ProjectModel.find({projectName: '***'}, ["_id"]).sort({viewCount: -1}).limit(5).exec(
function(err, projects) {
...
}
);
what is the mongoose equivalent for the SQL query
-
28-11-2021 - |
Domanda
select _id from project where projectName = '***' order by viewCount desc limit 5
i'm still new to mongoose and have a somewhat intermediate SQL understanding, here's my attempt of it as i'm trying to retrieve the ObjectId
of the sorted return
ProjectModel.find({id}).sort({viewCount: -1}).limit(5).exec(
function(err, projects) {
...
}
);
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow