Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Created November 7, 2011 17:08
Show Gist options
  • Save aheckmann/1345540 to your computer and use it in GitHub Desktop.
Save aheckmann/1345540 to your computer and use it in GitHub Desktop.
var mongoose = require('./mongoose');
mongoose.connect('localhost', 'testing_585');
var child = { name: String };
var Child = new mongoose.Schema(child);
var Par = new mongoose.Schema({ child: child });
var P = mongoose.model('Par', Par);
mongoose.connection.on('open', function () {
var p = new P;
p.child.name = "mario";
p.save(function (err) {
if (err) return console.error(err.stack||err);
P.findById(p, function (err, doc) {
if (err) return console.error(err.stack||err);
console.error(doc);
mongoose.connection.db.dropDatabase(function () {
mongoose.connection.close();
});
});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment