2 // import async to make control flow simplier
3 var async = require('async');
5 // import the rest of the normal stuff
6 var mongoose = require('../../lib');
8 require('./person.js')();
10 var Person = mongoose.model('Person');
12 // define some dummy data
17 birthday: new Date().setFullYear((new Date().getFullYear() - 25))
22 birthday: new Date().setFullYear((new Date().getFullYear() - 30))
27 birthday: new Date().setFullYear((new Date().getFullYear() - 21))
32 birthday: new Date().setFullYear((new Date().getFullYear() - 26))
37 birthday: new Date().setFullYear((new Date().getFullYear() - 1000))
42 // to connect to a replica set, pass in the comma delimited uri and optionally
43 // any connection options such as the rs_name.
45 replSet: {rs_name: 'rs0'}
47 mongoose.connect('mongodb://localhost:27018/persons,localhost:27019,localhost:27020', opts, function(err) {
50 // create all of the dummy people
51 async.each(data, function(item, cb) {
52 Person.create(item, cb);
58 // create and delete some data
59 var prom = Person.find({age: {$lt: 1000}}).exec();
61 prom.then(function(people) {
62 console.log('young people: %s', people);
68 Person.remove(function() {
69 mongoose.disconnect();