I can't find the answer. I have a query that can return many answer and I want to get the last one. How to do it?
db.users.find({username: "bob", sort: {createdAt: -1}}).first()
I would like something like this.
do this to get last N records :
function last(N) {
return db.collection.find().skip(db.collection.count() - N);
}