forked from Automattic/mongoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_goosetest.js
42 lines (31 loc) · 872 Bytes
/
_goosetest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var mongoose = require('../../');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var dbname = 'goosetest-{NAME}';
mongoose.connect('localhost', dbname);
mongoose.connection.on('error', function () {
console.error('connection error', arguments);
});
var schema = new Schema({
name: String
});
var A = mongoose.model('A', schema);
mongoose.connection.on('open', function () {
var a = new A({ name: '{NAME}' });
a.save(function (err) {
if (err) return done(err);
A.findById(a, function (err, doc) {
console.log(arguments);
done(err);
})
})
});
function done (err) {
if (err) console.error(err.stack);
mongoose.connection.db.dropDatabase(function () {
mongoose.connection.close();
});
}