diff --git a/dist/js-data-mongodb.js b/dist/js-data-mongodb.js
index 623a3a0..d1d7a30 100644
--- a/dist/js-data-mongodb.js
+++ b/dist/js-data-mongodb.js
@@ -77,8 +77,8 @@ var REMOVE_OPTS_DEFAULTS = {};
*
* @example
* // Use Container instead of DataStore on the server
- * import {Container} from 'js-data'
- * import MongoDBAdapter from 'js-data-mongodb'
+ * import { Container } from 'js-data';
+ * import MongoDBAdapter from 'js-data-mongodb';
*
* // Create a store to hold your Mappers
* const store = new Container({
@@ -86,16 +86,16 @@ var REMOVE_OPTS_DEFAULTS = {};
* // MongoDB uses "_id" as the primary key
* idAttribute: '_id'
* }
- * })
+ * });
*
* // Create an instance of MongoDBAdapter with default settings
- * const adapter = new MongoDBAdapter()
+ * const adapter = new MongoDBAdapter();
*
* // Mappers in "store" will use the MongoDB adapter by default
- * store.registerAdapter('mongodb', adapter, { default: true })
+ * store.registerAdapter('mongodb', adapter, { default: true });
*
* // Create a Mapper that maps to a "user" collection
- * store.defineMapper('user')
+ * store.defineMapper('user');
*
* @class MongoDBAdapter
* @extends Adapter
@@ -1041,8 +1041,8 @@ jsDataAdapter.Adapter.extend({
* Details of the current version of the `js-data-mongodb` module.
*
* @example
- * import {version} from 'js-data-mongodb'
- * console.log(version.full)
+ * import { version } from 'js-data-mongodb';
+ * console.log(version.full);
*
* @name module:js-data-mongodb.version
* @type {object}
@@ -1056,18 +1056,18 @@ jsDataAdapter.Adapter.extend({
* otherwise `false` if the current version is not beta.
*/
var version = {
- full: '1.0.1',
+ full: '1.0.2',
major: 1,
minor: 0,
- patch: 1
+ patch: 2
};
/**
* {@link MongoDBAdapter} class.
*
* @example
- * import {MongoDBAdapter} from 'js-data-mongodb'
- * const adapter = new MongoDBAdapter()
+ * import { MongoDBAdapter } from 'js-data-mongodb';
+ * const adapter = new MongoDBAdapter();
*
* @name module:js-data-mongodb.MongoDBAdapter
* @see MongoDBAdapter
@@ -1078,71 +1078,71 @@ var version = {
* Registered as `js-data-mongodb` in NPM.
*
* @example
Install from NPM
- * npm i --save js-data-mongodb@rc js-data@rc mongodb bson
+ * npm i --save js-data-mongodb js-data mongodb bson
*
* @example Load via CommonJS
- * var MongoDBAdapter = require('js-data-mongodb').MongoDBAdapter
- * var adapter = new MongoDBAdapter()
+ * const MongoDBAdapter = require('js-data-mongodb').MongoDBAdapter;
+ * const adapter = new MongoDBAdapter();
*
* @example Load via ES2015 Modules
- * import {MongoDBAdapter} from 'js-data-mongodb'
- * const adapter = new MongoDBAdapter()
+ * import { MongoDBAdapter } from 'js-data-mongodb';
+ * const adapter = new MongoDBAdapter();
*
* @module js-data-mongodb
*/
/**
-* Create a subclass of this MongoDBAdapter:
-* @example MongoDBAdapter.extend
-* // Normally you would do: import { MongoDBAdapter } from 'js-data-mongodb'
-* const JSDataMongoDB = require('js-data-mongodb')
-* const { MongoDBAdapter } = JSDataMongoDB
-* console.log('Using JSDataMongoDB v' + JSDataMongoDB.version.full)
-*
-* // Extend the class using ES2015 class syntax.
-* class CustomMongoDBAdapterClass extends MongoDBAdapter {
-* foo () { return 'bar' }
-* static beep () { return 'boop' }
-* }
-* const customMongoDBAdapter = new CustomMongoDBAdapterClass()
-* console.log(customMongoDBAdapter.foo())
-* console.log(CustomMongoDBAdapterClass.beep())
-*
-* // Extend the class using alternate method.
-* const OtherMongoDBAdapterClass = MongoDBAdapter.extend({
-* foo () { return 'bar' }
-* }, {
-* beep () { return 'boop' }
-* })
-* const otherMongoDBAdapter = new OtherMongoDBAdapterClass()
-* console.log(otherMongoDBAdapter.foo())
-* console.log(OtherMongoDBAdapterClass.beep())
-*
-* // Extend the class, providing a custom constructor.
-* function AnotherMongoDBAdapterClass () {
-* MongoDBAdapter.call(this)
-* this.created_at = new Date().getTime()
-* }
-* MongoDBAdapter.extend({
-* constructor: AnotherMongoDBAdapterClass,
-* foo () { return 'bar' }
-* }, {
-* beep () { return 'boop' }
-* })
-* const anotherMongoDBAdapter = new AnotherMongoDBAdapterClass()
-* console.log(anotherMongoDBAdapter.created_at)
-* console.log(anotherMongoDBAdapter.foo())
-* console.log(AnotherMongoDBAdapterClass.beep())
-*
-* @method MongoDBAdapter.extend
-* @param {object} [props={}] Properties to add to the prototype of the
-* subclass.
-* @param {object} [props.constructor] Provide a custom constructor function
-* to be used as the subclass itself.
-* @param {object} [classProps={}] Static properties to add to the subclass.
-* @returns {Constructor} Subclass of this MongoDBAdapter class.
-* @since 3.0.0
-*/
+ * Create a subclass of this MongoDBAdapter:
+ * @example MongoDBAdapter.extend
+ * // Normally you would do: import { MongoDBAdapter } from 'js-data-mongodb';
+ * const JSDataMongoDB = require('js-data-mongodb');
+ * const { MongoDBAdapter } = JSDataMongoDB;
+ * console.log('Using JSDataMongoDB v' + JSDataMongoDB.version.full);
+ *
+ * // Extend the class using ES2015 class syntax.
+ * class CustomMongoDBAdapterClass extends MongoDBAdapter {
+ * foo () { return 'bar'; }
+ * static beep () { return 'boop'; }
+ * }
+ * const customMongoDBAdapter = new CustomMongoDBAdapterClass();
+ * console.log(customMongoDBAdapter.foo());
+ * console.log(CustomMongoDBAdapterClass.beep());
+ *
+ * // Extend the class using alternate method.
+ * const OtherMongoDBAdapterClass = MongoDBAdapter.extend({
+ * foo () { return 'bar'; }
+ * }, {
+ * beep () { return 'boop'; }
+ * });
+ * const otherMongoDBAdapter = new OtherMongoDBAdapterClass();
+ * console.log(otherMongoDBAdapter.foo());
+ * console.log(OtherMongoDBAdapterClass.beep());
+ *
+ * // Extend the class, providing a custom constructor.
+ * function AnotherMongoDBAdapterClass () {
+ * MongoDBAdapter.call(this);
+ * this.created_at = new Date().getTime();
+ * }
+ * MongoDBAdapter.extend({
+ * constructor: AnotherMongoDBAdapterClass,
+ * foo () { return 'bar'; }
+ * }, {
+ * beep () { return 'boop'; }
+ * });
+ * const anotherMongoDBAdapter = new AnotherMongoDBAdapterClass();
+ * console.log(anotherMongoDBAdapter.created_at);
+ * console.log(anotherMongoDBAdapter.foo());
+ * console.log(AnotherMongoDBAdapterClass.beep());
+ *
+ * @method MongoDBAdapter.extend
+ * @param {object} [props={}] Properties to add to the prototype of the
+ * subclass.
+ * @param {object} [props.constructor] Provide a custom constructor function
+ * to be used as the subclass itself.
+ * @param {object} [classProps={}] Static properties to add to the subclass.
+ * @returns {Constructor} Subclass of this MongoDBAdapter class.
+ * @since 3.0.0
+ */
exports.MongoDBAdapter = MongoDBAdapter;
exports.version = version;
diff --git a/dist/js-data-mongodb.js.map b/dist/js-data-mongodb.js.map
index c38b54b..badd373 100644
--- a/dist/js-data-mongodb.js.map
+++ b/dist/js-data-mongodb.js.map
@@ -1 +1 @@
-{"version":3,"file":"js-data-mongodb.js","sources":["../src/index.js"],"sourcesContent":["import {MongoClient} from 'mongodb'\nimport {ObjectID} from 'bson'\nimport {utils} from 'js-data'\nimport {\n Adapter,\n reserved\n} from 'js-data-adapter'\nimport snakeCase from 'lodash.snakecase'\n\nconst DEFAULTS = {\n /**\n * Convert ObjectIDs to strings when pulling records out of the database.\n *\n * @name MongoDBAdapter#translateId\n * @type {boolean}\n * @default true\n */\n translateId: true,\n /**\n * Convert fields of record from database that are ObjectIDs to strings\n *\n * @name MongoDBAdapter#translateObjectIDs\n * @type {Boolean}\n * @default false\n */\n translateObjectIDs: false,\n\n /**\n * MongoDB URI.\n *\n * @name MongoDBAdapter#uri\n * @type {string}\n * @default mongodb://localhost:27017\n */\n uri: 'mongodb://localhost:27017',\n\n /**\n * MongoDB Driver options\n *\n * @name MongoDBAdapter#mongoDriverOpts\n * @type {object}\n * @default { ignoreUndefined: true }\n */\n mongoDriverOpts: {\n ignoreUndefined: true\n }\n}\n\nconst COUNT_OPTS_DEFAULTS = {}\nconst FIND_OPTS_DEFAULTS = {}\nconst FIND_ONE_OPTS_DEFAULTS = {}\nconst INSERT_OPTS_DEFAULTS = {}\nconst INSERT_MANY_OPTS_DEFAULTS = {}\nconst UPDATE_OPTS_DEFAULTS = {}\nconst REMOVE_OPTS_DEFAULTS = {}\n\n/**\n * MongoDBAdapter class.\n *\n * @example\n * // Use Container instead of DataStore on the server\n * import {Container} from 'js-data'\n * import MongoDBAdapter from 'js-data-mongodb'\n *\n * // Create a store to hold your Mappers\n * const store = new Container({\n * mapperDefaults: {\n * // MongoDB uses \"_id\" as the primary key\n * idAttribute: '_id'\n * }\n * })\n *\n * // Create an instance of MongoDBAdapter with default settings\n * const adapter = new MongoDBAdapter()\n *\n * // Mappers in \"store\" will use the MongoDB adapter by default\n * store.registerAdapter('mongodb', adapter, { default: true })\n *\n * // Create a Mapper that maps to a \"user\" collection\n * store.defineMapper('user')\n *\n * @class MongoDBAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {object} [opts.countOpts] See {@link MongoDBAdapter#countOpts}.\n * @param {object} [opts.findOpts] See {@link MongoDBAdapter#findOpts}.\n * @param {object} [opts.findOneOpts] See {@link MongoDBAdapter#findOneOpts}.\n * @param {object} [opts.insertOpts] See {@link MongoDBAdapter#insertOpts}.\n * @param {object} [opts.insertManyOpts] See {@link MongoDBAdapter#insertManyOpts}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {object} [opts.removeOpts] See {@link MongoDBAdapter#removeOpts}.\n * @param {boolean} [opts.translateId=true] See {@link MongoDBAdapter#translateId}.\n * @param {boolean} [opts.translateObjectIDs=false] See {@link MongoDBAdapter#translateObjectIDs}.\n * @param {object} [opts.updateOpts] See {@link MongoDBAdapter#updateOpts}.\n * @param {string} [opts.uri=\"mongodb://localhost:27017\"] See {@link MongoDBAdapter#uri}.\n */\nexport function MongoDBAdapter (opts) {\n utils.classCallCheck(this, MongoDBAdapter)\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { uri: opts }\n }\n utils.fillIn(opts, DEFAULTS)\n\n // Setup non-enumerable properties\n Object.defineProperties(this, {\n /**\n * A Promise that resolves to a reference to the MongoDB client being used by\n * this adapter.\n *\n * @name MongoDBAdapter#client\n * @type {Promise}\n */\n client: {\n writable: true,\n value: undefined\n },\n\n _db: {\n writable: true,\n value: undefined\n }\n })\n\n Adapter.call(this, opts)\n\n /**\n * Default options to pass to collection#count.\n *\n * @name MongoDBAdapter#countOpts\n * @type {object}\n * @default {}\n */\n this.countOpts || (this.countOpts = {})\n utils.fillIn(this.countOpts, COUNT_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#find.\n *\n * @name MongoDBAdapter#findOpts\n * @type {object}\n * @default {}\n */\n this.findOpts || (this.findOpts = {})\n utils.fillIn(this.findOpts, FIND_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#findOne.\n *\n * @name MongoDBAdapter#findOneOpts\n * @type {object}\n * @default {}\n */\n this.findOneOpts || (this.findOneOpts = {})\n utils.fillIn(this.findOneOpts, FIND_ONE_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#insert.\n *\n * @name MongoDBAdapter#insertOpts\n * @type {object}\n * @default {}\n */\n this.insertOpts || (this.insertOpts = {})\n utils.fillIn(this.insertOpts, INSERT_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#insertMany.\n *\n * @name MongoDBAdapter#insertManyOpts\n * @type {object}\n * @default {}\n */\n this.insertManyOpts || (this.insertManyOpts = {})\n utils.fillIn(this.insertManyOpts, INSERT_MANY_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#update.\n *\n * @name MongoDBAdapter#updateOpts\n * @type {object}\n * @default {}\n */\n this.updateOpts || (this.updateOpts = {})\n utils.fillIn(this.updateOpts, UPDATE_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#destroy.\n *\n * @name MongoDBAdapter#removeOpts\n * @type {object}\n * @default {}\n */\n this.removeOpts || (this.removeOpts = {})\n utils.fillIn(this.removeOpts, REMOVE_OPTS_DEFAULTS)\n\n this.client = new utils.Promise((resolve, reject) => {\n MongoClient.connect(opts.uri, opts.mongoDriverOpts, (err, db) => {\n if (err) {\n return reject(err)\n }\n this._db = db\n resolve(db)\n })\n })\n}\n\nAdapter.extend({\n constructor: MongoDBAdapter,\n\n _translateObjectIDs (r, opts) {\n opts || (opts = {})\n if (this.getOpt('translateObjectIDs', opts)) {\n this._translateFieldObjectIDs(r)\n } else if (this.getOpt('translateId', opts)) {\n this._translateId(r)\n }\n return r\n },\n\n /**\n * Translate ObjectIDs to strings.\n *\n * @method MongoDBAdapter#_translateId\n * @return {*}\n */\n _translateId (r) {\n if (utils.isArray(r)) {\n r.forEach((_r) => {\n const __id = _r._id ? _r._id.toString() : _r._id\n _r._id = typeof __id === 'string' ? __id : _r._id\n })\n } else if (utils.isObject(r)) {\n const __id = r._id ? r._id.toString() : r._id\n r._id = typeof __id === 'string' ? __id : r._id\n }\n return r\n },\n\n _translateFieldObjectIDs (r) {\n const _checkFields = (r) => {\n for (let field in r) {\n if (r[field]._bsontype === 'ObjectID') {\n r[field] = typeof r[field].toString() === 'string' ? r[field].toString() : r[field]\n }\n }\n }\n if (utils.isArray(r)) {\n r.forEach((_r) => {\n _checkFields(_r)\n })\n } else if (utils.isObject(r)) {\n _checkFields(r)\n }\n return r\n },\n\n /**\n * Retrieve the number of records that match the selection query.\n *\n * @method MongoDBAdapter#count\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {object} [opts.countOpts] Options to pass to collection#count.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#count.\n *\n * @method MongoDBAdapter#_count\n * @private\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const countOpts = this.getOpt('countOpts', opts)\n utils.fillIn(countOpts, this.getQueryOptions(mapper, query))\n\n const mongoQuery = this.getQuery(mapper, query)\n\n client\n .collection(collectionId)\n .count(mongoQuery, countOpts, (err, count) => err ? failure(err) : success([count, {}]))\n })\n },\n\n /**\n * Create a new record.\n *\n * @method MongoDBAdapter#create\n * @param {object} mapper The mapper.\n * @param {object} props The record to be created.\n * @param {object} [opts] Configuration options.\n * @param {object} [opts.insertOpts] Options to pass to collection#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * @return {Promise}\n */\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @method MongoDBAdapter#_create\n * @private\n * @param {object} mapper The mapper.\n * @param {object} props The record to be created.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const insertOpts = this.getOpt('insertOpts', opts)\n\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n props = utils.plainCopy(props)\n\n if (collection.insertOne) {\n collection\n .insertOne(props, insertOpts, handler)\n } else {\n collection\n .insert(props, insertOpts, handler)\n }\n }).then((cursor) => {\n let record\n let r = cursor.ops ? cursor.ops : cursor\n this._translateObjectIDs(r, opts)\n record = utils.isArray(r) ? r[0] : r\n cursor.connection = undefined\n return [record, cursor]\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @method MongoDBAdapter#createMany\n * @param {object} mapper The mapper.\n * @param {object} props The records to be created.\n * @param {object} [opts] Configuration options.\n * @param {object} [opts.insertManyOpts] Options to pass to\n * collection#insertMany.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @method MongoDBAdapter#_createMany\n * @private\n * @param {object} mapper The mapper.\n * @param {object} props The records to be created.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const insertManyOpts = this.getOpt('insertManyOpts', opts)\n props = utils.plainCopy(props)\n\n client.collection(collectionId)\n .insertMany(props, insertManyOpts, (err, cursor) => err ? failure(err) : success(cursor))\n }).then((cursor) => {\n let records = []\n let r = cursor.ops ? cursor.ops : cursor\n this._translateObjectIDs(r, opts)\n records = r\n cursor.connection = undefined\n return [records, cursor]\n })\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @method MongoDBAdapter#destroy\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.removeOpts] Options to pass to collection#remove.\n * @return {Promise}\n */\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @method MongoDBAdapter#_destroy\n * @private\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const removeOpts = this.getOpt('removeOpts', opts)\n\n const mongoQuery = {\n [mapper.idAttribute]: this.toObjectID(mapper, id)\n }\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.deleteOne) {\n collection\n .deleteOne(mongoQuery, removeOpts, handler)\n } else {\n collection\n .remove(mongoQuery, removeOpts, handler)\n }\n }).then((cursor) => [undefined, cursor])\n },\n\n /**\n * Destroy the records that match the selection query.\n *\n * @method MongoDBAdapter#destroyAll\n * @param {object} mapper the mapper.\n * @param {object} [query] Selection query.\n * @param {object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.removeOpts] Options to pass to collection#remove.\n * @return {Promise}\n */\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @method MongoDBAdapter#_destroyAll\n * @private\n * @param {object} mapper the mapper.\n * @param {object} [query] Selection query.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const removeOpts = this.getOpt('removeOpts', opts)\n utils.fillIn(removeOpts, this.getQueryOptions(mapper, query))\n\n const mongoQuery = this.getQuery(mapper, query)\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.deleteMany) {\n collection\n .deleteMany(mongoQuery, removeOpts, handler)\n } else {\n collection\n .remove(mongoQuery, removeOpts, handler)\n }\n }).then((cursor) => {\n cursor.connection = undefined\n return [undefined, cursor]\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @method MongoDBAdapter#find\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @param {object} [opts.findOneOpts] Options to pass to collection#findOne.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @method MongoDBAdapter#_find\n * @private\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @return {Promise}\n */\n _find (mapper, id, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const findOneOpts = this.getOpt('findOneOpts', opts)\n findOneOpts.fields = this._getFields(mapper, opts)\n\n const mongoQuery = {\n [mapper.idAttribute]: this.toObjectID(mapper, id)\n }\n\n client.collection(collectionId)\n .findOne(mongoQuery, findOneOpts, (err, record) => err ? failure(err) : success(record))\n }).then((record) => {\n if (record) {\n this._translateObjectIDs(record, opts)\n } else {\n record = undefined\n }\n return [record, {}]\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @method MongoDBAdapter#findAll\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @param {object} [opts.findOpts] Options to pass to collection#find.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @method MongoDBAdapter#_findAll\n * @private\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const findOpts = this.getOpt('findOpts', opts)\n utils.fillIn(findOpts, this.getQueryOptions(mapper, query))\n findOpts.fields = this._getFields(mapper, opts)\n\n const mongoQuery = this.getQuery(mapper, query)\n\n client.collection(collectionId)\n .find(mongoQuery, findOpts)\n .toArray((err, records) => err ? failure(err) : success(records))\n }).then((records) => {\n this._translateObjectIDs(records, opts)\n return [records, {}]\n })\n },\n\n _getCollectionId (mapper, opts) {\n opts || (opts = {})\n return opts.table || opts.collection || mapper.table || mapper.collection || snakeCase(mapper.name)\n },\n\n _getFields (mapper, opts) {\n opts || (opts = {})\n if (utils.isString(opts.fields)) {\n opts.fields = { [opts.fields]: 1 }\n } else if (utils.isArray(opts.fields)) {\n const fields = {}\n opts.fields.forEach((field) => {\n fields[field] = 1\n })\n return fields\n }\n return opts.fields\n },\n\n _run (cb) {\n if (this._db) {\n // Use the cached db object\n return new utils.Promise((resolve, reject) => {\n cb(this._db, resolve, reject)\n })\n }\n return this.getClient().then((client) => {\n return new utils.Promise((resolve, reject) => {\n cb(client, resolve, reject)\n })\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n *\n * @method MongoDBAdapter#update\n * @param {object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {object} props The update to apply to the record.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.updateOpts] Options to pass to collection#update.\n * @return {Promise}\n */\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @method MongoDBAdapter#_update\n * @private\n * @param {object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {object} props The update to apply to the record.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this._find(mapper, id, { raw: false })\n .then((result) => {\n if (!result[0]) {\n throw new Error('Not Found')\n }\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const updateOpts = this.getOpt('updateOpts', opts)\n\n const mongoQuery = {\n [mapper.idAttribute]: this.toObjectID(mapper, id)\n }\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.updateOne) {\n collection\n .updateOne(mongoQuery, { $set: props }, updateOpts, handler)\n } else {\n collection\n .update(mongoQuery, { $set: props }, updateOpts, handler)\n }\n })\n })\n .then((cursor) => {\n return this._find(mapper, id, { raw: false })\n .then((result) => {\n cursor.connection = undefined\n return [result[0], cursor]\n })\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n *\n * @method MongoDBAdapter#updateAll\n * @param {object} mapper The mapper.\n * @param {object} props The update to apply to the selected records.\n * @param {object} [query] Selection query.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.updateOpts] Options to pass to collection#update.\n * @return {Promise}\n */\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @method MongoDBAdapter#_updateAll\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let ids\n\n return this._run((client, success, failure) => {\n return this._findAll(mapper, query, { raw: false }).then((result) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const updateOpts = this.getOpt('updateOpts', opts)\n updateOpts.multi = true\n\n const queryOptions = this.getQueryOptions(mapper, query)\n queryOptions.$set = props\n ids = result[0].map((record) => this.toObjectID(mapper, record[mapper.idAttribute]))\n\n const mongoQuery = this.getQuery(mapper, query)\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.updateMany) {\n collection\n .updateMany(mongoQuery, queryOptions, updateOpts, handler)\n } else {\n collection\n .update(mongoQuery, queryOptions, updateOpts, handler)\n }\n })\n }).then((cursor) => {\n const query = {\n [mapper.idAttribute]: {\n 'in': ids\n }\n }\n return this._findAll(mapper, query, { raw: false }).then((result) => {\n cursor.connection = undefined\n return [result[0], cursor]\n })\n })\n },\n\n /**\n * Return a Promise that resolves to a reference to the MongoDB client being\n * used by this adapter.\n *\n * Useful when you need to do anything custom with the MongoDB client library.\n *\n * @method MongoDBAdapter#getClient\n * @return {object} MongoDB client.\n */\n getClient () {\n return this.client\n },\n\n /**\n * Map filtering params in a selection query to MongoDB a filtering object.\n *\n * Handles the following:\n *\n * - where\n * - and bunch of filtering operators\n *\n * @method MongoDBAdapter#getQuery\n * @return {object}\n */\n getQuery (mapper, query) {\n query = utils.plainCopy(query || {})\n query.where || (query.where = {})\n\n utils.forOwn(query, function (config, keyword) {\n if (reserved.indexOf(keyword) === -1) {\n if (utils.isObject(config)) {\n query.where[keyword] = config\n } else {\n query.where[keyword] = {\n '==': config\n }\n }\n delete query[keyword]\n }\n })\n\n let mongoQuery = {}\n\n if (Object.keys(query.where).length !== 0) {\n utils.forOwn(query.where, function (criteria, field) {\n if (!utils.isObject(criteria)) {\n query.where[field] = {\n '==': criteria\n }\n }\n utils.forOwn(criteria, function (v, op) {\n if (op === '==' || op === '===' || op === 'contains') {\n mongoQuery[field] = v\n } else if (op === '!=' || op === '!==' || op === 'notContains') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$ne = v\n } else if (op === '>') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$gt = v\n } else if (op === '>=') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$gte = v\n } else if (op === '<') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$lt = v\n } else if (op === '<=') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$lte = v\n } else if (op === 'in') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$in = v\n } else if (op === 'notIn') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$nin = v\n } else if (op === '|==' || op === '|===' || op === '|contains') {\n mongoQuery.$or = mongoQuery.$or || []\n let orEqQuery = {}\n orEqQuery[field] = v\n mongoQuery.$or.push(orEqQuery)\n } else if (op === '|!=' || op === '|!==' || op === '|notContains') {\n mongoQuery.$or = mongoQuery.$or || []\n let orNeQuery = {}\n orNeQuery[field] = {\n '$ne': v\n }\n mongoQuery.$or.push(orNeQuery)\n } else if (op === '|>') {\n mongoQuery.$or = mongoQuery.$or || []\n let orGtQuery = {}\n orGtQuery[field] = {\n '$gt': v\n }\n mongoQuery.$or.push(orGtQuery)\n } else if (op === '|>=') {\n mongoQuery.$or = mongoQuery.$or || []\n let orGteQuery = {}\n orGteQuery[field] = {\n '$gte': v\n }\n mongoQuery.$or.push(orGteQuery)\n } else if (op === '|<') {\n mongoQuery.$or = mongoQuery.$or || []\n let orLtQuery = {}\n orLtQuery[field] = {\n '$lt': v\n }\n mongoQuery.$or.push(orLtQuery)\n } else if (op === '|<=') {\n mongoQuery.$or = mongoQuery.$or || []\n let orLteQuery = {}\n orLteQuery[field] = {\n '$lte': v\n }\n mongoQuery.$or.push(orLteQuery)\n } else if (op === '|in') {\n mongoQuery.$or = mongoQuery.$or || []\n let orInQuery = {}\n orInQuery[field] = {\n '$in': v\n }\n mongoQuery.$or.push(orInQuery)\n } else if (op === '|notIn') {\n mongoQuery.$or = mongoQuery.$or || []\n let orNinQuery = {}\n orNinQuery[field] = {\n '$nin': v\n }\n mongoQuery.$or.push(orNinQuery)\n }\n })\n })\n }\n\n return mongoQuery\n },\n\n /**\n * Map non-filtering params in a selection query to MongoDB query options.\n *\n * Handles the following:\n *\n * - limit\n * - skip/offset\n * - orderBy/sort\n *\n * @method MongoDBAdapter#getQueryOptions\n * @return {object}\n */\n getQueryOptions (mapper, query) {\n query = utils.plainCopy(query || {})\n query.orderBy = query.orderBy || query.sort\n query.skip = query.skip || query.offset\n\n let queryOptions = {}\n\n if (query.orderBy) {\n if (utils.isString(query.orderBy)) {\n query.orderBy = [\n [query.orderBy, 'asc']\n ]\n }\n for (var i = 0; i < query.orderBy.length; i++) {\n if (utils.isString(query.orderBy[i])) {\n query.orderBy[i] = [query.orderBy[i], 'asc']\n }\n }\n queryOptions.sort = query.orderBy\n }\n\n if (query.skip) {\n queryOptions.skip = +query.skip\n }\n\n if (query.limit) {\n queryOptions.limit = +query.limit\n }\n\n return queryOptions\n },\n\n /**\n * Turn an _id into an ObjectID if it isn't already an ObjectID.\n *\n * @method MongoDBAdapter#toObjectID\n * @return {*}\n */\n toObjectID (mapper, id) {\n if (id !== undefined && mapper.idAttribute === '_id' && typeof id === 'string' && ObjectID.isValid(id) && !(id instanceof ObjectID)) {\n return new ObjectID(id)\n }\n return id\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * @method MongoDBAdapter#makeBelongsToForeignKey\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return this.toObjectID(def.getRelation(), Adapter.prototype.makeBelongsToForeignKey.call(this, mapper, def, record))\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @method MongoDBAdapter#makeHasManyLocalKeys\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n const relatedMapper = def.getRelation()\n const localKeys = Adapter.prototype.makeHasManyLocalKeys.call(this, mapper, def, record)\n return localKeys.map((key) => this.toObjectID(relatedMapper, key))\n },\n\n /**\n * Not supported.\n *\n * @method MongoDBAdapter#updateMany\n */\n updateMany () {\n throw new Error('not supported!')\n }\n})\n\n/**\n * Details of the current version of the `js-data-mongodb` module.\n *\n * @example\n * import {version} from 'js-data-mongodb'\n * console.log(version.full)\n *\n * @name module:js-data-mongodb.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * {@link MongoDBAdapter} class.\n *\n * @example\n * import {MongoDBAdapter} from 'js-data-mongodb'\n * const adapter = new MongoDBAdapter()\n *\n * @name module:js-data-mongodb.MongoDBAdapter\n * @see MongoDBAdapter\n * @type {Constructor}\n */\n\n/**\n * Registered as `js-data-mongodb` in NPM.\n *\n * @example Install from NPM\n * npm i --save js-data-mongodb@rc js-data@rc mongodb bson\n *\n * @example Load via CommonJS\n * var MongoDBAdapter = require('js-data-mongodb').MongoDBAdapter\n * var adapter = new MongoDBAdapter()\n *\n * @example Load via ES2015 Modules\n * import {MongoDBAdapter} from 'js-data-mongodb'\n * const adapter = new MongoDBAdapter()\n *\n * @module js-data-mongodb\n */\n\n /**\n * Create a subclass of this MongoDBAdapter:\n * @example MongoDBAdapter.extend\n * // Normally you would do: import { MongoDBAdapter } from 'js-data-mongodb'\n * const JSDataMongoDB = require('js-data-mongodb')\n * const { MongoDBAdapter } = JSDataMongoDB\n * console.log('Using JSDataMongoDB v' + JSDataMongoDB.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomMongoDBAdapterClass extends MongoDBAdapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customMongoDBAdapter = new CustomMongoDBAdapterClass()\n * console.log(customMongoDBAdapter.foo())\n * console.log(CustomMongoDBAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherMongoDBAdapterClass = MongoDBAdapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherMongoDBAdapter = new OtherMongoDBAdapterClass()\n * console.log(otherMongoDBAdapter.foo())\n * console.log(OtherMongoDBAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherMongoDBAdapterClass () {\n * MongoDBAdapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * MongoDBAdapter.extend({\n * constructor: AnotherMongoDBAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherMongoDBAdapter = new AnotherMongoDBAdapterClass()\n * console.log(anotherMongoDBAdapter.created_at)\n * console.log(anotherMongoDBAdapter.foo())\n * console.log(AnotherMongoDBAdapterClass.beep())\n *\n * @method MongoDBAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this MongoDBAdapter class.\n * @since 3.0.0\n */\n"],"names":["DEFAULTS","COUNT_OPTS_DEFAULTS","FIND_OPTS_DEFAULTS","FIND_ONE_OPTS_DEFAULTS","INSERT_OPTS_DEFAULTS","INSERT_MANY_OPTS_DEFAULTS","UPDATE_OPTS_DEFAULTS","REMOVE_OPTS_DEFAULTS","MongoDBAdapter","opts","classCallCheck","utils","isString","uri","fillIn","defineProperties","undefined","call","countOpts","findOpts","findOneOpts","insertOpts","insertManyOpts","updateOpts","removeOpts","client","Promise","resolve","reject","connect","mongoDriverOpts","err","db","_db","Adapter","extend","r","getOpt","_translateFieldObjectIDs","_translateId","isArray","forEach","_r","__id","_id","toString","isObject","_checkFields","field","_bsontype","mapper","query","_run","success","failure","collectionId","_getCollectionId","getQueryOptions","mongoQuery","getQuery","collection","count","props","handler","cursor","plainCopy","insertOne","insert","then","record","ops","_translateObjectIDs","connection","insertMany","records","id","idAttribute","toObjectID","deleteOne","remove","deleteMany","with","fields","_getFields","findOne","find","toArray","table","snakeCase","name","cb","getClient","_find","raw","result","Error","updateOne","$set","update","ids","_findAll","multi","queryOptions","map","updateMany","where","forOwn","config","keyword","reserved","indexOf","Object","keys","length","criteria","v","op","$ne","$gt","$gte","$lt","$lte","$in","$nin","$or","orEqQuery","push","orNeQuery","orGtQuery","orGteQuery","orLtQuery","orLteQuery","orInQuery","orNinQuery","orderBy","sort","skip","offset","i","limit","ObjectID","isValid","def","getRelation","prototype","makeBelongsToForeignKey","relatedMapper","localKeys","makeHasManyLocalKeys","key","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,WAAW;;;;;;;;eAQF,IARE;;;;;;;;sBAgBK,KAhBL;;;;;;;;;OAyBV,2BAzBU;;;;;;;;;mBAkCE;qBACE;;CAnCrB;;AAuCA,IAAMC,sBAAsB,EAA5B;AACA,IAAMC,qBAAqB,EAA3B;AACA,IAAMC,yBAAyB,EAA/B;AACA,IAAMC,uBAAuB,EAA7B;AACA,IAAMC,4BAA4B,EAAlC;AACA,IA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YjH,sBAAQ8G,SAAR,CAAkBI,oBAAlB,CAAuCnI,IAAvC,CAA4C,IAA5C,EAAkDiC,MAAlD,EAA0D4F,GAA1D,EAA+DzE,MAA/D,CAAlB;WACO8E,UAAU5C,GAAV,CAAc,UAAC8C,GAAD;aAAS,QAAKxE,UAAL,CAAgBqE,aAAhB,EAA+BG,GAA/B,CAAT;KAAd,CAAP;GAhwBW;;;;;;;;YAAA,wBAwwBC;UACN,IAAItD,KAAJ,CAAU,gBAAV,CAAN;;CAzwBJ;;;;;;;;;;;;;;;;;;;;AA+xBA,AAAO,IAAMuD,UAAU,gBAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"js-data-mongodb.js","sources":["../src/index.js"],"sourcesContent":["import {MongoClient} from 'mongodb'\nimport {ObjectID} from 'bson'\nimport {utils} from 'js-data'\nimport {\n Adapter,\n reserved\n} from 'js-data-adapter'\nimport snakeCase from 'lodash.snakecase'\n\nconst DEFAULTS = {\n /**\n * Convert ObjectIDs to strings when pulling records out of the database.\n *\n * @name MongoDBAdapter#translateId\n * @type {boolean}\n * @default true\n */\n translateId: true,\n /**\n * Convert fields of record from database that are ObjectIDs to strings\n *\n * @name MongoDBAdapter#translateObjectIDs\n * @type {Boolean}\n * @default false\n */\n translateObjectIDs: false,\n\n /**\n * MongoDB URI.\n *\n * @name MongoDBAdapter#uri\n * @type {string}\n * @default mongodb://localhost:27017\n */\n uri: 'mongodb://localhost:27017',\n\n /**\n * MongoDB Driver options\n *\n * @name MongoDBAdapter#mongoDriverOpts\n * @type {object}\n * @default { ignoreUndefined: true }\n */\n mongoDriverOpts: {\n ignoreUndefined: true\n }\n}\n\nconst COUNT_OPTS_DEFAULTS = {}\nconst FIND_OPTS_DEFAULTS = {}\nconst FIND_ONE_OPTS_DEFAULTS = {}\nconst INSERT_OPTS_DEFAULTS = {}\nconst INSERT_MANY_OPTS_DEFAULTS = {}\nconst UPDATE_OPTS_DEFAULTS = {}\nconst REMOVE_OPTS_DEFAULTS = {}\n\n/**\n * MongoDBAdapter class.\n *\n * @example\n * // Use Container instead of DataStore on the server\n * import { Container } from 'js-data';\n * import MongoDBAdapter from 'js-data-mongodb';\n *\n * // Create a store to hold your Mappers\n * const store = new Container({\n * mapperDefaults: {\n * // MongoDB uses \"_id\" as the primary key\n * idAttribute: '_id'\n * }\n * });\n *\n * // Create an instance of MongoDBAdapter with default settings\n * const adapter = new MongoDBAdapter();\n *\n * // Mappers in \"store\" will use the MongoDB adapter by default\n * store.registerAdapter('mongodb', adapter, { default: true });\n *\n * // Create a Mapper that maps to a \"user\" collection\n * store.defineMapper('user');\n *\n * @class MongoDBAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {object} [opts.countOpts] See {@link MongoDBAdapter#countOpts}.\n * @param {object} [opts.findOpts] See {@link MongoDBAdapter#findOpts}.\n * @param {object} [opts.findOneOpts] See {@link MongoDBAdapter#findOneOpts}.\n * @param {object} [opts.insertOpts] See {@link MongoDBAdapter#insertOpts}.\n * @param {object} [opts.insertManyOpts] See {@link MongoDBAdapter#insertManyOpts}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {object} [opts.removeOpts] See {@link MongoDBAdapter#removeOpts}.\n * @param {boolean} [opts.translateId=true] See {@link MongoDBAdapter#translateId}.\n * @param {boolean} [opts.translateObjectIDs=false] See {@link MongoDBAdapter#translateObjectIDs}.\n * @param {object} [opts.updateOpts] See {@link MongoDBAdapter#updateOpts}.\n * @param {string} [opts.uri=\"mongodb://localhost:27017\"] See {@link MongoDBAdapter#uri}.\n */\nexport function MongoDBAdapter (opts) {\n utils.classCallCheck(this, MongoDBAdapter)\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { uri: opts }\n }\n utils.fillIn(opts, DEFAULTS)\n\n // Setup non-enumerable properties\n Object.defineProperties(this, {\n /**\n * A Promise that resolves to a reference to the MongoDB client being used by\n * this adapter.\n *\n * @name MongoDBAdapter#client\n * @type {Promise}\n */\n client: {\n writable: true,\n value: undefined\n },\n\n _db: {\n writable: true,\n value: undefined\n }\n })\n\n Adapter.call(this, opts)\n\n /**\n * Default options to pass to collection#count.\n *\n * @name MongoDBAdapter#countOpts\n * @type {object}\n * @default {}\n */\n this.countOpts || (this.countOpts = {})\n utils.fillIn(this.countOpts, COUNT_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#find.\n *\n * @name MongoDBAdapter#findOpts\n * @type {object}\n * @default {}\n */\n this.findOpts || (this.findOpts = {})\n utils.fillIn(this.findOpts, FIND_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#findOne.\n *\n * @name MongoDBAdapter#findOneOpts\n * @type {object}\n * @default {}\n */\n this.findOneOpts || (this.findOneOpts = {})\n utils.fillIn(this.findOneOpts, FIND_ONE_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#insert.\n *\n * @name MongoDBAdapter#insertOpts\n * @type {object}\n * @default {}\n */\n this.insertOpts || (this.insertOpts = {})\n utils.fillIn(this.insertOpts, INSERT_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#insertMany.\n *\n * @name MongoDBAdapter#insertManyOpts\n * @type {object}\n * @default {}\n */\n this.insertManyOpts || (this.insertManyOpts = {})\n utils.fillIn(this.insertManyOpts, INSERT_MANY_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#update.\n *\n * @name MongoDBAdapter#updateOpts\n * @type {object}\n * @default {}\n */\n this.updateOpts || (this.updateOpts = {})\n utils.fillIn(this.updateOpts, UPDATE_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to collection#destroy.\n *\n * @name MongoDBAdapter#removeOpts\n * @type {object}\n * @default {}\n */\n this.removeOpts || (this.removeOpts = {})\n utils.fillIn(this.removeOpts, REMOVE_OPTS_DEFAULTS)\n\n this.client = new utils.Promise((resolve, reject) => {\n MongoClient.connect(opts.uri, opts.mongoDriverOpts, (err, db) => {\n if (err) {\n return reject(err)\n }\n this._db = db\n resolve(db)\n })\n })\n}\n\nAdapter.extend({\n constructor: MongoDBAdapter,\n\n _translateObjectIDs (r, opts) {\n opts || (opts = {})\n if (this.getOpt('translateObjectIDs', opts)) {\n this._translateFieldObjectIDs(r)\n } else if (this.getOpt('translateId', opts)) {\n this._translateId(r)\n }\n return r\n },\n\n /**\n * Translate ObjectIDs to strings.\n *\n * @method MongoDBAdapter#_translateId\n * @return {*}\n */\n _translateId (r) {\n if (utils.isArray(r)) {\n r.forEach((_r) => {\n const __id = _r._id ? _r._id.toString() : _r._id\n _r._id = typeof __id === 'string' ? __id : _r._id\n })\n } else if (utils.isObject(r)) {\n const __id = r._id ? r._id.toString() : r._id\n r._id = typeof __id === 'string' ? __id : r._id\n }\n return r\n },\n\n _translateFieldObjectIDs (r) {\n const _checkFields = (r) => {\n for (let field in r) {\n if (r[field]._bsontype === 'ObjectID') {\n r[field] = typeof r[field].toString() === 'string' ? r[field].toString() : r[field]\n }\n }\n }\n if (utils.isArray(r)) {\n r.forEach((_r) => {\n _checkFields(_r)\n })\n } else if (utils.isObject(r)) {\n _checkFields(r)\n }\n return r\n },\n\n /**\n * Retrieve the number of records that match the selection query.\n *\n * @method MongoDBAdapter#count\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {object} [opts.countOpts] Options to pass to collection#count.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#count.\n *\n * @method MongoDBAdapter#_count\n * @private\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const countOpts = this.getOpt('countOpts', opts)\n utils.fillIn(countOpts, this.getQueryOptions(mapper, query))\n\n const mongoQuery = this.getQuery(mapper, query)\n\n client\n .collection(collectionId)\n .count(mongoQuery, countOpts, (err, count) => err ? failure(err) : success([count, {}]))\n })\n },\n\n /**\n * Create a new record.\n *\n * @method MongoDBAdapter#create\n * @param {object} mapper The mapper.\n * @param {object} props The record to be created.\n * @param {object} [opts] Configuration options.\n * @param {object} [opts.insertOpts] Options to pass to collection#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * @return {Promise}\n */\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @method MongoDBAdapter#_create\n * @private\n * @param {object} mapper The mapper.\n * @param {object} props The record to be created.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const insertOpts = this.getOpt('insertOpts', opts)\n\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n props = utils.plainCopy(props)\n\n if (collection.insertOne) {\n collection\n .insertOne(props, insertOpts, handler)\n } else {\n collection\n .insert(props, insertOpts, handler)\n }\n }).then((cursor) => {\n let record\n let r = cursor.ops ? cursor.ops : cursor\n this._translateObjectIDs(r, opts)\n record = utils.isArray(r) ? r[0] : r\n cursor.connection = undefined\n return [record, cursor]\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @method MongoDBAdapter#createMany\n * @param {object} mapper The mapper.\n * @param {object} props The records to be created.\n * @param {object} [opts] Configuration options.\n * @param {object} [opts.insertManyOpts] Options to pass to\n * collection#insertMany.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @method MongoDBAdapter#_createMany\n * @private\n * @param {object} mapper The mapper.\n * @param {object} props The records to be created.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const insertManyOpts = this.getOpt('insertManyOpts', opts)\n props = utils.plainCopy(props)\n\n client.collection(collectionId)\n .insertMany(props, insertManyOpts, (err, cursor) => err ? failure(err) : success(cursor))\n }).then((cursor) => {\n let records = []\n let r = cursor.ops ? cursor.ops : cursor\n this._translateObjectIDs(r, opts)\n records = r\n cursor.connection = undefined\n return [records, cursor]\n })\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @method MongoDBAdapter#destroy\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.removeOpts] Options to pass to collection#remove.\n * @return {Promise}\n */\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @method MongoDBAdapter#_destroy\n * @private\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const removeOpts = this.getOpt('removeOpts', opts)\n\n const mongoQuery = {\n [mapper.idAttribute]: this.toObjectID(mapper, id)\n }\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.deleteOne) {\n collection\n .deleteOne(mongoQuery, removeOpts, handler)\n } else {\n collection\n .remove(mongoQuery, removeOpts, handler)\n }\n }).then((cursor) => [undefined, cursor])\n },\n\n /**\n * Destroy the records that match the selection query.\n *\n * @method MongoDBAdapter#destroyAll\n * @param {object} mapper the mapper.\n * @param {object} [query] Selection query.\n * @param {object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.removeOpts] Options to pass to collection#remove.\n * @return {Promise}\n */\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @method MongoDBAdapter#_destroyAll\n * @private\n * @param {object} mapper the mapper.\n * @param {object} [query] Selection query.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const removeOpts = this.getOpt('removeOpts', opts)\n utils.fillIn(removeOpts, this.getQueryOptions(mapper, query))\n\n const mongoQuery = this.getQuery(mapper, query)\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.deleteMany) {\n collection\n .deleteMany(mongoQuery, removeOpts, handler)\n } else {\n collection\n .remove(mongoQuery, removeOpts, handler)\n }\n }).then((cursor) => {\n cursor.connection = undefined\n return [undefined, cursor]\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @method MongoDBAdapter#find\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @param {object} [opts.findOneOpts] Options to pass to collection#findOne.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @method MongoDBAdapter#_find\n * @private\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @return {Promise}\n */\n _find (mapper, id, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const findOneOpts = this.getOpt('findOneOpts', opts)\n findOneOpts.fields = this._getFields(mapper, opts)\n\n const mongoQuery = {\n [mapper.idAttribute]: this.toObjectID(mapper, id)\n }\n\n client.collection(collectionId)\n .findOne(mongoQuery, findOneOpts, (err, record) => err ? failure(err) : success(record))\n }).then((record) => {\n if (record) {\n this._translateObjectIDs(record, opts)\n } else {\n record = undefined\n }\n return [record, {}]\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @method MongoDBAdapter#findAll\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @param {object} [opts.findOpts] Options to pass to collection#find.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @method MongoDBAdapter#_findAll\n * @private\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string|string[]|object} [opts.fields] Select a subset of fields to be returned.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n opts || (opts = {})\n\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const findOpts = this.getOpt('findOpts', opts)\n utils.fillIn(findOpts, this.getQueryOptions(mapper, query))\n findOpts.fields = this._getFields(mapper, opts)\n\n const mongoQuery = this.getQuery(mapper, query)\n\n client.collection(collectionId)\n .find(mongoQuery, findOpts)\n .toArray((err, records) => err ? failure(err) : success(records))\n }).then((records) => {\n this._translateObjectIDs(records, opts)\n return [records, {}]\n })\n },\n\n _getCollectionId (mapper, opts) {\n opts || (opts = {})\n return opts.table || opts.collection || mapper.table || mapper.collection || snakeCase(mapper.name)\n },\n\n _getFields (mapper, opts) {\n opts || (opts = {})\n if (utils.isString(opts.fields)) {\n opts.fields = { [opts.fields]: 1 }\n } else if (utils.isArray(opts.fields)) {\n const fields = {}\n opts.fields.forEach((field) => {\n fields[field] = 1\n })\n return fields\n }\n return opts.fields\n },\n\n _run (cb) {\n if (this._db) {\n // Use the cached db object\n return new utils.Promise((resolve, reject) => {\n cb(this._db, resolve, reject)\n })\n }\n return this.getClient().then((client) => {\n return new utils.Promise((resolve, reject) => {\n cb(client, resolve, reject)\n })\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n *\n * @method MongoDBAdapter#update\n * @param {object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {object} props The update to apply to the record.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.updateOpts] Options to pass to collection#update.\n * @return {Promise}\n */\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @method MongoDBAdapter#_update\n * @private\n * @param {object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {object} props The update to apply to the record.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this._find(mapper, id, { raw: false })\n .then((result) => {\n if (!result[0]) {\n throw new Error('Not Found')\n }\n return this._run((client, success, failure) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const updateOpts = this.getOpt('updateOpts', opts)\n\n const mongoQuery = {\n [mapper.idAttribute]: this.toObjectID(mapper, id)\n }\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.updateOne) {\n collection\n .updateOne(mongoQuery, { $set: props }, updateOpts, handler)\n } else {\n collection\n .update(mongoQuery, { $set: props }, updateOpts, handler)\n }\n })\n })\n .then((cursor) => {\n return this._find(mapper, id, { raw: false })\n .then((result) => {\n cursor.connection = undefined\n return [result[0], cursor]\n })\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n *\n * @method MongoDBAdapter#updateAll\n * @param {object} mapper The mapper.\n * @param {object} props The update to apply to the selected records.\n * @param {object} [query] Selection query.\n * @param {object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {object} [opts.updateOpts] Options to pass to collection#update.\n * @return {Promise}\n */\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @method MongoDBAdapter#_updateAll\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let ids\n\n return this._run((client, success, failure) => {\n return this._findAll(mapper, query, { raw: false }).then((result) => {\n const collectionId = this._getCollectionId(mapper, opts)\n const updateOpts = this.getOpt('updateOpts', opts)\n updateOpts.multi = true\n\n const queryOptions = this.getQueryOptions(mapper, query)\n queryOptions.$set = props\n ids = result[0].map((record) => this.toObjectID(mapper, record[mapper.idAttribute]))\n\n const mongoQuery = this.getQuery(mapper, query)\n const collection = client.collection(collectionId)\n const handler = (err, cursor) => err ? failure(err) : success(cursor)\n\n if (collection.updateMany) {\n collection\n .updateMany(mongoQuery, queryOptions, updateOpts, handler)\n } else {\n collection\n .update(mongoQuery, queryOptions, updateOpts, handler)\n }\n })\n }).then((cursor) => {\n const query = {\n [mapper.idAttribute]: {\n 'in': ids\n }\n }\n return this._findAll(mapper, query, { raw: false }).then((result) => {\n cursor.connection = undefined\n return [result[0], cursor]\n })\n })\n },\n\n /**\n * Return a Promise that resolves to a reference to the MongoDB client being\n * used by this adapter.\n *\n * Useful when you need to do anything custom with the MongoDB client library.\n *\n * @method MongoDBAdapter#getClient\n * @return {object} MongoDB client.\n */\n getClient () {\n return this.client\n },\n\n /**\n * Map filtering params in a selection query to MongoDB a filtering object.\n *\n * Handles the following:\n *\n * - where\n * - and bunch of filtering operators\n *\n * @method MongoDBAdapter#getQuery\n * @return {object}\n */\n getQuery (mapper, query) {\n query = utils.plainCopy(query || {})\n query.where || (query.where = {})\n\n utils.forOwn(query, function (config, keyword) {\n if (reserved.indexOf(keyword) === -1) {\n if (utils.isObject(config)) {\n query.where[keyword] = config\n } else {\n query.where[keyword] = {\n '==': config\n }\n }\n delete query[keyword]\n }\n })\n\n let mongoQuery = {}\n\n if (Object.keys(query.where).length !== 0) {\n utils.forOwn(query.where, function (criteria, field) {\n if (!utils.isObject(criteria)) {\n query.where[field] = {\n '==': criteria\n }\n }\n utils.forOwn(criteria, function (v, op) {\n if (op === '==' || op === '===' || op === 'contains') {\n mongoQuery[field] = v\n } else if (op === '!=' || op === '!==' || op === 'notContains') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$ne = v\n } else if (op === '>') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$gt = v\n } else if (op === '>=') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$gte = v\n } else if (op === '<') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$lt = v\n } else if (op === '<=') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$lte = v\n } else if (op === 'in') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$in = v\n } else if (op === 'notIn') {\n mongoQuery[field] = mongoQuery[field] || {}\n mongoQuery[field].$nin = v\n } else if (op === '|==' || op === '|===' || op === '|contains') {\n mongoQuery.$or = mongoQuery.$or || []\n let orEqQuery = {}\n orEqQuery[field] = v\n mongoQuery.$or.push(orEqQuery)\n } else if (op === '|!=' || op === '|!==' || op === '|notContains') {\n mongoQuery.$or = mongoQuery.$or || []\n let orNeQuery = {}\n orNeQuery[field] = {\n '$ne': v\n }\n mongoQuery.$or.push(orNeQuery)\n } else if (op === '|>') {\n mongoQuery.$or = mongoQuery.$or || []\n let orGtQuery = {}\n orGtQuery[field] = {\n '$gt': v\n }\n mongoQuery.$or.push(orGtQuery)\n } else if (op === '|>=') {\n mongoQuery.$or = mongoQuery.$or || []\n let orGteQuery = {}\n orGteQuery[field] = {\n '$gte': v\n }\n mongoQuery.$or.push(orGteQuery)\n } else if (op === '|<') {\n mongoQuery.$or = mongoQuery.$or || []\n let orLtQuery = {}\n orLtQuery[field] = {\n '$lt': v\n }\n mongoQuery.$or.push(orLtQuery)\n } else if (op === '|<=') {\n mongoQuery.$or = mongoQuery.$or || []\n let orLteQuery = {}\n orLteQuery[field] = {\n '$lte': v\n }\n mongoQuery.$or.push(orLteQuery)\n } else if (op === '|in') {\n mongoQuery.$or = mongoQuery.$or || []\n let orInQuery = {}\n orInQuery[field] = {\n '$in': v\n }\n mongoQuery.$or.push(orInQuery)\n } else if (op === '|notIn') {\n mongoQuery.$or = mongoQuery.$or || []\n let orNinQuery = {}\n orNinQuery[field] = {\n '$nin': v\n }\n mongoQuery.$or.push(orNinQuery)\n }\n })\n })\n }\n\n return mongoQuery\n },\n\n /**\n * Map non-filtering params in a selection query to MongoDB query options.\n *\n * Handles the following:\n *\n * - limit\n * - skip/offset\n * - orderBy/sort\n *\n * @method MongoDBAdapter#getQueryOptions\n * @return {object}\n */\n getQueryOptions (mapper, query) {\n query = utils.plainCopy(query || {})\n query.orderBy = query.orderBy || query.sort\n query.skip = query.skip || query.offset\n\n let queryOptions = {}\n\n if (query.orderBy) {\n if (utils.isString(query.orderBy)) {\n query.orderBy = [\n [query.orderBy, 'asc']\n ]\n }\n for (var i = 0; i < query.orderBy.length; i++) {\n if (utils.isString(query.orderBy[i])) {\n query.orderBy[i] = [query.orderBy[i], 'asc']\n }\n }\n queryOptions.sort = query.orderBy\n }\n\n if (query.skip) {\n queryOptions.skip = +query.skip\n }\n\n if (query.limit) {\n queryOptions.limit = +query.limit\n }\n\n return queryOptions\n },\n\n /**\n * Turn an _id into an ObjectID if it isn't already an ObjectID.\n *\n * @method MongoDBAdapter#toObjectID\n * @return {*}\n */\n toObjectID (mapper, id) {\n if (id !== undefined && mapper.idAttribute === '_id' && typeof id === 'string' && ObjectID.isValid(id) && !(id instanceof ObjectID)) {\n return new ObjectID(id)\n }\n return id\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * @method MongoDBAdapter#makeBelongsToForeignKey\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return this.toObjectID(def.getRelation(), Adapter.prototype.makeBelongsToForeignKey.call(this, mapper, def, record))\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @method MongoDBAdapter#makeHasManyLocalKeys\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n const relatedMapper = def.getRelation()\n const localKeys = Adapter.prototype.makeHasManyLocalKeys.call(this, mapper, def, record)\n return localKeys.map((key) => this.toObjectID(relatedMapper, key))\n },\n\n /**\n * Not supported.\n *\n * @method MongoDBAdapter#updateMany\n */\n updateMany () {\n throw new Error('not supported!')\n }\n})\n\n/**\n * Details of the current version of the `js-data-mongodb` module.\n *\n * @example\n * import { version } from 'js-data-mongodb';\n * console.log(version.full);\n *\n * @name module:js-data-mongodb.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * {@link MongoDBAdapter} class.\n *\n * @example\n * import { MongoDBAdapter } from 'js-data-mongodb';\n * const adapter = new MongoDBAdapter();\n *\n * @name module:js-data-mongodb.MongoDBAdapter\n * @see MongoDBAdapter\n * @type {Constructor}\n */\n\n/**\n * Registered as `js-data-mongodb` in NPM.\n *\n * @example Install from NPM\n * npm i --save js-data-mongodb js-data mongodb bson\n *\n * @example Load via CommonJS\n * const MongoDBAdapter = require('js-data-mongodb').MongoDBAdapter;\n * const adapter = new MongoDBAdapter();\n *\n * @example Load via ES2015 Modules\n * import { MongoDBAdapter } from 'js-data-mongodb';\n * const adapter = new MongoDBAdapter();\n *\n * @module js-data-mongodb\n */\n\n/**\n * Create a subclass of this MongoDBAdapter:\n * @example MongoDBAdapter.extend\n * // Normally you would do: import { MongoDBAdapter } from 'js-data-mongodb';\n * const JSDataMongoDB = require('js-data-mongodb');\n * const { MongoDBAdapter } = JSDataMongoDB;\n * console.log('Using JSDataMongoDB v' + JSDataMongoDB.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomMongoDBAdapterClass extends MongoDBAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customMongoDBAdapter = new CustomMongoDBAdapterClass();\n * console.log(customMongoDBAdapter.foo());\n * console.log(CustomMongoDBAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherMongoDBAdapterClass = MongoDBAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * });\n * const otherMongoDBAdapter = new OtherMongoDBAdapterClass();\n * console.log(otherMongoDBAdapter.foo());\n * console.log(OtherMongoDBAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherMongoDBAdapterClass () {\n * MongoDBAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * MongoDBAdapter.extend({\n * constructor: AnotherMongoDBAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * });\n * const anotherMongoDBAdapter = new AnotherMongoDBAdapterClass();\n * console.log(anotherMongoDBAdapter.created_at);\n * console.log(anotherMongoDBAdapter.foo());\n * console.log(AnotherMongoDBAdapterClass.beep());\n *\n * @method MongoDBAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this MongoDBAdapter class.\n * @since 3.0.0\n */\n"],"names":["DEFAULTS","COUNT_OPTS_DEFAULTS","FIND_OPTS_DEFAULTS","FIND_ONE_OPTS_DEFAULTS","INSERT_OPTS_DEFAULTS","INSERT_MANY_OPTS_DEFAULTS","UPDATE_OPTS_DEFAULTS","REMOVE_OPTS_DEFAULTS","MongoDBAdapter","opts","classCallCheck","utils","isString","uri","fillIn","defineProperties","undefined","call","countOpts","findOpts","findOneOpts","insertOpts","insertManyOpts","updateOpts","removeOpts","client","Promise","resolve","reject","connect","mongoDriverOpts","err","db","_db","Adapter","extend","r","getOpt","_translateFieldObjectIDs","_translateId","isArray","forEach","_r","__id","_id","toString","isObject","_checkFields","field","_bsontype","mapper","query","_run","success","failure","collectionId","_getCollectionId","getQueryOptions","mongoQuery","getQuery","collection","count","props","handler","cursor","plainCopy","insertOne","insert","then","record","ops","_translateObjectIDs","connection","insertMany","records","id","idAttribute","toObjectID","deleteOne","remove","deleteMany","with","fields","_getFields","findOne","find","toArray","table","snakeCase","name","cb","getClient","_find","raw","result","Error","updateOne","$set","update","ids","_findAll","multi","queryOptions","map","updateMany","where","forOwn","config","keyword","reserved","indexOf","Object","keys","length","criteria","v","op","$ne","$gt","$gte","$lt","$lte","$in","$nin","$or","orEqQuery","push","orNeQuery","orGtQuery","orGteQuery","orLtQuery","orLteQuery","orInQuery","orNinQuery","orderBy","sort","skip","offset","i","limit","ObjectID","isValid","def","getRelation","prototype","makeBelongsToForeignKey","relatedMapper","localKeys","makeHasManyLocalKeys","key","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,WAAW;;;;;;;;eAQF,IARE;;;;;;;;sBAgBK,KAhBL;;;;;;;;;OAyBV,2BAzBU;;;;;;;;;mBAkCE;qBACE;;CAnCrB;;AAuCA,I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