Comparing version 2.1.2 to 2.2.0
@@ -9,3 +9,2 @@ 'use strict'; | ||
const pluralize = require('pluralize'); | ||
const mongodb = require('mongodb'); | ||
const Promise = require('bluebird'); | ||
@@ -21,5 +20,7 @@ const extend = require('class-extend').extend; | ||
let mongodb = require('mongodb'); | ||
let MongoClient = mongodb.MongoClient; | ||
const Query = require('./query'); | ||
const MongoClient = mongodb.MongoClient; | ||
const emptyObject = {}; | ||
@@ -36,4 +37,26 @@ | ||
/** | ||
* Sets the driver. | ||
* | ||
* @api public | ||
* @param {object} driver The driver | ||
*/ | ||
Mongorito.setDriver = function(driver) { | ||
if (typeof driver !== 'undefined' && typeof driver.MongoClient !== 'undefined') { | ||
mongodb = driver; | ||
MongoClient = driver.MongoClient; | ||
} | ||
}; | ||
/** | ||
* Gets the driver. | ||
* | ||
* @api public | ||
* @return {object} The driver. | ||
*/ | ||
Mongorito.getDriver = function() { | ||
return mongodb; | ||
}; | ||
/** | ||
* Connect to a MongoDB database and return connection object | ||
@@ -74,2 +97,3 @@ * | ||
if (!self.db) { | ||
db.url = urls.join(','); | ||
self.db = db; | ||
@@ -118,3 +142,3 @@ } | ||
Mongorito._collection = function (db, name) { | ||
let url = db.s.options.url; | ||
let url = db.url; | ||
let collections = this._collections[url]; | ||
@@ -509,3 +533,3 @@ | ||
if (action === 'create' || action === 'update') { | ||
hooks.push.apply(hooks, this._hooks[when].save); | ||
hooks = hooks.concat(this._hooks[when].save); | ||
} | ||
@@ -512,0 +536,0 @@ |
@@ -370,4 +370,4 @@ 'use strict'; | ||
// ensure _id is ObjectId | ||
if (query._id && !is.object(query._id)) { | ||
if (typeof query._id === 'object') { | ||
if (query._id) { | ||
if (is.object(query._id)) { | ||
if (query._id.$in) { | ||
@@ -374,0 +374,0 @@ let convertedIds = []; |
{ | ||
"name": "mongorito", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "ES6 generator-based MongoDB ODM. It rocks.", | ||
@@ -60,5 +60,6 @@ "author": "Vadim Demedes <vdemedes@gmail.com>", | ||
"prefer-arrow-callback": 0, | ||
"prefer-spread": 0 | ||
"prefer-spread": 0, | ||
"no-use-extend-native/no-use-extend-native": 0 | ||
} | ||
} | ||
} |
33058
1177