Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Created July 25, 2011 15:03
Show Gist options
  • Save aheckmann/1104335 to your computer and use it in GitHub Desktop.
Save aheckmann/1104335 to your computer and use it in GitHub Desktop.
'pushing to an array of Mixed works': function () {
var db = start();
mongoose.model('MySchema_', new Schema({
arrays: []
}));
var DooDad = db.model('MySchema_')
, doodad = new DooDad({ arrays: [] })
, date = 1234567890;
doodad.arrays.push(["+10", "yup", date]);
doodad.save(function (err) {
should.strictEqual(err, null);
DooDad.findById(doodad._id, function (err, doodad) {
should.strictEqual(err, null);
doodad.arrays.toObject().should.eql([['+10','yup',date]]);
doodad.arrays.push(["another", 1]);
doodad.save(function (err) {
should.strictEqual(err, null);
DooDad.findById(doodad._id, function (err, doodad) {
should.strictEqual(err, null);
doodad
.arrays
.toObject()
.should.eql([['+10','yup',date], ["another", 1]]);
db.close();
});
});
})
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment