Answer the question
In order to leave comments, you need to log in
How to make such a query to the mongoDB database?
I have a database with many content records { text: 'message text', date: '*date the record was added*' }
The date field is formed like this date: new Date()
How to write a query that will display 10 records sorted by date , i.e. first recent, then old?
MongoDB, node.js
Answer the question
In order to leave comments, you need to log in
If using the Node.js MongoDB driver:
collection.find({}).sort({date: -1}).limit(10).toArray(function (data) { /* ваш код */ });
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question