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.
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);