我正在尝试进行一些MongoDB查询,但它不起作用。
这就是对象的外观:
{
"_id" : ObjectId("5c616e96aeddc93e2c076101"),
"_class" : "school.domain.mongo.User",
"username" : "test1234",
"password" : "test1234",
"status" : "ACTIVE",
"time_created" : ISODate("2019-02-11T13:46:14.753+01:00"),
"last_modified" : ISODate("2019-02-11T13:46:14.753+01:00")
}
现在我需要找到在过去24小时内修改了数据的用户
这是我试过的问题,但不起作用
db.getCollection('user').find({
$and : [
{"status" : "ACTIVE"},
{"last_modified" : { $lt: new Date(), $gte: new Date(new Date().setDate(new Date().getDate()-1))}},
{"last_modified" : { $ne: "time_created"}}
]
})
用户必须处于活动状态,最近一次在当前范围内修改,过去24小时内修改
最后修改的时间必须与创建的时间不同,因为如果它与用户相同,则只在过去24小时内创建而不修改。
我已经尝试过这个查询,它仍然会给我具有相同的上次修改和时间创建值的用户。