In my mongo collection, I have several records with timestamps. I want to use findOne()
and return the oldest record with a where parameter.
If it's not possible to use findOne()
, it's alright. I just need to return the oldest record with a where parameter.
How can this be done in MongoDB?
If you need an oldest record, use
db.collection.find().sort({ created: *1* }).limit(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With