Skip to content

Commit

Permalink
use mongo-mock only if memory
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanoff committed Aug 23, 2017
1 parent 5afb33d commit ad1bc08
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/db/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
'use strict'

var mongodb = require('mongodb');
var mongodbTest = require('mongo-mock');
mongodbTest.max_delay = 0;

var state = { db: null };

Expand All @@ -20,8 +18,12 @@ var state = { db: null };
*/
exports.connect = function (url, done) {
if (state.db) return done();
var MongoClient = (process.env.DB_STORAGE === 'memory')?
mongodbTest.MongoClient : mongodb.MongoClient;
var MongoClient = mongodb.MongoClient;
if(process.env.DB_STORAGE === 'memory') {
var mongodbTest = require('mongo-mock');
mongodbTest.max_delay = 0;
MongoClient = mongodbTest.MongoClient
}
MongoClient.connect(url, function (err, db) {
if (err) return done(err);
state.db = db;
Expand Down

0 comments on commit ad1bc08

Please sign in to comment.