Defining the Photo Model

Listing 27.2 implements the Photo model schema for the application. The schema is also very basic; it includes title, filename, timestamp, and commentId fields. The commentId field has the same purpose as the commentId field in the Page model. This reused field makes it easier to later add comments to any additional pages or object models that you want to add to the application.

Listing 27.2 photo_model.js: Implementing the Photo model for Mongoose


01 var mongoose = require('mongoose'),
02     Schema = mongoose.Schema;
03 var PhotoSchema = new Schema({
04     title: String,
05     filename: String,
06     timestamp: { type: Date, default: Date.now },
07     commentId: Schema.ObjectId
08 });
09 mongoose.model('Photo', PhotoSchema);


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

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