I'am trying to make some mongoDB query, but it doesn't work. This is how object look:
{
"_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")
}
Now i need to find user who are modified their data in the last 24 hours This is query that i try but it doesn't work
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"}}
]
})
User must be active, last modified in range now and 24 hours in past And last modified must be different from time created, because if it's same than user is only created and not modified in the past 24 hours. I've tried this query and it still give me users that have same last_modified and time_created values.