From 6a93a1f9515136454563c04bba0b1f2db1cb4aa3 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Tue, 10 May 2016 21:01:12 -0700 Subject: [PATCH] 3.0.0-beta.5 --- dist/js-data-rethinkdb.js | 191 ++++++++++++++++++++-------------- dist/js-data-rethinkdb.js.map | 2 +- 2 files changed, 114 insertions(+), 79 deletions(-) diff --git a/dist/js-data-rethinkdb.js b/dist/js-data-rethinkdb.js index 2433860..1b0d50a 100644 --- a/dist/js-data-rethinkdb.js +++ b/dist/js-data-rethinkdb.js @@ -322,24 +322,24 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { } }, _count: function _count(mapper, query, opts) { - var self = this; opts || (opts = {}); query || (query = {}); - return self.filterSequence(self.selectTable(mapper, opts), query).count().run(self.getOpt('runOpts', opts)).then(function (count) { + return this.filterSequence(this.selectTable(mapper, opts), query).count().run(this.getOpt('runOpts', opts)).then(function (count) { return [count, {}]; }); }, _create: function _create(mapper, props, opts) { - var self = this; + var _this = this; + props || (props = {}); opts || (opts = {}); - var insertOpts = self.getOpt('insertOpts', opts); + var insertOpts = this.getOpt('insertOpts', opts); insertOpts.returnChanges = true; - return self.selectTable(mapper, opts).insert(props, insertOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { - self._handleErrors(cursor); + return this.selectTable(mapper, opts).insert(props, insertOpts).run(this.getOpt('runOpts', opts)).then(function (cursor) { + _this._handleErrors(cursor); var record = void 0; if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) { record = cursor.changes[0].new_val; @@ -348,15 +348,16 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { }); }, _createMany: function _createMany(mapper, props, opts) { - var self = this; + var _this2 = this; + props || (props = {}); opts || (opts = {}); - var insertOpts = self.getOpt('insertOpts', opts); + var insertOpts = this.getOpt('insertOpts', opts); insertOpts.returnChanges = true; - return self.selectTable(mapper, opts).insert(props, insertOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { - self._handleErrors(cursor); + return this.selectTable(mapper, opts).insert(props, insertOpts).run(this.getOpt('runOpts', opts)).then(function (cursor) { + _this2._handleErrors(cursor); var records = []; if (cursor && cursor.changes && cursor.changes.length && cursor.changes) { records = cursor.changes.map(function (change) { @@ -367,64 +368,64 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { }); }, _destroy: function _destroy(mapper, id, opts) { - var self = this; + var _this3 = this; + opts || (opts = {}); - return self.selectTable(mapper, opts).get(id).delete(self.getOpt('deleteOpts', opts)).run(self.getOpt('runOpts', opts)).then(function (cursor) { - self._handleErrors(cursor); + return this.selectTable(mapper, opts).get(id).delete(this.getOpt('deleteOpts', opts)).run(this.getOpt('runOpts', opts)).then(function (cursor) { + _this3._handleErrors(cursor); return [undefined, cursor]; }); }, _destroyAll: function _destroyAll(mapper, query, opts) { - var self = this; + var _this4 = this; + query || (query = {}); opts || (opts = {}); - return self.filterSequence(self.selectTable(mapper, opts), query).delete(self.getOpt('deleteOpts', opts)).run(self.getOpt('runOpts', opts)).then(function (cursor) { - self._handleErrors(cursor); + return this.filterSequence(this.selectTable(mapper, opts), query).delete(this.getOpt('deleteOpts', opts)).run(this.getOpt('runOpts', opts)).then(function (cursor) { + _this4._handleErrors(cursor); return [undefined, cursor]; }); }, _find: function _find(mapper, id, opts) { - var self = this; opts || (opts = {}); - return self.selectTable(mapper, opts).get(id).run(self.getOpt('runOpts', opts)).then(function (record) { + return this.selectTable(mapper, opts).get(id).run(this.getOpt('runOpts', opts)).then(function (record) { return [record, {}]; }); }, _findAll: function _findAll(mapper, query, opts) { - var self = this; opts || (opts = {}); query || (query = {}); - return self.filterSequence(self.selectTable(mapper, opts), query).run(self.getOpt('runOpts', opts)).then(function (records) { + return this.filterSequence(this.selectTable(mapper, opts), query).run(this.getOpt('runOpts', opts)).then(function (records) { return [records, {}]; }); }, _sum: function _sum(mapper, field, query, opts) { - var self = this; if (!jsData.utils.isString(field)) { throw new Error('field must be a string!'); } opts || (opts = {}); query || (query = {}); - return self.filterSequence(self.selectTable(mapper, opts), query).sum(field).run(self.getOpt('runOpts', opts)).then(function (sum) { + return this.filterSequence(this.selectTable(mapper, opts), query).sum(field).run(this.getOpt('runOpts', opts)).then(function (sum) { return [sum, {}]; }); }, _update: function _update(mapper, id, props, opts) { - var self = this; + var _this5 = this; + props || (props = {}); opts || (opts = {}); - var updateOpts = self.getOpt('updateOpts', opts); + var updateOpts = this.getOpt('updateOpts', opts); updateOpts.returnChanges = true; - return self.selectTable(mapper, opts).get(id).update(props, updateOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { + return this.selectTable(mapper, opts).get(id).update(props, updateOpts).run(this.getOpt('runOpts', opts)).then(function (cursor) { var record = void 0; - self._handleErrors(cursor); + _this5._handleErrors(cursor); if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) { record = cursor.changes[0].new_val; } else { @@ -434,17 +435,18 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { }); }, _updateAll: function _updateAll(mapper, props, query, opts) { - var self = this; + var _this6 = this; + props || (props = {}); query || (query = {}); opts || (opts = {}); - var updateOpts = self.getOpt('updateOpts', opts); + var updateOpts = this.getOpt('updateOpts', opts); updateOpts.returnChanges = true; - return self.filterSequence(self.selectTable(mapper, opts), query).update(props, updateOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { + return this.filterSequence(this.selectTable(mapper, opts), query).update(props, updateOpts).run(this.getOpt('runOpts', opts)).then(function (cursor) { var records = []; - self._handleErrors(cursor); + _this6._handleErrors(cursor); if (cursor && cursor.changes && cursor.changes.length) { records = cursor.changes.map(function (change) { return change.new_val; @@ -454,17 +456,18 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { }); }, _updateMany: function _updateMany(mapper, records, opts) { - var self = this; + var _this7 = this; + records || (records = []); opts || (opts = {}); - var insertOpts = self.getOpt('insertOpts', opts); + var insertOpts = this.getOpt('insertOpts', opts); insertOpts.returnChanges = true; insertOpts.conflict = 'update'; - return self.selectTable(mapper, opts).insert(records, insertOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { + return this.selectTable(mapper, opts).insert(records, insertOpts).run(this.getOpt('runOpts', opts)).then(function (cursor) { records = []; - self._handleErrors(cursor); + _this7._handleErrors(cursor); if (cursor && cursor.changes && cursor.changes.length) { records = cursor.changes.map(function (change) { return change.new_val; @@ -499,7 +502,7 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * for specified operators. */ filterSequence: function filterSequence(sequence, query, opts) { - var _this = this; + var _this8 = this; var r = this.r; @@ -544,7 +547,7 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { operator = operator.substr(1); isOr = true; } - var predicateFn = _this.getOperator(operator, opts); + var predicateFn = _this8.getOperator(operator, opts); if (predicateFn) { var predicateResult = predicateFn(r, row, field, value); if (isOr) { @@ -595,35 +598,35 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { return this.databases[db]; }, waitForTable: function waitForTable(mapper, opts) { - var _this2 = this; + var _this9 = this; opts || (opts = {}); var table = jsData.utils.isString(mapper) ? mapper : mapper.table || underscore(mapper.name); var db = jsData.utils.isUndefined(opts.db) ? this.rOpts.db : opts.db; return this.waitForDb(opts).then(function () { - _this2.tables[db] = _this2.tables[db] || {}; - if (!_this2.tables[db][table]) { - _this2.tables[db][table] = _this2.r.branch(_this2.r.db(db).tableList().contains(table), true, _this2.r.db(db).tableCreate(table)).run(); + _this9.tables[db] = _this9.tables[db] || {}; + if (!_this9.tables[db][table]) { + _this9.tables[db][table] = _this9.r.branch(_this9.r.db(db).tableList().contains(table), true, _this9.r.db(db).tableCreate(table)).run(); } - return _this2.tables[db][table]; + return _this9.tables[db][table]; }); }, waitForIndex: function waitForIndex(table, index, opts) { - var _this3 = this; + var _this10 = this; opts || (opts = {}); var db = jsData.utils.isUndefined(opts.db) ? this.rOpts.db : opts.db; return this.waitForDb(opts).then(function () { - return _this3.waitForTable(table, opts); + return _this10.waitForTable(table, opts); }).then(function () { - _this3.indices[db] = _this3.indices[db] || {}; - _this3.indices[db][table] = _this3.indices[db][table] || {}; - if (!_this3.tables[db][table][index]) { - _this3.tables[db][table][index] = _this3.r.branch(_this3.r.db(db).table(table).indexList().contains(index), true, _this3.r.db(db).table(table).indexCreate(index)).run().then(function () { - return _this3.r.db(db).table(table).indexWait(index).run(); + _this10.indices[db] = _this10.indices[db] || {}; + _this10.indices[db][table] = _this10.indices[db][table] || {}; + if (!_this10.tables[db][table][index]) { + _this10.tables[db][table][index] = _this10.r.branch(_this10.r.db(db).table(table).indexList().contains(index), true, _this10.r.db(db).table(table).indexCreate(index)).run().then(function () { + return _this10.r.db(db).table(table).indexWait(index).run(); }); } - return _this3.tables[db][table][index]; + return _this10.tables[db][table][index]; }); }, @@ -650,13 +653,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ count: function count(mapper, query, opts) { - var _this4 = this; + var _this11 = this; opts || (opts = {}); query || (query = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.count.call(_this4, mapper, query, opts); + return __super__.count.call(_this11, mapper, query, opts); }); }, @@ -676,13 +679,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ create: function create(mapper, props, opts) { - var _this5 = this; + var _this12 = this; props || (props = {}); opts || (opts = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.create.call(_this5, mapper, props, opts); + return __super__.create.call(_this12, mapper, props, opts); }); }, @@ -702,13 +705,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ createMany: function createMany(mapper, props, opts) { - var _this6 = this; + var _this13 = this; props || (props = {}); opts || (opts = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.createMany.call(_this6, mapper, props, opts); + return __super__.createMany.call(_this13, mapper, props, opts); }); }, @@ -728,12 +731,12 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ destroy: function destroy(mapper, id, opts) { - var _this7 = this; + var _this14 = this; opts || (opts = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.destroy.call(_this7, mapper, id, opts); + return __super__.destroy.call(_this14, mapper, id, opts); }); }, @@ -761,13 +764,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ destroyAll: function destroyAll(mapper, query, opts) { - var _this8 = this; + var _this15 = this; opts || (opts = {}); query || (query = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.destroyAll.call(_this8, mapper, query, opts); + return __super__.destroyAll.call(_this15, mapper, query, opts); }); }, @@ -787,7 +790,7 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ find: function find(mapper, id, opts) { - var _this9 = this; + var _this16 = this; opts || (opts = {}); opts.with || (opts.with = []); @@ -803,14 +806,14 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { } if (def.foreignKey && def.type !== 'belongsTo') { if (def.type === 'belongsTo') { - tasks.push(_this9.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts)); + tasks.push(_this16.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts)); } else { - tasks.push(_this9.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts)); + tasks.push(_this16.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts)); } } }); return Promise.all(tasks).then(function () { - return __super__.find.call(_this9, mapper, id, opts); + return __super__.find.call(_this16, mapper, id, opts); }); }, @@ -838,7 +841,7 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ findAll: function findAll(mapper, query, opts) { - var _this10 = this; + var _this17 = this; opts || (opts = {}); opts.with || (opts.with = []); @@ -855,14 +858,14 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { } if (def.foreignKey && def.type !== 'belongsTo') { if (def.type === 'belongsTo') { - tasks.push(_this10.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts)); + tasks.push(_this17.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts)); } else { - tasks.push(_this10.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts)); + tasks.push(_this17.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts)); } } }); return Promise.all(tasks).then(function () { - return __super__.findAll.call(_this10, mapper, query, opts); + return __super__.findAll.call(_this17, mapper, query, opts); }); }, @@ -911,13 +914,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ sum: function sum(mapper, field, query, opts) { - var _this11 = this; + var _this18 = this; opts || (opts = {}); query || (query = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.sum.call(_this11, mapper, field, query, opts); + return __super__.sum.call(_this18, mapper, field, query, opts); }); }, @@ -938,13 +941,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ update: function update(mapper, id, props, opts) { - var _this12 = this; + var _this19 = this; props || (props = {}); opts || (opts = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.update.call(_this12, mapper, id, props, opts); + return __super__.update.call(_this19, mapper, id, props, opts); }); }, @@ -973,14 +976,14 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ updateAll: function updateAll(mapper, props, query, opts) { - var _this13 = this; + var _this20 = this; props || (props = {}); query || (query = {}); opts || (opts = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.updateAll.call(_this13, mapper, props, query, opts); + return __super__.updateAll.call(_this20, mapper, props, query, opts); }); }, @@ -1000,13 +1003,13 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * @return {Promise} */ updateMany: function updateMany(mapper, records, opts) { - var _this14 = this; + var _this21 = this; records || (records = []); opts || (opts = {}); return this.waitForTable(mapper, opts).then(function () { - return __super__.updateMany.call(_this14, mapper, records, opts); + return __super__.updateMany.call(_this21, mapper, records, opts); }); } }); @@ -1034,15 +1037,47 @@ jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { * otherwise `false` if the current version is not beta. */ var version = { - beta: 4, - full: '3.0.0-beta.4', + beta: 5, + full: '3.0.0-beta.5', major: 3, minor: 0, patch: 0 }; +/** + * {@link RethinkDBAdapter} class. + * + * @example ES2015 modules import + * import {RethinkDBAdapter} from 'js-data-rethinkdb' + * const adapter = new RethinkDBAdapter() + * + * @example CommonJS import + * var RethinkDBAdapter = require('js-data-rethinkdb').RethinkDBAdapter + * var adapter = new RethinkDBAdapter() + * + * @name module:js-data-rethinkdb.RethinkDBAdapter + * @see RethinkDBAdapter + * @type {Constructor} + */ + +/** + * Registered as `js-data-rethinkdb` in NPM. + * + * @example Install from NPM + * npm i --save js-data-rethinkdb@beta js-data@beta rethinkdbdash + * + * @example ES2015 modules import + * import {RethinkDBAdapter} from 'js-data-rethinkdb' + * const adapter = new RethinkDBAdapter() + * + * @example CommonJS import + * var RethinkDBAdapter = require('js-data-rethinkdb').RethinkDBAdapter + * var adapter = new RethinkDBAdapter() + * + * @module js-data-rethinkdb + */ + exports.OPERATORS = OPERATORS; exports.RethinkDBAdapter = RethinkDBAdapter; exports.version = version; -exports['default'] = RethinkDBAdapter; //# sourceMappingURL=js-data-rethinkdb.js.map \ No newline at end of file diff --git a/dist/js-data-rethinkdb.js.map b/dist/js-data-rethinkdb.js.map index ce5c0c1..db632ad 100644 --- a/dist/js-data-rethinkdb.js.map +++ b/dist/js-data-rethinkdb.js.map @@ -1 +1 @@ -{"version":3,"file":"js-data-rethinkdb.js","sources":["../src/index.js"],"sourcesContent":["import {utils} from 'js-data'\nimport {\n Adapter,\n reserved\n} from 'js-data-adapter'\nimport rethinkdbdash from 'rethinkdbdash'\nimport underscore from 'mout/string/underscore'\n\nconst __super__ = Adapter.prototype\n\nconst R_OPTS_DEFAULTS = {\n db: 'test'\n}\nconst INSERT_OPTS_DEFAULTS = {}\nconst UPDATE_OPTS_DEFAULTS = {}\nconst DELETE_OPTS_DEFAULTS = {}\nconst RUN_OPTS_DEFAULTS = {}\n\nconst equal = function (r, row, field, value) {\n return row(field).default(null).eq(value)\n}\n\nconst notEqual = function (r, row, field, value) {\n return row(field).default(null).ne(value)\n}\n\n/**\n * Default predicate functions for the filtering operators.\n *\n * @name module:js-data-rethinkdb.OPERATORS\n * @property {Function} == Equality operator.\n * @property {Function} != Inequality operator.\n * @property {Function} > \"Greater than\" operator.\n * @property {Function} >= \"Greater than or equal to\" operator.\n * @property {Function} < \"Less than\" operator.\n * @property {Function} <= \"Less than or equal to\" operator.\n * @property {Function} isectEmpty Operator to test that the intersection\n * between two arrays is empty.\n * @property {Function} isectNotEmpty Operator to test that the intersection\n * between two arrays is NOT empty.\n * @property {Function} in Operator to test whether a value is found in the\n * provided array.\n * @property {Function} notIn Operator to test whether a value is NOT found in\n * the provided array.\n * @property {Function} contains Operator to test whether an array contains the\n * provided value.\n * @property {Function} notContains Operator to test whether an array does NOT\n * contain the provided value.\n */\nexport const OPERATORS = {\n '==': equal,\n '===': equal,\n '!=': notEqual,\n '!==': notEqual,\n '>': function (r, row, field, value) {\n return row(field).default(null).gt(value)\n },\n '>=': function (r, row, field, value) {\n return row(field).default(null).ge(value)\n },\n '<': function (r, row, field, value) {\n return row(field).default(null).lt(value)\n },\n '<=': function (r, row, field, value) {\n return row(field).default(null).le(value)\n },\n 'isectEmpty': function (r, row, field, value) {\n return row(field).default([]).setIntersection(r.expr(value).default([])).count().eq(0)\n },\n 'isectNotEmpty': function (r, row, field, value) {\n return row(field).default([]).setIntersection(r.expr(value).default([])).count().ne(0)\n },\n 'in': function (r, row, field, value) {\n return r.expr(value).default(r.expr([])).contains(row(field).default(null))\n },\n 'notIn': function (r, row, field, value) {\n return r.expr(value).default(r.expr([])).contains(row(field).default(null)).not()\n },\n 'contains': function (r, row, field, value) {\n return row(field).default([]).contains(value)\n },\n 'notContains': function (r, row, field, value) {\n return row(field).default([]).contains(value).not()\n }\n}\n\nObject.freeze(OPERATORS)\n\n/**\n * RethinkDBAdapter class.\n *\n * @example\n * // Use Container instead of DataStore on the server\n * import {Container} from 'js-data'\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n *\n * // Create a store to hold your Mappers\n * const store = new Container()\n *\n * // Create an instance of RethinkDBAdapter with default settings\n * const adapter = new RethinkDBAdapter()\n *\n * // Mappers in \"store\" will use the RethinkDB adapter by default\n * store.registerAdapter('rethinkdb', adapter, { default: true })\n *\n * // Create a Mapper that maps to a \"user\" table\n * store.defineMapper('user')\n *\n * @class RethinkDBAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {Object} [opts.deleteOpts={}] See {@link RethinkDBAdapter#deleteOpts}.\n * @param {Object} [opts.insertOpts={}] See {@link RethinkDBAdapter#insertOpts}.\n * @param {Object} [opts.operators={@link module:js-data-rethinkdb.OPERATORS}] See {@link RethinkDBAdapter#operators}.\n * @param {Object} [opts.r] See {@link RethinkDBAdapter#r}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {Object} [opts.rOpts={}] See {@link RethinkDBAdapter#rOpts}.\n * @param {Object} [opts.runOpts={}] See {@link RethinkDBAdapter#runOpts}.\n * @param {Object} [opts.updateOpts={}] See {@link RethinkDBAdapter#updateOpts}.\n */\nexport function RethinkDBAdapter (opts) {\n utils.classCallCheck(this, RethinkDBAdapter)\n opts || (opts = {})\n\n // Setup non-enumerable properties\n Object.defineProperties(this, {\n /**\n * The rethinkdbdash instance used by this adapter. Use this directly when\n * you need to write custom queries.\n *\n * @example Use default instance.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n * adapter.r.dbDrop('foo').then(...)\n *\n * @example Configure default instance.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * user: 'myUser',\n * password: 'myPassword'\n * }\n * })\n * adapter.r.dbDrop('foo').then(...)\n *\n * @example Provide a custom instance.\n * import rethinkdbdash from 'rethinkdbdash'\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const r = rethinkdbdash()\n * const adapter = new RethinkDBAdapter({\n * r: r\n * })\n * adapter.r.dbDrop('foo').then(...)\n *\n * @name RethinkDBAdapter#r\n * @type {Object}\n */\n r: {\n writable: true,\n value: undefined\n },\n databases: {\n value: {}\n },\n indices: {\n value: {}\n },\n tables: {\n value: {}\n }\n })\n\n Adapter.call(this, opts)\n\n /**\n * Default options to pass to r#insert.\n *\n * @name RethinkDBAdapter#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 r#update.\n *\n * @name RethinkDBAdapter#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 r#delete.\n *\n * @name RethinkDBAdapter#deleteOpts\n * @type {Object}\n * @default {}\n */\n this.deleteOpts || (this.deleteOpts = {})\n utils.fillIn(this.deleteOpts, DELETE_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to r#run.\n *\n * @name RethinkDBAdapter#runOpts\n * @type {Object}\n * @default {}\n */\n this.runOpts || (this.runOpts = {})\n utils.fillIn(this.runOpts, RUN_OPTS_DEFAULTS)\n\n /**\n * Override the default predicate functions for the specified operators.\n *\n * @name RethinkDBAdapter#operators\n * @type {Object}\n * @default {}\n */\n this.operators || (this.operators = {})\n utils.fillIn(this.operators, OPERATORS)\n\n /**\n * Options to pass to a new `rethinkdbdash` instance, if one was not provided\n * at {@link RethinkDBAdapter#r}. See the [rethinkdbdash README][readme] for\n * instance options.\n *\n * [readme]: https://github.com/neumino/rethinkdbdash#importing-the-driver\n *\n * @example Connect to localhost:8080, and let the driver find other instances.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * discovery: true\n * }\n * })\n *\n * @example Connect to and only to localhost:8080.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @example Do not create a connection pool.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * pool: false\n * }\n * })\n *\n * @example Connect to a cluster seeding from `192.168.0.100`, `192.168.0.101`, `192.168.0.102`.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * servers: [\n * { host: '192.168.0.100', port: 28015 },\n * { host: '192.168.0.101', port: 28015 },\n * { host: '192.168.0.102', port: 28015 }\n * ]\n * }\n * })\n *\n * @name RethinkDBAdapter#rOpts\n * @see https://github.com/neumino/rethinkdbdash#importing-the-driver\n * @type {Object}\n */\n this.rOpts || (this.rOpts = {})\n utils.fillIn(this.rOpts, R_OPTS_DEFAULTS)\n\n this.r || (this.r = rethinkdbdash(this.rOpts))\n}\n\n// Setup prototype inheritance from Adapter\nRethinkDBAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: RethinkDBAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(RethinkDBAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `RethinkDBAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyRethinkDBAdapter extends RethinkDBAdapter {...}\n * const adapter = new MyRethinkDBAdapter()\n *\n * @example Using {@link RethinkDBAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyRethinkDBAdapter = RethinkDBAdapter.extend(instanceProps, classProps)\n * var adapter = new MyRethinkDBAdapter()\n *\n * @method RethinkDBAdapter.extend\n * @static\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Constructor} Subclass of `RethinkDBAdapter`.\n */\nRethinkDBAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, {\n _handleErrors (cursor) {\n if (cursor && cursor.errors > 0) {\n if (cursor.first_error) {\n throw new Error(cursor.first_error)\n }\n throw new Error('Unknown RethinkDB Error')\n }\n },\n\n _count (mapper, query, opts) {\n const self = this\n opts || (opts = {})\n query || (query = {})\n\n return self.filterSequence(self.selectTable(mapper, opts), query)\n .count()\n .run(self.getOpt('runOpts', opts)).then(function (count) {\n return [count, {}]\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n const insertOpts = self.getOpt('insertOpts', opts)\n insertOpts.returnChanges = true\n\n return self.selectTable(mapper, opts)\n .insert(props, insertOpts)\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n self._handleErrors(cursor)\n let record\n if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) {\n record = cursor.changes[0].new_val\n }\n return [record, cursor]\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n const insertOpts = self.getOpt('insertOpts', opts)\n insertOpts.returnChanges = true\n\n return self.selectTable(mapper, opts)\n .insert(props, insertOpts)\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n self._handleErrors(cursor)\n let records = []\n if (cursor && cursor.changes && cursor.changes.length && cursor.changes) {\n records = cursor.changes.map(function (change) {\n return change.new_val\n })\n }\n return [records, cursor]\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return self.selectTable(mapper, opts)\n .get(id)\n .delete(self.getOpt('deleteOpts', opts))\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n self._handleErrors(cursor)\n return [undefined, cursor]\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return self\n .filterSequence(self.selectTable(mapper, opts), query)\n .delete(self.getOpt('deleteOpts', opts))\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n self._handleErrors(cursor)\n return [undefined, cursor]\n })\n },\n\n _find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return self.selectTable(mapper, opts)\n .get(id)\n .run(self.getOpt('runOpts', opts)).then(function (record) {\n return [record, {}]\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n opts || (opts = {})\n query || (query = {})\n\n return self.filterSequence(self.selectTable(mapper, opts), query)\n .run(self.getOpt('runOpts', opts)).then(function (records) {\n return [records, {}]\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts || (opts = {})\n query || (query = {})\n\n return self.filterSequence(self.selectTable(mapper, opts), query)\n .sum(field)\n .run(self.getOpt('runOpts', opts)).then(function (sum) {\n return [sum, {}]\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n const updateOpts = self.getOpt('updateOpts', opts)\n updateOpts.returnChanges = true\n\n return self.selectTable(mapper, opts)\n .get(id)\n .update(props, updateOpts)\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n let record\n self._handleErrors(cursor)\n if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) {\n record = cursor.changes[0].new_val\n } else {\n throw new Error('Not Found')\n }\n return [record, cursor]\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n const updateOpts = self.getOpt('updateOpts', opts)\n updateOpts.returnChanges = true\n\n return self.filterSequence(self.selectTable(mapper, opts), query)\n .update(props, updateOpts)\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n let records = []\n self._handleErrors(cursor)\n if (cursor && cursor.changes && cursor.changes.length) {\n records = cursor.changes.map(function (change) { return change.new_val })\n }\n return [records, cursor]\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n const insertOpts = self.getOpt('insertOpts', opts)\n insertOpts.returnChanges = true\n insertOpts.conflict = 'update'\n\n return self.selectTable(mapper, opts)\n .insert(records, insertOpts)\n .run(self.getOpt('runOpts', opts)).then(function (cursor) {\n records = []\n self._handleErrors(cursor)\n if (cursor && cursor.changes && cursor.changes.length) {\n records = cursor.changes.map(function (change) { return change.new_val })\n }\n return [records, cursor]\n })\n },\n\n selectDb (opts) {\n return this.r.db(utils.isUndefined(opts.db) ? this.rOpts.db : opts.db)\n },\n\n selectTable (mapper, opts) {\n return this.selectDb(opts).table(mapper.table || underscore(mapper.name))\n },\n\n /**\n * Apply the specified selection query to the provided RQL sequence.\n *\n * @name RethinkDBAdapter#filterSequence\n * @method\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n */\n filterSequence (sequence, query, opts) {\n const r = this.r\n\n query = utils.plainCopy(query || {})\n opts || (opts = {})\n opts.operators || (opts.operators = {})\n query.where || (query.where = {})\n query.orderBy || (query.orderBy = query.sort)\n query.orderBy || (query.orderBy = [])\n query.skip || (query.skip = query.offset)\n\n // Transform non-keyword properties to \"where\" clause configuration\n utils.forOwn(query, (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 rql = sequence\n\n // Filter\n if (Object.keys(query.where).length !== 0) {\n // Filter sequence using filter function\n rql = rql.filter((row) => {\n let subQuery\n // Apply filter for each field\n utils.forOwn(query.where, (criteria, field) => {\n if (!utils.isObject(criteria)) {\n criteria = { '==': criteria }\n }\n // Apply filter for each operator\n utils.forOwn(criteria, (value, operator) => {\n let isOr = false\n if (operator && operator[0] === '|') {\n operator = operator.substr(1)\n isOr = true\n }\n let predicateFn = this.getOperator(operator, opts)\n if (predicateFn) {\n const predicateResult = predicateFn(r, row, field, value)\n if (isOr) {\n subQuery = subQuery ? subQuery.or(predicateResult) : predicateResult\n } else {\n subQuery = subQuery ? subQuery.and(predicateResult) : predicateResult\n }\n } else {\n throw new Error(`Operator ${operator} not supported!`)\n }\n })\n })\n return subQuery || true\n })\n }\n\n // Sort\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 rql = (query.orderBy[i][1] || '').toUpperCase() === 'DESC' ? rql.orderBy(r.desc(query.orderBy[i][0])) : rql.orderBy(query.orderBy[i][0])\n }\n }\n\n // Offset\n if (query.skip) {\n rql = rql.skip(+query.skip)\n }\n\n // Limit\n if (query.limit) {\n rql = rql.limit(+query.limit)\n }\n\n return rql\n },\n\n waitForDb (opts) {\n opts || (opts = {})\n const db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db\n if (!this.databases[db]) {\n this.databases[db] = this.r.branch(\n this.r.dbList().contains(db),\n true,\n this.r.dbCreate(db)\n ).run()\n }\n return this.databases[db]\n },\n\n waitForTable (mapper, opts) {\n opts || (opts = {})\n const table = utils.isString(mapper) ? mapper : (mapper.table || underscore(mapper.name))\n let db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db\n return this.waitForDb(opts).then(() => {\n this.tables[db] = this.tables[db] || {}\n if (!this.tables[db][table]) {\n this.tables[db][table] = this.r.branch(this.r.db(db).tableList().contains(table), true, this.r.db(db).tableCreate(table)).run()\n }\n return this.tables[db][table]\n })\n },\n\n waitForIndex (table, index, opts) {\n opts || (opts = {})\n let db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db\n return this.waitForDb(opts).then(() => this.waitForTable(table, opts)).then(() => {\n this.indices[db] = this.indices[db] || {}\n this.indices[db][table] = this.indices[db][table] || {}\n if (!this.tables[db][table][index]) {\n this.tables[db][table][index] = this.r.branch(this.r.db(db).table(table).indexList().contains(index), true, this.r.db(db).table(table).indexCreate(index)).run().then(() => {\n return this.r.db(db).table(table).indexWait(index).run()\n })\n }\n return this.tables[db][table][index]\n })\n },\n\n /**\n * Return the number of records that match the selection query.\n *\n * @name RethinkDBAdapter#count\n * @method\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.count.call(this, mapper, query, opts))\n },\n\n /**\n * Create a new record.\n *\n * @name RethinkDBAdapter#create\n * @method\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 r#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.create.call(this, mapper, props, opts))\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name RethinkDBAdapter#createMany\n * @method\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.insertOpts] Options to pass to r#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.createMany.call(this, mapper, props, opts))\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name RethinkDBAdapter#destroy\n * @method\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 {Object} [opts.deleteOpts] Options to pass to r#delete.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.destroy.call(this, mapper, id, opts))\n },\n\n /**\n * Destroy the records that match the selection query.\n *\n * @name RethinkDBAdapter#destroyAll\n * @method\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 {Object} [opts.deleteOpts] Options to pass to r#delete.\n * @param {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.destroyAll.call(this, mapper, query, opts))\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name RethinkDBAdapter#find\n * @method\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 {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const relationList = mapper.relationList || []\n let tasks = [this.waitForTable(mapper, opts)]\n\n relationList.forEach((def) => {\n const relationName = def.relation\n const relationDef = def.getRelation()\n if (!opts.with || opts.with.indexOf(relationName) === -1) {\n return\n }\n if (def.foreignKey && def.type !== 'belongsTo') {\n if (def.type === 'belongsTo') {\n tasks.push(this.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts))\n } else {\n tasks.push(this.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts))\n }\n }\n })\n return Promise.all(tasks).then(() => __super__.find.call(this, mapper, id, opts))\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name RethinkDBAdapter#findAll\n * @method\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n query || (query = {})\n\n const relationList = mapper.relationList || []\n let tasks = [this.waitForTable(mapper, opts)]\n\n relationList.forEach((def) => {\n const relationName = def.relation\n const relationDef = def.getRelation()\n if (!opts.with || opts.with.indexOf(relationName) === -1) {\n return\n }\n if (def.foreignKey && def.type !== 'belongsTo') {\n if (def.type === 'belongsTo') {\n tasks.push(this.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts))\n } else {\n tasks.push(this.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts))\n }\n }\n })\n return Promise.all(tasks).then(() => __super__.findAll.call(this, mapper, query, opts))\n },\n\n /**\n * Resolve the predicate function for the specified operator based on the\n * given options and this adapter's settings.\n *\n * @name RethinkDBAdapter#getOperator\n * @method\n * @param {string} operator The name of the operator.\n * @param {Object} [opts] Configuration options.\n * @param {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @return {*} The predicate function for the specified operator.\n */\n getOperator (operator, opts) {\n opts || (opts = {})\n opts.operators || (opts.operators = {})\n let ownOps = this.operators || {}\n return utils.isUndefined(opts.operators[operator]) ? ownOps[operator] : opts.operators[operator]\n },\n\n /**\n * Return the sum of the specified field of records that match the selection\n * query.\n *\n * @name RethinkDBAdapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field The field to sum.\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.sum.call(this, mapper, field, query, opts))\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n *\n * @name RethinkDBAdapter#update\n * @method\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 {Object} [opts.updateOpts] Options to pass to r#update.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.update.call(this, mapper, id, props, opts))\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n *\n * @name RethinkDBAdapter#updateAll\n * @method\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} [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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @param {Object} [opts.updateOpts] Options to pass to r#update.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.updateAll.call(this, mapper, props, query, opts))\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name RethinkDBAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {Object} [opts.insertOpts] Options to pass to r#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.updateMany.call(this, mapper, records, opts))\n }\n})\n\n/**\n * Details of the current version of the `js-data-rethinkdb` module.\n *\n * @example ES2015 modules import\n * import {version} from 'js-data-rethinkdb'\n * console.log(version.full)\n *\n * @example CommonJS import\n * var version = require('js-data-rethinkdb').version\n * console.log(version.full)\n *\n * @name module:js-data-rethinkdb.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 RethinkDBAdapter} class.\n *\n * @example ES2015 modules import\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @example CommonJS import\n * var RethinkDBAdapter = require('js-data-rethinkdb').RethinkDBAdapter\n * var adapter = new RethinkDBAdapter()\n *\n * @name module:js-data-rethinkdb.RethinkDBAdapter\n * @see RethinkDBAdapter\n * @type {Constructor}\n */\n\n/**\n * {@link RethinkDBAdapter} class.\n *\n * @example ES2015 modules \"default\" import\n * import RethinkDBAdapter from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @name module:js-data-rethinkdb.default\n * @see RethinkDBAdapter\n * @type {Constructor}\n */\n\n/**\n * Registered as `js-data-rethinkdb` in NPM.\n *\n * @example Install from NPM\n * npm i --save js-data-rethinkdb@beta js-data@beta rethinkdbdash\n *\n * @example ES2015 modules import\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @example CommonJS import\n * var RethinkDBAdapter = require('js-data-rethinkdb').RethinkDBAdapter\n * var adapter = new RethinkDBAdapter()\n *\n * @module js-data-rethinkdb\n */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AxC,EAA+C,IAA/C,CAAN;KADD,CAAP;GAlnBqD;;;;;;;;;;;;;;;;;;;;;;;;;;WAAA,qBA6oB5C,MA7oB4C,EA6oBpC,KA7oBoC,EA6oB7B,KA7oB6B,EA6oBtB,IA7oBsB,EA6oBhB;;;cAC3B,QAAQ,EAAlB;cACU,QAAQ,EAAlB;aACS,OAAO,EAAhB;;WAEO,KAAK,YAAL,CAAkB,MAAlB,EAA0B,IAA1B,EACJ,IADI,CACC;aAAM,UAAU,SAAV,CAAoB,IAApB,UAA+B,MAA/B,EAAuC,KAAvC,EAA8C,KAA9C,EAAqD,IAArD,CAAN;KADD,CAAP;GAlpBqD;;;;;;;;;;;;;;;;;YAAA,sBAoqB3C,MApqB2C,EAoqBnC,OApqBmC,EAoqB1B,IApqB0B,EAoqBpB;;;gBACrB,UAAU,EAAtB;aACS,OAAO,EAAhB;;WAEO,KAAK,YAAL,CAAkB,MAAlB,EAA0B,IAA1B,EACJ,IADI,CACC;aAAM,UAAU,UAAV,CAAqB,IAArB,UAAgC,MAAhC,EAAwC,OAAxC,EAAiD,IAAjD,CAAN;KADD,CAAP;;CAxqBJ;;;;;;;;;;;;;;;;;;;;;;;;AAmsBA,AAAO,IAAM,UAAU,gBAAhB;;;;;"} \ No newline at end of file +{"version":3,"file":"js-data-rethinkdb.js","sources":["../src/index.js"],"sourcesContent":["import {utils} from 'js-data'\nimport {\n Adapter,\n reserved\n} from 'js-data-adapter'\nimport rethinkdbdash from 'rethinkdbdash'\nimport underscore from 'mout/string/underscore'\n\nconst __super__ = Adapter.prototype\n\nconst R_OPTS_DEFAULTS = {\n db: 'test'\n}\nconst INSERT_OPTS_DEFAULTS = {}\nconst UPDATE_OPTS_DEFAULTS = {}\nconst DELETE_OPTS_DEFAULTS = {}\nconst RUN_OPTS_DEFAULTS = {}\n\nconst equal = function (r, row, field, value) {\n return row(field).default(null).eq(value)\n}\n\nconst notEqual = function (r, row, field, value) {\n return row(field).default(null).ne(value)\n}\n\n/**\n * Default predicate functions for the filtering operators.\n *\n * @name module:js-data-rethinkdb.OPERATORS\n * @property {Function} == Equality operator.\n * @property {Function} != Inequality operator.\n * @property {Function} > \"Greater than\" operator.\n * @property {Function} >= \"Greater than or equal to\" operator.\n * @property {Function} < \"Less than\" operator.\n * @property {Function} <= \"Less than or equal to\" operator.\n * @property {Function} isectEmpty Operator to test that the intersection\n * between two arrays is empty.\n * @property {Function} isectNotEmpty Operator to test that the intersection\n * between two arrays is NOT empty.\n * @property {Function} in Operator to test whether a value is found in the\n * provided array.\n * @property {Function} notIn Operator to test whether a value is NOT found in\n * the provided array.\n * @property {Function} contains Operator to test whether an array contains the\n * provided value.\n * @property {Function} notContains Operator to test whether an array does NOT\n * contain the provided value.\n */\nexport const OPERATORS = {\n '==': equal,\n '===': equal,\n '!=': notEqual,\n '!==': notEqual,\n '>': function (r, row, field, value) {\n return row(field).default(null).gt(value)\n },\n '>=': function (r, row, field, value) {\n return row(field).default(null).ge(value)\n },\n '<': function (r, row, field, value) {\n return row(field).default(null).lt(value)\n },\n '<=': function (r, row, field, value) {\n return row(field).default(null).le(value)\n },\n 'isectEmpty': function (r, row, field, value) {\n return row(field).default([]).setIntersection(r.expr(value).default([])).count().eq(0)\n },\n 'isectNotEmpty': function (r, row, field, value) {\n return row(field).default([]).setIntersection(r.expr(value).default([])).count().ne(0)\n },\n 'in': function (r, row, field, value) {\n return r.expr(value).default(r.expr([])).contains(row(field).default(null))\n },\n 'notIn': function (r, row, field, value) {\n return r.expr(value).default(r.expr([])).contains(row(field).default(null)).not()\n },\n 'contains': function (r, row, field, value) {\n return row(field).default([]).contains(value)\n },\n 'notContains': function (r, row, field, value) {\n return row(field).default([]).contains(value).not()\n }\n}\n\nObject.freeze(OPERATORS)\n\n/**\n * RethinkDBAdapter class.\n *\n * @example\n * // Use Container instead of DataStore on the server\n * import {Container} from 'js-data'\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n *\n * // Create a store to hold your Mappers\n * const store = new Container()\n *\n * // Create an instance of RethinkDBAdapter with default settings\n * const adapter = new RethinkDBAdapter()\n *\n * // Mappers in \"store\" will use the RethinkDB adapter by default\n * store.registerAdapter('rethinkdb', adapter, { default: true })\n *\n * // Create a Mapper that maps to a \"user\" table\n * store.defineMapper('user')\n *\n * @class RethinkDBAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {Object} [opts.deleteOpts={}] See {@link RethinkDBAdapter#deleteOpts}.\n * @param {Object} [opts.insertOpts={}] See {@link RethinkDBAdapter#insertOpts}.\n * @param {Object} [opts.operators={@link module:js-data-rethinkdb.OPERATORS}] See {@link RethinkDBAdapter#operators}.\n * @param {Object} [opts.r] See {@link RethinkDBAdapter#r}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {Object} [opts.rOpts={}] See {@link RethinkDBAdapter#rOpts}.\n * @param {Object} [opts.runOpts={}] See {@link RethinkDBAdapter#runOpts}.\n * @param {Object} [opts.updateOpts={}] See {@link RethinkDBAdapter#updateOpts}.\n */\nexport function RethinkDBAdapter (opts) {\n utils.classCallCheck(this, RethinkDBAdapter)\n opts || (opts = {})\n\n // Setup non-enumerable properties\n Object.defineProperties(this, {\n /**\n * The rethinkdbdash instance used by this adapter. Use this directly when\n * you need to write custom queries.\n *\n * @example Use default instance.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n * adapter.r.dbDrop('foo').then(...)\n *\n * @example Configure default instance.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * user: 'myUser',\n * password: 'myPassword'\n * }\n * })\n * adapter.r.dbDrop('foo').then(...)\n *\n * @example Provide a custom instance.\n * import rethinkdbdash from 'rethinkdbdash'\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const r = rethinkdbdash()\n * const adapter = new RethinkDBAdapter({\n * r: r\n * })\n * adapter.r.dbDrop('foo').then(...)\n *\n * @name RethinkDBAdapter#r\n * @type {Object}\n */\n r: {\n writable: true,\n value: undefined\n },\n databases: {\n value: {}\n },\n indices: {\n value: {}\n },\n tables: {\n value: {}\n }\n })\n\n Adapter.call(this, opts)\n\n /**\n * Default options to pass to r#insert.\n *\n * @name RethinkDBAdapter#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 r#update.\n *\n * @name RethinkDBAdapter#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 r#delete.\n *\n * @name RethinkDBAdapter#deleteOpts\n * @type {Object}\n * @default {}\n */\n this.deleteOpts || (this.deleteOpts = {})\n utils.fillIn(this.deleteOpts, DELETE_OPTS_DEFAULTS)\n\n /**\n * Default options to pass to r#run.\n *\n * @name RethinkDBAdapter#runOpts\n * @type {Object}\n * @default {}\n */\n this.runOpts || (this.runOpts = {})\n utils.fillIn(this.runOpts, RUN_OPTS_DEFAULTS)\n\n /**\n * Override the default predicate functions for the specified operators.\n *\n * @name RethinkDBAdapter#operators\n * @type {Object}\n * @default {}\n */\n this.operators || (this.operators = {})\n utils.fillIn(this.operators, OPERATORS)\n\n /**\n * Options to pass to a new `rethinkdbdash` instance, if one was not provided\n * at {@link RethinkDBAdapter#r}. See the [rethinkdbdash README][readme] for\n * instance options.\n *\n * [readme]: https://github.com/neumino/rethinkdbdash#importing-the-driver\n *\n * @example Connect to localhost:8080, and let the driver find other instances.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * discovery: true\n * }\n * })\n *\n * @example Connect to and only to localhost:8080.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @example Do not create a connection pool.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * pool: false\n * }\n * })\n *\n * @example Connect to a cluster seeding from `192.168.0.100`, `192.168.0.101`, `192.168.0.102`.\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter({\n * rOpts: {\n * servers: [\n * { host: '192.168.0.100', port: 28015 },\n * { host: '192.168.0.101', port: 28015 },\n * { host: '192.168.0.102', port: 28015 }\n * ]\n * }\n * })\n *\n * @name RethinkDBAdapter#rOpts\n * @see https://github.com/neumino/rethinkdbdash#importing-the-driver\n * @type {Object}\n */\n this.rOpts || (this.rOpts = {})\n utils.fillIn(this.rOpts, R_OPTS_DEFAULTS)\n\n this.r || (this.r = rethinkdbdash(this.rOpts))\n}\n\n// Setup prototype inheritance from Adapter\nRethinkDBAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: RethinkDBAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(RethinkDBAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `RethinkDBAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyRethinkDBAdapter extends RethinkDBAdapter {...}\n * const adapter = new MyRethinkDBAdapter()\n *\n * @example Using {@link RethinkDBAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyRethinkDBAdapter = RethinkDBAdapter.extend(instanceProps, classProps)\n * var adapter = new MyRethinkDBAdapter()\n *\n * @method RethinkDBAdapter.extend\n * @static\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Constructor} Subclass of `RethinkDBAdapter`.\n */\nRethinkDBAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, {\n _handleErrors (cursor) {\n if (cursor && cursor.errors > 0) {\n if (cursor.first_error) {\n throw new Error(cursor.first_error)\n }\n throw new Error('Unknown RethinkDB Error')\n }\n },\n\n _count (mapper, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.filterSequence(this.selectTable(mapper, opts), query)\n .count()\n .run(this.getOpt('runOpts', opts))\n .then((count) => [count, {}])\n },\n\n _create (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n const insertOpts = this.getOpt('insertOpts', opts)\n insertOpts.returnChanges = true\n\n return this.selectTable(mapper, opts)\n .insert(props, insertOpts)\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n this._handleErrors(cursor)\n let record\n if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) {\n record = cursor.changes[0].new_val\n }\n return [record, cursor]\n })\n },\n\n _createMany (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n const insertOpts = this.getOpt('insertOpts', opts)\n insertOpts.returnChanges = true\n\n return this.selectTable(mapper, opts)\n .insert(props, insertOpts)\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n this._handleErrors(cursor)\n let records = []\n if (cursor && cursor.changes && cursor.changes.length && cursor.changes) {\n records = cursor.changes.map((change) => change.new_val)\n }\n return [records, cursor]\n })\n },\n\n _destroy (mapper, id, opts) {\n opts || (opts = {})\n\n return this.selectTable(mapper, opts)\n .get(id)\n .delete(this.getOpt('deleteOpts', opts))\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n this._handleErrors(cursor)\n return [undefined, cursor]\n })\n },\n\n _destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n\n return this.filterSequence(this.selectTable(mapper, opts), query)\n .delete(this.getOpt('deleteOpts', opts))\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n this._handleErrors(cursor)\n return [undefined, cursor]\n })\n },\n\n _find (mapper, id, opts) {\n opts || (opts = {})\n\n return this.selectTable(mapper, opts)\n .get(id)\n .run(this.getOpt('runOpts', opts))\n .then((record) => [record, {}])\n },\n\n _findAll (mapper, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.filterSequence(this.selectTable(mapper, opts), query)\n .run(this.getOpt('runOpts', opts))\n .then((records) => [records, {}])\n },\n\n _sum (mapper, field, query, opts) {\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts || (opts = {})\n query || (query = {})\n\n return this.filterSequence(this.selectTable(mapper, opts), query)\n .sum(field)\n .run(this.getOpt('runOpts', opts))\n .then((sum) => [sum, {}])\n },\n\n _update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n const updateOpts = this.getOpt('updateOpts', opts)\n updateOpts.returnChanges = true\n\n return this.selectTable(mapper, opts)\n .get(id)\n .update(props, updateOpts)\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n let record\n this._handleErrors(cursor)\n if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) {\n record = cursor.changes[0].new_val\n } else {\n throw new Error('Not Found')\n }\n return [record, cursor]\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n const updateOpts = this.getOpt('updateOpts', opts)\n updateOpts.returnChanges = true\n\n return this.filterSequence(this.selectTable(mapper, opts), query)\n .update(props, updateOpts)\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n let records = []\n this._handleErrors(cursor)\n if (cursor && cursor.changes && cursor.changes.length) {\n records = cursor.changes.map((change) => change.new_val)\n }\n return [records, cursor]\n })\n },\n\n _updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n\n const insertOpts = this.getOpt('insertOpts', opts)\n insertOpts.returnChanges = true\n insertOpts.conflict = 'update'\n\n return this.selectTable(mapper, opts)\n .insert(records, insertOpts)\n .run(this.getOpt('runOpts', opts))\n .then((cursor) => {\n records = []\n this._handleErrors(cursor)\n if (cursor && cursor.changes && cursor.changes.length) {\n records = cursor.changes.map((change) => change.new_val)\n }\n return [records, cursor]\n })\n },\n\n selectDb (opts) {\n return this.r.db(utils.isUndefined(opts.db) ? this.rOpts.db : opts.db)\n },\n\n selectTable (mapper, opts) {\n return this.selectDb(opts).table(mapper.table || underscore(mapper.name))\n },\n\n /**\n * Apply the specified selection query to the provided RQL sequence.\n *\n * @name RethinkDBAdapter#filterSequence\n * @method\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n */\n filterSequence (sequence, query, opts) {\n const r = this.r\n\n query = utils.plainCopy(query || {})\n opts || (opts = {})\n opts.operators || (opts.operators = {})\n query.where || (query.where = {})\n query.orderBy || (query.orderBy = query.sort)\n query.orderBy || (query.orderBy = [])\n query.skip || (query.skip = query.offset)\n\n // Transform non-keyword properties to \"where\" clause configuration\n utils.forOwn(query, (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 rql = sequence\n\n // Filter\n if (Object.keys(query.where).length !== 0) {\n // Filter sequence using filter function\n rql = rql.filter((row) => {\n let subQuery\n // Apply filter for each field\n utils.forOwn(query.where, (criteria, field) => {\n if (!utils.isObject(criteria)) {\n criteria = { '==': criteria }\n }\n // Apply filter for each operator\n utils.forOwn(criteria, (value, operator) => {\n let isOr = false\n if (operator && operator[0] === '|') {\n operator = operator.substr(1)\n isOr = true\n }\n let predicateFn = this.getOperator(operator, opts)\n if (predicateFn) {\n const predicateResult = predicateFn(r, row, field, value)\n if (isOr) {\n subQuery = subQuery ? subQuery.or(predicateResult) : predicateResult\n } else {\n subQuery = subQuery ? subQuery.and(predicateResult) : predicateResult\n }\n } else {\n throw new Error(`Operator ${operator} not supported!`)\n }\n })\n })\n return subQuery || true\n })\n }\n\n // Sort\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 rql = (query.orderBy[i][1] || '').toUpperCase() === 'DESC' ? rql.orderBy(r.desc(query.orderBy[i][0])) : rql.orderBy(query.orderBy[i][0])\n }\n }\n\n // Offset\n if (query.skip) {\n rql = rql.skip(+query.skip)\n }\n\n // Limit\n if (query.limit) {\n rql = rql.limit(+query.limit)\n }\n\n return rql\n },\n\n waitForDb (opts) {\n opts || (opts = {})\n const db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db\n if (!this.databases[db]) {\n this.databases[db] = this.r.branch(\n this.r.dbList().contains(db),\n true,\n this.r.dbCreate(db)\n ).run()\n }\n return this.databases[db]\n },\n\n waitForTable (mapper, opts) {\n opts || (opts = {})\n const table = utils.isString(mapper) ? mapper : (mapper.table || underscore(mapper.name))\n let db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db\n return this.waitForDb(opts).then(() => {\n this.tables[db] = this.tables[db] || {}\n if (!this.tables[db][table]) {\n this.tables[db][table] = this.r.branch(this.r.db(db).tableList().contains(table), true, this.r.db(db).tableCreate(table)).run()\n }\n return this.tables[db][table]\n })\n },\n\n waitForIndex (table, index, opts) {\n opts || (opts = {})\n let db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db\n return this.waitForDb(opts).then(() => this.waitForTable(table, opts)).then(() => {\n this.indices[db] = this.indices[db] || {}\n this.indices[db][table] = this.indices[db][table] || {}\n if (!this.tables[db][table][index]) {\n this.tables[db][table][index] = this.r.branch(this.r.db(db).table(table).indexList().contains(index), true, this.r.db(db).table(table).indexCreate(index)).run().then(() => {\n return this.r.db(db).table(table).indexWait(index).run()\n })\n }\n return this.tables[db][table][index]\n })\n },\n\n /**\n * Return the number of records that match the selection query.\n *\n * @name RethinkDBAdapter#count\n * @method\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.count.call(this, mapper, query, opts))\n },\n\n /**\n * Create a new record.\n *\n * @name RethinkDBAdapter#create\n * @method\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 r#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.create.call(this, mapper, props, opts))\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name RethinkDBAdapter#createMany\n * @method\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.insertOpts] Options to pass to r#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.createMany.call(this, mapper, props, opts))\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name RethinkDBAdapter#destroy\n * @method\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 {Object} [opts.deleteOpts] Options to pass to r#delete.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.destroy.call(this, mapper, id, opts))\n },\n\n /**\n * Destroy the records that match the selection query.\n *\n * @name RethinkDBAdapter#destroyAll\n * @method\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 {Object} [opts.deleteOpts] Options to pass to r#delete.\n * @param {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.destroyAll.call(this, mapper, query, opts))\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name RethinkDBAdapter#find\n * @method\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 {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const relationList = mapper.relationList || []\n let tasks = [this.waitForTable(mapper, opts)]\n\n relationList.forEach((def) => {\n const relationName = def.relation\n const relationDef = def.getRelation()\n if (!opts.with || opts.with.indexOf(relationName) === -1) {\n return\n }\n if (def.foreignKey && def.type !== 'belongsTo') {\n if (def.type === 'belongsTo') {\n tasks.push(this.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts))\n } else {\n tasks.push(this.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts))\n }\n }\n })\n return Promise.all(tasks).then(() => __super__.find.call(this, mapper, id, opts))\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name RethinkDBAdapter#findAll\n * @method\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n query || (query = {})\n\n const relationList = mapper.relationList || []\n let tasks = [this.waitForTable(mapper, opts)]\n\n relationList.forEach((def) => {\n const relationName = def.relation\n const relationDef = def.getRelation()\n if (!opts.with || opts.with.indexOf(relationName) === -1) {\n return\n }\n if (def.foreignKey && def.type !== 'belongsTo') {\n if (def.type === 'belongsTo') {\n tasks.push(this.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts))\n } else {\n tasks.push(this.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts))\n }\n }\n })\n return Promise.all(tasks).then(() => __super__.findAll.call(this, mapper, query, opts))\n },\n\n /**\n * Resolve the predicate function for the specified operator based on the\n * given options and this adapter's settings.\n *\n * @name RethinkDBAdapter#getOperator\n * @method\n * @param {string} operator The name of the operator.\n * @param {Object} [opts] Configuration options.\n * @param {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @return {*} The predicate function for the specified operator.\n */\n getOperator (operator, opts) {\n opts || (opts = {})\n opts.operators || (opts.operators = {})\n let ownOps = this.operators || {}\n return utils.isUndefined(opts.operators[operator]) ? ownOps[operator] : opts.operators[operator]\n },\n\n /**\n * Return the sum of the specified field of records that match the selection\n * query.\n *\n * @name RethinkDBAdapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field The field to sum.\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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n opts || (opts = {})\n query || (query = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.sum.call(this, mapper, field, query, opts))\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n *\n * @name RethinkDBAdapter#update\n * @method\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 {Object} [opts.updateOpts] Options to pass to r#update.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.update.call(this, mapper, id, props, opts))\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n *\n * @name RethinkDBAdapter#updateAll\n * @method\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} [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 {Object} [opts.operators] Override the default predicate functions\n * for specified operators.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @param {Object} [opts.updateOpts] Options to pass to r#update.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.updateAll.call(this, mapper, props, query, opts))\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name RethinkDBAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {Object} [opts.insertOpts] Options to pass to r#insert.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {Object} [opts.runOpts] Options to pass to r#run.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n\n return this.waitForTable(mapper, opts)\n .then(() => __super__.updateMany.call(this, mapper, records, opts))\n }\n})\n\n/**\n * Details of the current version of the `js-data-rethinkdb` module.\n *\n * @example ES2015 modules import\n * import {version} from 'js-data-rethinkdb'\n * console.log(version.full)\n *\n * @example CommonJS import\n * var version = require('js-data-rethinkdb').version\n * console.log(version.full)\n *\n * @name module:js-data-rethinkdb.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 RethinkDBAdapter} class.\n *\n * @example ES2015 modules import\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @example CommonJS import\n * var RethinkDBAdapter = require('js-data-rethinkdb').RethinkDBAdapter\n * var adapter = new RethinkDBAdapter()\n *\n * @name module:js-data-rethinkdb.RethinkDBAdapter\n * @see RethinkDBAdapter\n * @type {Constructor}\n */\n\n/**\n * Registered as `js-data-rethinkdb` in NPM.\n *\n * @example Install from NPM\n * npm i --save js-data-rethinkdb@beta js-data@beta rethinkdbdash\n *\n * @example ES2015 modules import\n * import {RethinkDBAdapter} from 'js-data-rethinkdb'\n * const adapter = new RethinkDBAdapter()\n *\n * @example CommonJS import\n * var RethinkDBAdapter = require('js-data-rethinkdb').RethinkDBAdapter\n * var adapter = new RethinkDBAdapter()\n *\n * @module js-data-rethinkdb\n */\n"],"names":["Adapter","utils","reserved"],"mappings":";;;;;;;;;AAQA,IAAM,YAAYA,sBAAQ,SAA1B;;AAEA,IAAM,kBAAkB;MAClB;CADN;AAGA,IAAM,uBAAuB,EAA7B;AACA,IAAM,uBAAuB,EAA7B;AACA,IAAM,uBAAuB,EAA7B;AACA,IAAM,oBAAoB,EAA1B;;AAEA,IAAM,QAAQ,SAAR,KAAQ,CAAU,CAAV,EAAa,GAAb,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC;SACrC,IAAI,KAAJ,EAAW,OAAX,CAAmB,IAAnB,EAAyB,EAAzB,CAA4B,KAA5B,CAAP;CADF;;AAIA,IAAM,WAAW,SAAX,QAAW,CAAU,CAAV,EAAa,GAAb,EAAkB,KAAlB,EAAyB,KAAzB,EAAgC;SACxC,IA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