问题:MovieSchema.pre('save',function(next){^^^^^^^^^^^SyntaxError: Unexpected identifier源代码:var mongoose = require('mongoose')//骨架模版var MovieSchema = new mongoose.Schema({ doctor:String, title:String, language:String, country:String, year:Number, summary:String, flash:String, poster:String, meta:{ createAt:{ type:Date, default:Date.now() }, updateAt:{ type:Date, default:Date.now() } }//为模式增加方法MovieSchema.pre('save',function(next){ if (this.isNew) { this.meta.createAt = this.meta.updateAt = Date.now() }else{ this.meta.updateAt = Date.now() }})//添加静态方法MovieSchema.statics ={ fetch:function(cb){ return this .find({}) .sort('meta.updateAt') .exec(cb) }, findById:function(id,cb){ return this .findOne({_id:id}) .exec(cb) }}module.exports = MovieSchema
添加回答
举报
0/150
提交
取消