mongoose and partial select/update

mongodb, mongoose

Solution

To fetch only certain fields, pass a string of field names as the second parameter in your `find`:

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

or use the object notation as described here:

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

To only update some of the properties, use an `update` with a `$set` modifier:

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

Problem

In node.js, when I use Mongoose: is it possible to only fetch some of the values of a large object? Is it possible to only update some of the values?

Original source