April 2020
Intermediate to advanced
716 pages
18h 55m
English
We will implement a Mongoose model to define a Media model for storing the details of each piece of media that's posted to the application. This model will be defined in server/models/media.model.js, and the implementation will be similar to other Mongoose model implementations we covered in the previous chapters, such as the Course model we defined in Chapter 6, Building a Web-Based Classroom Application. The Media schema in this model will have fields to record the media title, description, genre, number of views, dates of when the media was posted and updated, and a reference to the user who posted the media. The code for defining the media fields is as follows: