I'm new to Meteor and trying to figure out how to best design this database to store and publish data. I thought it would make sense to use these packages:
https://github.com/aldeed/meteor-autoform
https://github.com/aldeed/meteor-simple-schema
https://github.com/iron-meteor/iron-router
I'd have a collection for the list of courses to be listed on a page:
Courses = new Mongo.Collection("courses");
Courses.attachSchema(new SimpleSchema({
title: {
type: String,
label: "Title",
max: 200
},
comingSoon: {
type: boolean,
label: "Coming Soon?"
},
description: {
type: String,
label: "Course Description",
max: 200
}
}));
And a collection for the lessons inside each course:
Lessons = new Mongo.Collection("lessons");
Lessons.attachSchema(new SimpleSchema({
title: {
type: String,
label: "Title",
max: 200
},
video: {
type: String,
label: "Link to video"
},
}));
and have a admin page to create new courses/lessons using the autoform package.
My questions is how would I link the course to the lessons related to it? Would I use iron:router to listen to parameters in the url and query both collections and create the template layout?
You should have a field corresponding to the Lesson / Course relation, similarly as in traditional databases.
For example:
Lessons.attachSchema(new SimpleSchema({
...
courseId: {type: String}, // ID of the corresponding course
}));
or:
Courses.attachSchema(new SimpleSchema({
...
lessonIds: {type: [String]}, // Array of IDs of lessons
}));