PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/node_modules/mquery/test/collection/node.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 28 lines | 21 code | 6 blank | 1 comment | 1 complexity | 1d7bb159ed7371735ef264a6008113f1 MD5 | raw file
 1
 2var assert = require('assert')
 3var slice = require('sliced')
 4var mongo = require('mongodb')
 5var utils = require('../../').utils;
 6
 7var uri = process.env.MQUERY_URI || 'mongodb://localhost/mquery';
 8var db;
 9
10exports.getCollection = function (cb) {
11  mongo.MongoClient.connect(uri, function (err, db_) {
12    assert.ifError(err);
13    db = db_;
14
15    var collection = db.collection('stuff');
16
17    // clean test db before starting
18    db.dropDatabase(function () {
19      cb(null, collection);
20    });
21  })
22}
23
24exports.dropCollection = function (cb) {
25  db.dropDatabase(function () {
26    db.close(cb);
27  })
28}