2012-07-25 91 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是在模型的属性名。