2012-07-25 50 views

回答

9

要提取僅某些領域,通過字段名的字符串作爲第二個參數的find

// Include the first and last properties, and exclude _id 
Model.find({}, 'first last -_id', callback) 

,或者使用對象表示法如所描述的here

Model.find({}, {first: 1, last: 1, _id: 0}, callback) 

要只更新一些屬性,使用update$set修飾符:

// Only update the name property 
Model.update({_id: 12345}, {$set: {name: 'New name'}}, callback); 
3

我覺得跟3.0.0這是更新版本

Model.find({}, 'first last', callback); 

firstlast是在模型的屬性名。