LearnBoost/mongoose — Issue #766: Setting key=value of embedded obj causes value=key on parent
Author: troyk
Created: 2012-03-09 03:48:33+00:00
State: open

```javascript
var ContactSchema = new Schema({
company: String,
name: {
first: String,
last: String
}
});
Contact = mongoose.model('Contact', ContactSchema, 'contacts');

c = new Contact();
c.name = 'val1';
c.name = 'val2';
c._delta(); //=> { '$set': { val1: 'name', val2: 'name' } }

```

Ideally, it would be nice to put a setter on 'name'. What I thought I was going to do is a pre-save hook and if name is a string, parse it back to an object.