I am finding latest 15 minutes data with ObjectID.
Find Query:
db.data.find({
_id: {
$gte: new ObjectId(
Math.floor(new Date(ISODate().getTime() - 1000 * 60 * 15) / 1000).toString(16) + "0000000000000000"
)
}
})
Output:
{ "_id" : ObjectId("57c3ef6837ff7057a2ad3cca"), "User" : "Karthick", age: 26 }
{ "_id" : ObjectId("57c3ef6837ff7057a2ad3cce"), "User" : "Raja", age: 29 }
But, I am trying to take the data dump,
mongodump --query '{ _id: { $gte: new ObjectId(Math.floor(new Date(ISODate().getTime() - 1000 * 60 * 15) / 1000).toString(16) + "0000000000000000") } }' --db test --collection data --username abcdef --password abc@123 --authenticationDatabase admin -o "mongodump"
Error
Failed: error parsing query as json: invalid character 't' in literal MaxKey (expecting 'x')
I am getting the above error. How do I solve this issue or how do I put 15 minutes data dump in cronjob?