0
select _id from project where projectName = '***' order by viewCount desc limit 5

我对 mongoose 还很陌生,并且对 SQL 有一定的理解,这是我的尝试,因为我正在尝试检索ObjectId排序返回的

ProjectModel.find({id}).sort({viewCount: -1}).limit(5).exec( 
    function(err, projects) {
        ...
    }
);
4

1 回答 1

2
ProjectModel.find({projectName: '***'}, ["_id"]).sort({viewCount: -1}).limit(5).exec( 
    function(err, projects) {
        ...
    }
);
于 2012-11-08T21:11:44.540 回答