Defining the Page Model

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.ObjectId
06 });
07 mongoose.model('Page', PageSchema);


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.50.71