我想要排除Mongoose设置的虚拟id字段。
var Bar = new Schema({ body: String });
var Foo = new Schema({ bars: type: Schema.Types.ObjectId, ref: 'Bar' });
Foo
.find({..query...})
.populate('bars', 'body -_id')
.exec(function(err, foos){
console.log(foos); // { bars: [{id: null, body: 'body string'}] }
});
我该如何摆脱那个“id”字段?由于在populate中排除了_id,因此它已经是null了。
'body -_id -id'
有效吗? - royhowie