June 2014
Intermediate to advanced
696 pages
38h 52m
English
Listing 27.1 implements the Page model schema for the application. The schema is very simple and includes only name and commentId fields. Notice that the name field is set to be unique, which is necessary to be able to look up the page by name. The main purpose of the Page model is to provide a place where you can associate a webpage with a comment thread.
Listing 27.1 page_model.js: Implementing the Page model for Mongoose
01 var mongoose = require('mongoose'),02 Schema = mongoose.Schema;03 var PageSchema = new Schema({04 name: {type: String, unique: true},05 commentId: Schema.ObjectId06 });07 mongoose.model('Page', PageSchema);
Read now
Unlock full access