git ssb

0+

cel-desktop / ssb-pkg



Tree: c5c7a8ffadbd51aa28a5f3f096fe43f69405da44

Files: c5c7a8ffadbd51aa28a5f3f096fe43f69405da44 / 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