Created
March 2, 2012 17:56
-
-
Save jerem/1960043 to your computer and use it in GitHub Desktop.
Mongoose array bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var TestSchema = new mongoose.Schema({ | |
a : Array, | |
s : String, | |
n : Number | |
}); | |
var Test = mongoose.model('Test', TestSchema); | |
mongoose.connection.once('open', function() { | |
this.db.collection('tests', function(err, collection) { | |
// First we drop the collection | |
collection.drop(function(err) { | |
// Then we insert an empty doc | |
collection.insert({}, function(err) { | |
// And find it with mongoose | |
Test.findOne({}, function(err, item) { | |
console.log(err, item); | |
item.a = undefined; | |
item.s = undefined; | |
item.n = undefined; | |
console.log(item._delta()); | |
}); | |
}); | |
}); | |
}); | |
}); | |
mongoose.connect('mongodb://127.0.0.1:27017/test'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment