git ssb

0+

cel-desktop / ssb-pkg



Tree: 1eb144e388da5f1a3466703f56ac4ab591d700fc

Files: 1eb144e388da5f1a3466703f56ac4ab591d700fc / test / test-79-npm / mongoose / mongoose.js

766 bytesRaw
1'use strict';
2
3var mongoose = require('mongoose');
4mongoose.connect('mongodb://localhost/pkg-test');
5
6var Cat = mongoose.model('Cat', { name: String });
7var name = 'Tuz' + (new Date()).getTime().toString();
8var kitty = new Cat({ name: name });
9
10kitty.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