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.
01 var mongoose = require('mongoose'),
02 Schema = mongoose.Schema;
03 var PageSchema = new Schema({
04 name: {type: String, unique: true},
05 commentId: Schema.ObjectId
06 });
07 mongoose.model('Page', PageSchema);