You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Mongoose 4.0.4 I've found what I think is an incompatibility with the native Mongo driver. This issue is not present in 4.0.1. It appears to only happen if I also install the native mongo driver as a dependency in the project, even though it's not used in the sample code itself.
varassert=require('assert');varmongoose=require('mongoose');varSchema=mongoose.Schema;varObjectId=mongoose.Types.ObjectId;mongoose.connect('mongodb://localhost/mongoose-test');varCat=mongoose.model('Cat',{name: String,bestFriend: {type: Schema.Types.ObjectId,ref: 'Cat'}});// Clear all catsCat.remove({},function(err){assert.equal(err,null);// Save a new catvarkitty=newCat({_id: '607f1f77bcf86cd799439012',name: 'Zildjian'});kitty.save(function(err){assert.equal(err,null);// Save a cat using direct collection insertCat.collection.insert({_id: ObjectId('507f1f77bcf86cd799439011'),name: 'Zildjian',bestFriend: ObjectId('607f1f77bcf86cd799439012')},function(err){assert.equal(err,null);// Asert that cat was saved correctlyCat.findById('507f1f77bcf86cd799439011',function(err,cat){assert.equal(err,null);assert.equal(typeofcat.bestFriend,'object');// This failsprocess.exit(0);});});});});
In the above code assert.equal(typeof cat.bestFriend, 'object'); will fail with AssertionError: "undefined" == "object". It appears for some reason it doesn't want to save that value.
The text was updated successfully, but these errors were encountered:
In Mongoose
4.0.4
I've found what I think is an incompatibility with the native Mongo driver. This issue is not present in4.0.1
. It appears to only happen if I also install the native mongo driver as a dependency in the project, even though it's not used in the sample code itself.node version v0.10.37
npm version 1.4.28
I've simplified it down to the following code:
package.json
index.js
In the above code
assert.equal(typeof cat.bestFriend, 'object');
will fail withAssertionError: "undefined" == "object"
. It appears for some reason it doesn't want to save that value.The text was updated successfully, but these errors were encountered: