Well, just try :)
// uses streamline.js
var mongoose = require('mongoose');
var client = mongoose.connect('mongodb://localhost/test');
var Doc = mongoose.model('Doc', new mongoose.Schema({
name : String,
body : String
}));
var doc = new Doc({ name : 'foo', body : 'this is the body' }).save(_);
var result = Doc.findById(doc._id).select('-body').exec(_);
console.log('R#1', result);
doc.name = 'new name';
var newdoc = doc.save(_);
var result2 = Doc.findById(newdoc._id).exec(_);
console.log('R#2', result2);
This prints:
R#1 { name: 'foo', _id: 525506fb23c4904b61000001, __v: 0 }
R#2 { __v: 0,
_id: 525506fb23c4904b61000001,
body: 'this is the body',
name: 'new name' }
So the body
property still exists.
The reason why is that .save()
for an existing document actually executes an .update()
internally.