Skip to content

Instantly share code, notes, and snippets.

@asalant
Created April 19, 2013 21:35
Show Gist options
  • Save asalant/5423400 to your computer and use it in GitHub Desktop.
Save asalant/5423400 to your computer and use it in GitHub Desktop.
Set mixed { '0': { name: 'Foo' },
'1':
{ path: 'mixed',
instance: undefined,
validators: [],
setters: [ [Function] ],
getters: [],
options: { type: [Function: Mixed] },
_index: null } }
Set mixed { '0': 'Bar',
'1':
{ path: 'mixed',
instance: undefined,
validators: [],
setters: [ [Function] ],
getters: [],
options: { type: [Function: Mixed] },
_index: null } }
var mongoose = require('mongoose');
var schema = new mongoose.Schema({
mixed: {type: mongoose.Schema.Types.Mixed}
});
schema.path('mixed').set(function (data) {
console.log("Set mixed", arguments);
return data;
});
var TestModel = mongoose.model('TestModel', schema);
var obj = new TestModel({mixed: { name: 'Foo'}});
obj.set('mixed.name', 'Bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment