db.events.find().forEach(function(doc)
{
var iso_date = new Date(doc.starts_at);
if(iso_date>= new Date() && iso_date<= new Date(new Date().setDate(new
Date().getDate()+4))){
printjson(doc);
}
})
我无法删除在 MongoDB 中_id
使用的字段printjson()
。我正在根据我使用 JavaScript 处理的特定条件打印字段。使用 打印时printjson()
,我无法删除_id
字段。有没有办法_id
在使用打印时删除printjson()
?
只需使用投影来避免在数据库结果中返回 _id :
db.events.find(
{starts_at: {$gte: Date.now(), $lte: new Date().setDate(4)}},
{_id:0}
)
.forEach(function(doc)
{
printjson(doc);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句