Skip to content

Instantly share code, notes, and snippets.

@bnoguchi
Created June 9, 2011 08:20
Show Gist options
  • Save bnoguchi/1016313 to your computer and use it in GitHub Desktop.
Save bnoguchi/1016313 to your computer and use it in GitHub Desktop.
mongoose GH-241 non-failing example
var mongoose = require('mongoose')
, Schema = mongoose.Schema ;
mongoose.connect('mongodb://localhost/test');
var ContactNameSchema = new Schema({
familyName: String,
givenName: String
});
var ContactSchema = new Schema({
name: [ContactNameSchema]
});
var Contact = mongoose.model('Contact', ContactSchema);
var contact = new Contact();
contact.name.push({
familyName: '',
givenName: '',
SOME_EXTRA_ACCIDENTAL_FIELD: ''
});
contact.save(function (err) {
if (err) throw err;
mongoose.disconnect();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment