Set Mongoose model instance properties with "extend" util

I have Mongoose model instance:

var s = new Song({
  song_id: '123',
  title: 'sample song',
  artist: {
    name: 'sample artist',
    id: '456'
  }
});

Now I'd like to set/update its properties but using extend (e.g. from nodejs util._extend)

s = extend(s, {
  title: 'changed title',
  artist: {
    name: 'changed artist',
    id: '789'
  }
});

s.save();

And while title (as a top-level property) gets set ok, changes in artist are not visible.

I know I can just set it via:

s.artist.name = 'changed artist';

but is there something I'm missing or is this way of updating properties not usable?

EDIT

Gah... Looks like someone defined schema the wrong way. Instead of artist field defined as

artist: {
  name: String, 
  id: String
} 

it was defined like

artist.name: String, 
artist.id: String

When I redefined it it works now. Thanks

What you can do is to use Mongoose's update method:

Song.update({
    song_id: '123',
}, {
    $set: {
        title: 'changed title',
        artist: {
            name: 'changed artist',
            id: '789',
        },
    },
}, function(err, numAffected) {
    ...
});

However, I don't actually see why your extend attempt failed. It seems to work for me, I usually use underscore's _.extend function.