Skip to content

Instantly share code, notes, and snippets.

@jerem
Created March 2, 2012 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jerem/1960043 to your computer and use it in GitHub Desktop.
Save jerem/1960043 to your computer and use it in GitHub Desktop.
Mongoose array bug
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