如何基于ObjectId(_id)删除文档

时间:2017-08-14 15:02:36

标签: mongodb mongodb-query mongodb-shell

如何编写一个MongoDB shell查询,该查询将返回在特定日期之后创建的所有对象的文档?

收藏品如:

{
"_id" : ObjectId("59918c9014450171039b7e1f"),
"cont_id" : "59918c9014450171039b7e1d",
"systemdate" : ISODate("2017-07-25T00:09:00.567Z"),
}

db.itemtable.count({"systemdate" : { $gte: ISODate("2017-07-25T00:00:00.000Z")}})

退货 - 15210

db.itemtable.count({'_id': {'$gt' : ObjectId("59918c9014450171039b7e1f")}})

退货 - 987652

谢谢! Bharathi

1 个答案:

答案 0 :(得分:0)

db.itemtable.find({"systemdate" : { $gte: ISODate("2017-07-25T00:00:00.000Z")}}).count() 返回这些文件的数量。

如果您想要光标到这些文档,请使用find db.itemtable.find({"systemdate" : { $gte: ISODate("2017-07-25T00:00:00.000Z")}})

相关问题