Answer the question
In order to leave comments, you need to log in
How to find top 10 records in MongoDB using mongoose?
There are entries like this:
[
{
name: 'статья',
popularity: 12
},
{
name: 'статья',
popularity: 10
},
{
name: 'статья',
popularity: 15
},
]
Answer the question
In order to leave comments, you need to log in
.
Records
.find(...)
.sort({popularity: -1})
.limit(10)
.exec(...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question