I'm unable to push regular objects to an array of Mixed fields in mongoose.
I'm trying this:
ME.update({_id: eventid},
{$push: { rawdata: {x: packet.x, y: packet.y} }},
{upsert:true}, function(err, data) {
console.log(err);
}
});
However, this only results in an array of ids in the mongodb database:
[rawdata] => Array (
[0] => Array (
[_id] => MongoId Object (
[$id] => 50f476a13ebe522960000005
)
)
[1] => Array (
[_id] => MongoId Object (
[$id] => 50f476a13ebe522960000006
)
)
[2] => Array (
[_id] => MongoId Object (
[$id] => 50f476a23ebe522960000007
)
)
[3] => Array (
[_id] => MongoId Object (
[$id] => 50f476a23ebe522960000008
)
)
[4] => Array (
[_id] => MongoId Object (
[$id] => 50f476a23ebe522960000009
)
)
[5] => Array (
[_id] => MongoId Object (
[$id] => 50f476a33ebe52296000000a
)
)
[6] => Array (
[_id] => MongoId Object (
[$id] => 50f476a33ebe52296000000b
)
)
[7] => Array (
[_id] => MongoId Object (
[$id] => 50f476a33ebe52296000000c
)
)
Not at all what I expected. What's going wrong?
First I create the "rawdata" schema: (Here I use an empty object literal, I also used the Schema.Types.Mixed one)
{ rawdata: { type: {} } }
And then I add that to the bigger schema, which results in something like:
rawdata:
[ { paths: [Object],
subpaths: {},
virtuals: [Object],
nested: {},
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
statics: {},
tree: [Object],
_requiredpaths: undefined,
options: [Object] } ],