1 var mongoose = require('../../lib');
4 // import the global schema, this can be done in any file that needs the model
5 require('./person.js')();
7 // grab the person model object
8 var Person = mongoose.model('Person');
10 // connect to a server to do a quick write / read example
12 mongoose.connect('mongodb://localhost/persons', function(err) {
20 birthday: new Date().setFullYear((new Date().getFullYear() - 25))
21 }, function(err, bill) {
25 console.log('People added to db: %s', bill.toString());
26 Person.find({}, function(err, people) {
31 people.forEach(function(person) {
32 console.log('People in the db: %s', person.toString());
35 // make sure to clean things up after we're done
36 setTimeout(function() {
44 Person.remove(function() {
45 mongoose.disconnect();