【发布时间】:2012-02-13 23:53:44
【问题描述】:
我希望来自 mongodb 的 mongoose 查询回调结果仅包含文档的某个部分。现在,以下代码返回整个文档,而不仅仅是假定的切片数组部分。任何线索为什么?在数据库中,pending 实际上包含超过 10 个元素。谢谢
var NotificationsReference = new Schema({
id : Number, //fbid
unRead : Number,
pendingSize : Number,
pending : [Notification]
});
NotificationsReference.find({ id: userId}, { pending: { $slice: [skip, 5]}}, function(err, result){
if(err || result === null){
callback("Failed");
}
else{
callback(result);
}
});
【问题讨论】:
标签: javascript node.js mongodb mongoose