KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to know the most recent record in a collection. How to do that? Note: I know the following command line queries works: 1. db.test.find().sort({"idate":-1}).limit(1).forEach(printjson); 2. db.test.find().skip(db.test.count()-1).forEach(printjson) where idate has the timestamp added. The problem is longer the collection is the time to get back the data and my 'test' collection is really really huge. I need a query with constant time response. If there is any better mongodb command line query, do let me know.
Tags (comma-separated)
Save Edits
Cancel