I have a mongoose schema with a virtual of mixed type. For example:
var mongoose = require('mongoose') // version 3.3.1
var FooSchema = new mongoose.Schema( { x: Number } );
FooSchema.virtual('v').set( function(value){
console.log("SETTING", value);
});
var Foo = mongoose.model('Foo', FooSchema);
new Foo( { v:1 } );
new Foo( { v:[] } );
new Foo( { v:{} } );
When I run this code I get:
SETTING 1
SETTING []
As you'll notice it never shows "SETTING {}", any reason why this doesn't work?
This was an open issue in Mongoose that's been fixed in a recent commit by Aaron Heckmann.