我的mongodb中有一个包含此格式记录的集合
db.userlogins.find().pretty()
{
"_id" : ObjectId("519bb8c11f30bbf5bcba06f0"),
"userId" : "sai",
"created_at" : "2013-05-16 10:31:02.765"
}
{
"_id" : ObjectId("519bb8cf1f30bbf5bcba06f1"),
"userId" : "sai",
"created_at" : "2013-05-17 10:31:02.765"
}
{
"_id" : ObjectId("519bb8db1f30bbf5bcba06f2"),
"userId" : "sai",
"created_at" : "2013-05-18 10:31:02.765"
}
{
"_id" : ObjectId("519bb8e71f30bbf5bcba06f3"),
"userId" : "sai",
"created_at" : "2013-05-19 10:31:02.765"
}
{
"_id" : ObjectId("519bb8f21f30bbf5bcba06f4"),
"userId" : "sai",
"created_at" : "2013-05-20 10:31:02.765"
}
{
"_id" : ObjectId("519bb8fc1f30bbf5bcba06f5"),
"userId" : "sai",
"created_at" : "2013-05-21 10:31:02.765"
我试图找出以certian范围登录的用户
所以我试过
db.userlogins.find({created_on: {$gte: "2013-05-17 10:31:02.765", $lt: "2013-05-21 10:31:02.765"}});
但是不知道为什么它没有返回任何数据? 有人可以帮忙吗
答案 0 :(得分:2)
这将有效:
db.userlogins.find({created_at: {$gte: "2013-05-17 10:31:02.765", $lt: "2013-05-21 10:31:02.765"}});