April 2020
Intermediate to advanced
716 pages
18h 55m
English
We need to define the lesson data structure and associate it with the course data structure before we can store and retrieve lesson details for each course.
We will start by defining the Lesson model, with a schema containing the title, the content, and the resource URL fields of the string type, as shown in the following code.
mern-classroom/server/models/course.model.js
const LessonSchema = new mongoose.Schema({ title: String, content: String, resource_url: String})const Lesson = mongoose.model('Lesson', LessonSchema)
These schemas will let educators create and store basic lessons for their courses. To integrate lessons with the course structure, we will add a field called lessons in the Course model, which will store an ...
Read now
Unlock full access