August 2016
Intermediate to advanced
376 pages
6h 33m
English
Now let's create the application's template files. Since we are using the mongoose middleware used in chapter 1, Building a Twitter-Like Application Using the MVC Design Pattern in Node.js, we will keep the same type of configuration:
comments.js inside the models folder at server/models and add the following code: // load the things we need var mongoose = require('mongoose'); var Schema = mongoose.Schema; var commentSchema = mongoose.Schema({ created: { type: Date, default: Date.now }, title: { type: String, default: '', trim: true, required: 'Title cannot be blank' }, content: { type: String, default: '', trim: true }, user: { type: Schema.ObjectId, ref: 'User' } }); module.exports = mongoose.model('Comments', ...Read now
Unlock full access