Files: ca90b5ca0579ebdcc0635288bce4978e3fb200f5 / test / test-79-npm / mongoose / mongoose.js
766 bytesRaw
1 | ; |
2 | |
3 | var mongoose = require('mongoose'); |
4 | mongoose.connect('mongodb://localhost/pkg-test'); |
5 | |
6 | var Cat = mongoose.model('Cat', { name: String }); |
7 | var name = 'Tuz' + (new Date()).getTime().toString(); |
8 | var kitty = new Cat({ name: name }); |
9 | |
10 | kitty.save(function (error1) { |
11 | if (error1) return; |
12 | Cat.find({}).$where(function () { |
13 | return (this.name.slice(0, 3) === 'Tuz'); // eslint-disable-line no-invalid-this |
14 | }).exec(function (error2, cats) { |
15 | if (process.pkg) { |
16 | if (cats) return; |
17 | if (error2.message.indexOf('Pkg') >= 0) { |
18 | console.log('ok'); |
19 | mongoose.disconnect(); |
20 | } |
21 | } else { |
22 | if (error2) return; |
23 | if (cats.length > 0) { |
24 | console.log('ok'); |
25 | mongoose.disconnect(); |
26 | } |
27 | } |
28 | }); |
29 | }); |
30 |
Built with git-ssb-web