码迷,mamicode.com
首页 > 其他好文 > 详细

mongo virtual

时间:2016-10-29 12:00:06      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:option   json   mongo   ups   mis   false   iss   ast   function   

var options={"upsert":false,"multi":false,‘new‘:false}; 不存是否插入,更新是否批量,返回内容是更新前还是后.

permissions.findOne(query, function (err, data) {
if (err) return next(err);
res.json(data);
});

var PersonSchema = new Schema({
name:{
first:String,
last:String
}
});
var PersonModel = mongoose.model(‘Person‘,PersonSchema);
PersonSchema.virtual(‘name.full‘).get(function(){
return this.name.first + ‘ ‘ + this.name.last;
});
PersonSchema.virtual(‘name.full‘).set(function(name){
var split = name.split(‘ ‘);
this.name.first = split[0];
this.name.last = split[1];
});

mongo virtual

标签:option   json   mongo   ups   mis   false   iss   ast   function   

原文地址:http://www.cnblogs.com/jayruan/p/6010272.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!