0
select _id from project where projectName = '***' order by viewCount desc limit 5
我還是新來貓鼬,並有一些表現中間SQL的理解,這是我的嘗試它,因爲我試圖檢索排序回報ObjectId
什麼是貓鼬相當於爲SQL查詢
ProjectModel.find({id}).sort({viewCount: -1}).limit(5).exec(
function(err, projects) {
...
}
);
***'是什麼意思?如果'projectName'不爲null,則返回'_id'並用'viewCount'對其進行排序並將結果限制爲5? – bouncingHippo
請參閱http://mongoosejs.com/docs/api.html#model_Model-find'{projectName:'***'}'是'where projectName ='***''等同於SQL – Esailija