From dd53d7988e8c0118154e692e555bdce4c781ca64 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Fri, 29 Apr 2016 21:02:55 -0700 Subject: [PATCH] 3.0.0-beta.2 --- .gitignore | 2 - dist/js-data-rethinkdb.js | 1013 +++++++++++++++++++++++++++++++++ dist/js-data-rethinkdb.js.map | 1 + 3 files changed, 1014 insertions(+), 2 deletions(-) create mode 100644 dist/js-data-rethinkdb.js create mode 100644 dist/js-data-rethinkdb.js.map diff --git a/.gitignore b/.gitignore index 37bd7a5..5080327 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -dist/*.js -dist/*.map # Logs logs *.log diff --git a/dist/js-data-rethinkdb.js b/dist/js-data-rethinkdb.js new file mode 100644 index 0000000..3d1c0b1 --- /dev/null +++ b/dist/js-data-rethinkdb.js @@ -0,0 +1,1013 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var jsData = require('js-data'); +var jsDataAdapter = require('js-data-adapter'); +var rethinkdbdash = _interopDefault(require('rethinkdbdash')); +var underscore = _interopDefault(require('mout/string/underscore')); + +var __super__ = jsDataAdapter.Adapter.prototype; + +var DEFAULTS = { + /** + * RethinkDB authorization key. + * + * @name RethinkDBAdapter#authKey + * @type {string} + */ + authKey: '', + + /** + * Buffer size for connection pool. + * + * @name RethinkDBAdapter#bufferSize + * @type {number} + * @default 10 + */ + bufferSize: 10, + + /** + * Default database. + * + * @name RethinkDBAdapter#db + * @type {string} + * @default "test" + */ + db: 'test', + + /** + * RethinkDB host. + * + * @name RethinkDBAdapter#host + * @type {string} + * @default "localhost" + */ + host: 'localhost', + + /** + * Minimum connections in pool. + * + * @name RethinkDBAdapter#min + * @type {number} + * @default 10 + */ + min: 10, + + /** + * Maximum connections in pool. + * + * @name RethinkDBAdapter#max + * @type {number} + * @default 50 + */ + max: 50, + + /** + * RethinkDB port. + * + * @name RethinkDBAdapter#port + * @type {number} + * @default 28015 + */ + port: 28015 +}; + +var INSERT_OPTS_DEFAULTS = {}; +var UPDATE_OPTS_DEFAULTS = {}; +var DELETE_OPTS_DEFAULTS = {}; +var RUN_OPTS_DEFAULTS = {}; + +var equal = function equal(r, row, field, value) { + return row(field).default(null).eq(value); +}; + +var notEqual = function notEqual(r, row, field, value) { + return row(field).default(null).ne(value); +}; + +/** + * Default predicate functions for the filtering operators. + * + * @name module:js-data-rethinkdb.OPERATORS + * @property {Function} == Equality operator. + * @property {Function} != Inequality operator. + * @property {Function} > "Greater than" operator. + * @property {Function} >= "Greater than or equal to" operator. + * @property {Function} < "Less than" operator. + * @property {Function} <= "Less than or equal to" operator. + * @property {Function} isectEmpty Operator to test that the intersection + * between two arrays is empty. + * @property {Function} isectNotEmpty Operator to test that the intersection + * between two arrays is NOT empty. + * @property {Function} in Operator to test whether a value is found in the + * provided array. + * @property {Function} notIn Operator to test whether a value is NOT found in + * the provided array. + * @property {Function} contains Operator to test whether an array contains the + * provided value. + * @property {Function} notContains Operator to test whether an array does NOT + * contain the provided value. + */ +var OPERATORS = { + '==': equal, + '===': equal, + '!=': notEqual, + '!==': notEqual, + '>': function _(r, row, field, value) { + return row(field).default(null).gt(value); + }, + '>=': function _(r, row, field, value) { + return row(field).default(null).ge(value); + }, + '<': function _(r, row, field, value) { + return row(field).default(null).lt(value); + }, + '<=': function _(r, row, field, value) { + return row(field).default(null).le(value); + }, + 'isectEmpty': function isectEmpty(r, row, field, value) { + return row(field).default([]).setIntersection(r.expr(value).default([])).count().eq(0); + }, + 'isectNotEmpty': function isectNotEmpty(r, row, field, value) { + return row(field).default([]).setIntersection(r.expr(value).default([])).count().ne(0); + }, + 'in': function _in(r, row, field, value) { + return r.expr(value).default(r.expr([])).contains(row(field).default(null)); + }, + 'notIn': function notIn(r, row, field, value) { + return r.expr(value).default(r.expr([])).contains(row(field).default(null)).not(); + }, + 'contains': function contains(r, row, field, value) { + return row(field).default([]).contains(value); + }, + 'notContains': function notContains(r, row, field, value) { + return row(field).default([]).contains(value).not(); + } +}; + +Object.freeze(OPERATORS); + +/** + * RethinkDBAdapter class. + * + * @example + * // Use Container instead of DataStore on the server + * import {Container} from 'js-data' + * import RethinkDBAdapter from 'js-data-rethinkdb' + * + * // Create a store to hold your Mappers + * const store = new Container() + * + * // Create an instance of RethinkDBAdapter with default settings + * const adapter = new RethinkDBAdapter() + * + * // Mappers in "store" will use the RethinkDB adapter by default + * store.registerAdapter('rethinkdb', adapter, { default: true }) + * + * // Create a Mapper that maps to a "user" table + * store.defineMapper('user') + * + * @class RethinkDBAdapter + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.authKey=""] See {@link RethinkDBAdapter#authKey}. + * @param {number} [opts.bufferSize=10] See {@link RethinkDBAdapter#bufferSize}. + * @param {string} [opts.db="test"] Default database. + * @param {boolean} [opts.debug=false] See {@link Adapter#debug}. + * @param {Object} [opts.deleteOpts={}] See {@link RethinkDBAdapter#deleteOpts}. + * @param {string} [opts.host="localhost"] See {@link RethinkDBAdapter#host}. + * @param {Object} [opts.insertOpts={}] See {@link RethinkDBAdapter#insertOpts}. + * @param {number} [opts.max=50] See {@link RethinkDBAdapter#max}. + * @param {number} [opts.min=10] See {@link RethinkDBAdapter#min}. + * @param {Object} [opts.operators] See {@link RethinkDBAdapter#operators}. + * @param {number} [opts.port=28015] See {@link RethinkDBAdapter#port}. + * @param {boolean} [opts.raw=false] See {@link Adapter#raw}. + * @param {Object} [opts.runOpts={}] See {@link RethinkDBAdapter#runOpts}. + * @param {Object} [opts.updateOpts={}] See {@link RethinkDBAdapter#updateOpts}. + */ +function RethinkDBAdapter(opts) { + var self = this; + jsData.utils.classCallCheck(self, RethinkDBAdapter); + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + jsDataAdapter.Adapter.call(self, opts); + + /** + * Default options to pass to r#insert. + * + * @name RethinkDBAdapter#insertOpts + * @type {Object} + * @default {} + */ + self.insertOpts || (self.insertOpts = {}); + jsData.utils.fillIn(self.insertOpts, INSERT_OPTS_DEFAULTS); + + /** + * Default options to pass to r#update. + * + * @name RethinkDBAdapter#updateOpts + * @type {Object} + * @default {} + */ + self.updateOpts || (self.updateOpts = {}); + jsData.utils.fillIn(self.updateOpts, UPDATE_OPTS_DEFAULTS); + + /** + * Default options to pass to r#delete. + * + * @name RethinkDBAdapter#deleteOpts + * @type {Object} + * @default {} + */ + self.deleteOpts || (self.deleteOpts = {}); + jsData.utils.fillIn(self.deleteOpts, DELETE_OPTS_DEFAULTS); + + /** + * Default options to pass to r#run. + * + * @name RethinkDBAdapter#runOpts + * @type {Object} + * @default {} + */ + self.runOpts || (self.runOpts = {}); + jsData.utils.fillIn(self.runOpts, RUN_OPTS_DEFAULTS); + + /** + * Override the default predicate functions for specified operators. + * + * @name RethinkDBAdapter#operators + * @type {Object} + * @default {} + */ + self.operators || (self.operators = {}); + + jsData.utils.fillIn(self.operators, OPERATORS); + + /** + * The rethinkdbdash instance used by this adapter. Use this directly when you + * need to write custom queries. + * + * @name RethinkDBAdapter#r + * @type {Object} + */ + self.r = rethinkdbdash(opts); + self.databases = {}; + self.tables = {}; + self.indices = {}; +} + +// Setup prototype inheritance from Adapter +RethinkDBAdapter.prototype = Object.create(jsDataAdapter.Adapter.prototype, { + constructor: { + value: RethinkDBAdapter, + enumerable: false, + writable: true, + configurable: true + } +}); + +Object.defineProperty(RethinkDBAdapter, '__super__', { + configurable: true, + value: jsDataAdapter.Adapter +}); + +/** + * Alternative to ES6 class syntax for extending `RethinkDBAdapter`. + * + * @example Using the ES2015 class syntax. + * class MyRethinkDBAdapter extends RethinkDBAdapter {...} + * const adapter = new MyRethinkDBAdapter() + * + * @example Using {@link RethinkDBAdapter.extend}. + * var instanceProps = {...} + * var classProps = {...} + * + * var MyRethinkDBAdapter = RethinkDBAdapter.extend(instanceProps, classProps) + * var adapter = new MyRethinkDBAdapter() + * + * @name RethinkDBAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the Subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the Subclass itself. + * @return {Constructor} Subclass of `RethinkDBAdapter`. + */ +RethinkDBAdapter.extend = jsData.utils.extend; + +jsData.utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, { + _handleErrors: function _handleErrors(cursor) { + if (cursor && cursor.errors > 0) { + if (cursor.first_error) { + throw new Error(cursor.first_error); + } + throw new Error('Unknown RethinkDB Error'); + } + }, + _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 [count, {}]; + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + var insertOpts = self.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); + var record = void 0; + if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) { + record = cursor.changes[0].new_val; + } + return [record, cursor]; + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + var insertOpts = self.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); + var records = []; + if (cursor && cursor.changes && cursor.changes.length && cursor.changes) { + records = cursor.changes.map(function (change) { + return change.new_val; + }); + } + return [records, cursor]; + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = 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 [undefined, cursor]; + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = 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 [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 [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 [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 [sum, {}]; + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + var updateOpts = self.getOpt('updateOpts', opts); + updateOpts.returnChanges = true; + + return self.selectTable(mapper, opts).get(id).update(jsDataAdapter.withoutRelations(mapper, props), updateOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { + var record = void 0; + self._handleErrors(cursor); + if (cursor && cursor.changes && cursor.changes.length && cursor.changes[0].new_val) { + record = cursor.changes[0].new_val; + } else { + throw new Error('Not Found'); + } + return [record, cursor]; + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + + var updateOpts = self.getOpt('updateOpts', opts); + updateOpts.returnChanges = true; + + return self.filterSequence(self.selectTable(mapper, opts), query).update(jsDataAdapter.withoutRelations(mapper, props), updateOpts).run(self.getOpt('runOpts', opts)).then(function (cursor) { + var records = []; + self._handleErrors(cursor); + if (cursor && cursor.changes && cursor.changes.length) { + records = cursor.changes.map(function (change) { + return change.new_val; + }); + } + return [records, cursor]; + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + + var insertOpts = self.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) { + records = []; + self._handleErrors(cursor); + if (cursor && cursor.changes && cursor.changes.length) { + records = cursor.changes.map(function (change) { + return change.new_val; + }); + } + return [records, cursor]; + }); + }, + selectDb: function selectDb(opts) { + return this.r.db(jsData.utils.isUndefined(opts.db) ? this.db : opts.db); + }, + selectTable: function selectTable(mapper, opts) { + return this.selectDb(opts).table(mapper.table || underscore(mapper.name)); + }, + + + /** + * Apply the specified selection query to the provided RQL sequence. + * + * @name RethinkDBAdapter#filterSequence + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + */ + filterSequence: function filterSequence(sequence, query, opts) { + var self = this; + var r = self.r; + + query = jsData.utils.plainCopy(query || {}); + opts || (opts = {}); + opts.operators || (opts.operators = {}); + query.where || (query.where = {}); + query.orderBy || (query.orderBy = query.sort); + query.orderBy || (query.orderBy = []); + query.skip || (query.skip = query.offset); + + // Transform non-keyword properties to "where" clause configuration + jsData.utils.forOwn(query, function (config, keyword) { + if (jsDataAdapter.reserved.indexOf(keyword) === -1) { + if (jsData.utils.isObject(config)) { + query.where[keyword] = config; + } else { + query.where[keyword] = { + '==': config + }; + } + delete query[keyword]; + } + }); + + var rql = sequence; + + // Filter + if (Object.keys(query.where).length !== 0) { + // Filter sequence using filter function + rql = rql.filter(function (row) { + var subQuery = void 0; + // Apply filter for each field + jsData.utils.forOwn(query.where, function (criteria, field) { + if (!jsData.utils.isObject(criteria)) { + criteria = { '==': criteria }; + } + // Apply filter for each operator + jsData.utils.forOwn(criteria, function (value, operator) { + var isOr = false; + if (operator && operator[0] === '|') { + operator = operator.substr(1); + isOr = true; + } + var predicateFn = self.getOperator(operator, opts); + if (predicateFn) { + var predicateResult = predicateFn(r, row, field, value); + if (isOr) { + subQuery = subQuery ? subQuery.or(predicateResult) : predicateResult; + } else { + subQuery = subQuery ? subQuery.and(predicateResult) : predicateResult; + } + } else { + throw new Error('Operator ' + operator + ' not supported!'); + } + }); + }); + return subQuery || true; + }); + } + + // Sort + if (query.orderBy) { + if (jsData.utils.isString(query.orderBy)) { + query.orderBy = [[query.orderBy, 'asc']]; + } + for (var i = 0; i < query.orderBy.length; i++) { + if (jsData.utils.isString(query.orderBy[i])) { + query.orderBy[i] = [query.orderBy[i], 'asc']; + } + rql = (query.orderBy[i][1] || '').toUpperCase() === 'DESC' ? rql.orderBy(r.desc(query.orderBy[i][0])) : rql.orderBy(query.orderBy[i][0]); + } + } + + // Offset + if (query.skip) { + rql = rql.skip(+query.skip); + } + + // Limit + if (query.limit) { + rql = rql.limit(+query.limit); + } + + return rql; + }, + waitForDb: function waitForDb(opts) { + var self = this; + opts || (opts = {}); + var db = jsData.utils.isUndefined(opts.db) ? self.db : opts.db; + if (!self.databases[db]) { + self.databases[db] = self.r.branch(self.r.dbList().contains(db), true, self.r.dbCreate(db)).run(); + } + return self.databases[db]; + }, + waitForTable: function waitForTable(mapper, options) { + var _this = this; + + var table = jsData.utils.isString(mapper) ? mapper : mapper.table || underscore(mapper.name); + options = options || {}; + var db = jsData.utils.isUndefined(options.db) ? this.db : options.db; + return this.waitForDb(options).then(function () { + _this.tables[db] = _this.tables[db] || {}; + if (!_this.tables[db][table]) { + _this.tables[db][table] = _this.r.branch(_this.r.db(db).tableList().contains(table), true, _this.r.db(db).tableCreate(table)).run(); + } + return _this.tables[db][table]; + }); + }, + waitForIndex: function waitForIndex(table, index, options) { + var _this2 = this; + + options = options || {}; + var db = jsData.utils.isUndefined(options.db) ? this.db : options.db; + return this.waitForDb(options).then(function () { + return _this2.waitForTable(table, options); + }).then(function () { + _this2.indices[db] = _this2.indices[db] || {}; + _this2.indices[db][table] = _this2.indices[db][table] || {}; + if (!_this2.tables[db][table][index]) { + _this2.tables[db][table][index] = _this2.r.branch(_this2.r.db(db).table(table).indexList().contains(index), true, _this2.r.db(db).table(table).indexCreate(index)).run().then(function () { + return _this2.r.db(db).table(table).indexWait(index).run(); + }); + } + return _this2.tables[db][table][index]; + }); + }, + + + /** + * Return the number of records that match the selection query. + * + * @name RethinkDBAdapter#count + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + opts || (opts = {}); + query || (query = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.count.call(self, mapper, query, opts); + }); + }, + + + /** + * Create a new record. + * + * @name RethinkDBAdapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.insertOpts] Options to pass to r#insert. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.create.call(self, mapper, props, opts); + }); + }, + + + /** + * Create multiple records in a single batch. + * + * @name RethinkDBAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.insertOpts] Options to pass to r#insert. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.createMany.call(self, mapper, props, opts); + }); + }, + + + /** + * Destroy the record with the given primary key. + * + * @name RethinkDBAdapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.deleteOpts] Options to pass to r#delete. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.destroy.call(self, mapper, id, opts); + }); + }, + + + /** + * Destroy the records that match the selection query. + * + * @name RethinkDBAdapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.deleteOpts] Options to pass to r#delete. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + opts || (opts = {}); + query || (query = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.destroyAll.call(self, mapper, query, opts); + }); + }, + + + /** + * Retrieve the record with the given primary key. + * + * @name RethinkDBAdapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + + var relationList = mapper.relationList || []; + var tasks = [self.waitForTable(mapper, opts)]; + + relationList.forEach(function (def) { + var relationName = def.relation; + var relationDef = def.getRelation(); + if (!opts.with || opts.with.indexOf(relationName) === -1) { + return; + } + if (def.foreignKey && def.type !== 'belongsTo') { + if (def.type === 'belongsTo') { + tasks.push(self.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts)); + } else { + tasks.push(self.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts)); + } + } + }); + return Promise.all(tasks).then(function () { + return __super__.find.call(self, mapper, id, opts); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name RethinkDBAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + query || (query = {}); + + var relationList = mapper.relationList || []; + var tasks = [self.waitForTable(mapper, opts)]; + + relationList.forEach(function (def) { + var relationName = def.relation; + var relationDef = def.getRelation(); + if (!opts.with || opts.with.indexOf(relationName) === -1) { + return; + } + if (def.foreignKey && def.type !== 'belongsTo') { + if (def.type === 'belongsTo') { + tasks.push(self.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts)); + } else { + tasks.push(self.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts)); + } + } + }); + return Promise.all(tasks).then(function () { + return __super__.findAll.call(self, mapper, query, opts); + }); + }, + + + /** + * Resolve the predicate function for the specified operator based on the + * given options and this adapter's settings. + * + * @name RethinkDBAdapter#getOperator + * @method + * @param {string} operator The name of the operator. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + * @return {*} The predicate function for the specified operator. + */ + getOperator: function getOperator(operator, opts) { + opts || (opts = {}); + opts.operators || (opts.operators = {}); + var ownOps = this.operators || {}; + return jsData.utils.isUndefined(opts.operators[operator]) ? ownOps[operator] : opts.operators[operator]; + }, + + + /** + * Return the sum of the specified field of records that match the selection + * query. + * + * @name RethinkDBAdapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + opts || (opts = {}); + query || (query = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.sum.call(self, mapper, field, query, opts); + }); + }, + + + /** + * Apply the given update to the record with the specified primary key. + * + * @name RethinkDBAdapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.updateOpts] Options to pass to r#update. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.update.call(self, mapper, id, props, opts); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * + * @name RethinkDBAdapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.operators] Override the default predicate functions + * for specified operators. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @param {Object} [opts.updateOpts] Options to pass to r#update. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.updateAll.call(self, mapper, props, query, opts); + }); + }, + + + /** + * Update the given records in a single batch. + * + * @name RethinkDBAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {Object} [opts.insertOpts] Options to pass to r#insert. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {Object} [opts.runOpts] Options to pass to r#run. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + + return self.waitForTable(mapper, opts).then(function () { + return __super__.updateMany.call(self, mapper, records, opts); + }); + } +}); + +/** + * Details of the current version of the `js-data-rethinkdb` module. + * + * @name module:js-data-rethinkdb.version + * @type {Object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +var version = { + beta: 2, + full: '3.0.0-beta.2', + major: 3, + minor: 0, + patch: 0 +}; + +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 new file mode 100644 index 0000000..542d187 --- /dev/null +++ b/dist/js-data-rethinkdb.js.map @@ -0,0 +1 @@ +{"version":3,"file":"js-data-rethinkdb.js","sources":["../src/index.js"],"sourcesContent":["import {utils} from 'js-data'\nimport {\n Adapter,\n reserved,\n withoutRelations\n} from 'js-data-adapter'\nimport rethinkdbdash from 'rethinkdbdash'\nimport underscore from 'mout/string/underscore'\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * RethinkDB authorization key.\n *\n * @name RethinkDBAdapter#authKey\n * @type {string}\n */\n authKey: '',\n\n /**\n * Buffer size for connection pool.\n *\n * @name RethinkDBAdapter#bufferSize\n * @type {number}\n * @default 10\n */\n bufferSize: 10,\n\n /**\n * Default database.\n *\n * @name RethinkDBAdapter#db\n * @type {string}\n * @default \"test\"\n */\n db: 'test',\n\n /**\n * RethinkDB host.\n *\n * @name RethinkDBAdapter#host\n * @type {string}\n * @default \"localhost\"\n */\n host: 'localhost',\n\n /**\n * Minimum connections in pool.\n *\n * @name RethinkDBAdapter#min\n * @type {number}\n * @default 10\n */\n min: 10,\n\n /**\n * Maximum connections in pool.\n *\n * @name RethinkDBAdapter#max\n * @type {number}\n * @default 50\n */\n max: 50,\n\n /**\n * RethinkDB port.\n *\n * @name RethinkDBAdapter#port\n * @type {number}\n * @default 28015\n */\n port: 28015\n}\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 {string} [opts.authKey=\"\"] See {@link RethinkDBAdapter#authKey}.\n * @param {number} [opts.bufferSize=10] See {@link RethinkDBAdapter#bufferSize}.\n * @param {string} [opts.db=\"test\"] Default database.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {Object} [opts.deleteOpts={}] See {@link RethinkDBAdapter#deleteOpts}.\n * @param {string} [opts.host=\"localhost\"] See {@link RethinkDBAdapter#host}.\n * @param {Object} [opts.insertOpts={}] See {@link RethinkDBAdapter#insertOpts}.\n * @param {number} [opts.max=50] See {@link RethinkDBAdapter#max}.\n * @param {number} [opts.min=10] See {@link RethinkDBAdapter#min}.\n * @param {Object} [opts.operators] See {@link RethinkDBAdapter#operators}.\n * @param {number} [opts.port=28015] See {@link RethinkDBAdapter#port}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {Object} [opts.runOpts={}] See {@link RethinkDBAdapter#runOpts}.\n * @param {Object} [opts.updateOpts={}] See {@link RethinkDBAdapter#updateOpts}.\n */\nexport function RethinkDBAdapter (opts) {\n const self = this\n utils.classCallCheck(self, RethinkDBAdapter)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n\n /**\n * Default options to pass to r#insert.\n *\n * @name RethinkDBAdapter#insertOpts\n * @type {Object}\n * @default {}\n */\n self.insertOpts || (self.insertOpts = {})\n utils.fillIn(self.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 self.updateOpts || (self.updateOpts = {})\n utils.fillIn(self.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 self.deleteOpts || (self.deleteOpts = {})\n utils.fillIn(self.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 self.runOpts || (self.runOpts = {})\n utils.fillIn(self.runOpts, RUN_OPTS_DEFAULTS)\n\n /**\n * Override the default predicate functions for specified operators.\n *\n * @name RethinkDBAdapter#operators\n * @type {Object}\n * @default {}\n */\n self.operators || (self.operators = {})\n\n utils.fillIn(self.operators, OPERATORS)\n\n /**\n * The rethinkdbdash instance used by this adapter. Use this directly when you\n * need to write custom queries.\n *\n * @name RethinkDBAdapter#r\n * @type {Object}\n */\n self.r = rethinkdbdash(opts)\n self.databases = {}\n self.tables = {}\n self.indices = {}\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 * @name RethinkDBAdapter.extend\n * @method\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(withoutRelations(mapper, 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(withoutRelations(mapper, 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.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 self = this\n const r = self.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, 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 rql = sequence\n\n // Filter\n if (Object.keys(query.where).length !== 0) {\n // Filter sequence using filter function\n rql = rql.filter(function (row) {\n let subQuery\n // Apply filter for each field\n utils.forOwn(query.where, function (criteria, field) {\n if (!utils.isObject(criteria)) {\n criteria = { '==': criteria }\n }\n // Apply filter for each operator\n utils.forOwn(criteria, function (value, operator) {\n let isOr = false\n if (operator && operator[0] === '|') {\n operator = operator.substr(1)\n isOr = true\n }\n let predicateFn = self.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 const self = this\n opts || (opts = {})\n const db = utils.isUndefined(opts.db) ? self.db : opts.db\n if (!self.databases[db]) {\n self.databases[db] = self.r.branch(\n self.r.dbList().contains(db),\n true,\n self.r.dbCreate(db)\n ).run()\n }\n return self.databases[db]\n },\n\n waitForTable (mapper, options) {\n const table = utils.isString(mapper) ? mapper : (mapper.table || underscore(mapper.name))\n options = options || {}\n let db = utils.isUndefined(options.db) ? this.db : options.db\n return this.waitForDb(options).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, options) {\n options = options || {}\n let db = utils.isUndefined(options.db) ? this.db : options.db\n return this.waitForDb(options).then(() => this.waitForTable(table, options)).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 const self = this\n opts || (opts = {})\n query || (query = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.count.call(self, mapper, query, opts)\n })\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 const self = this\n props || (props = {})\n opts || (opts = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.create.call(self, mapper, props, opts)\n })\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 const self = this\n props || (props = {})\n opts || (opts = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.createMany.call(self, mapper, props, opts)\n })\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 const self = this\n opts || (opts = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.destroy.call(self, mapper, id, opts)\n })\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 const self = this\n opts || (opts = {})\n query || (query = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.destroyAll.call(self, mapper, query, opts)\n })\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 const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const relationList = mapper.relationList || []\n let tasks = [self.waitForTable(mapper, opts)]\n\n relationList.forEach(function (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(self.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts))\n } else {\n tasks.push(self.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts))\n }\n }\n })\n return Promise.all(tasks).then(function () {\n return __super__.find.call(self, mapper, id, opts)\n })\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 const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n query || (query = {})\n\n const relationList = mapper.relationList || []\n let tasks = [self.waitForTable(mapper, opts)]\n\n relationList.forEach(function (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(self.waitForIndex(mapper.table || underscore(mapper.name), def.foreignKey, opts))\n } else {\n tasks.push(self.waitForIndex(relationDef.table || underscore(relationDef.name), def.foreignKey, opts))\n }\n }\n })\n return Promise.all(tasks).then(function () {\n return __super__.findAll.call(self, mapper, query, opts)\n })\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 const self = this\n opts || (opts = {})\n query || (query = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.sum.call(self, mapper, field, query, opts)\n })\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 const self = this\n props || (props = {})\n opts || (opts = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.update.call(self, mapper, id, props, opts)\n })\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 const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.updateAll.call(self, mapper, props, query, opts)\n })\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 const self = this\n records || (records = [])\n opts || (opts = {})\n\n return self.waitForTable(mapper, opts).then(function () {\n return __super__.updateMany.call(self, mapper, records, opts)\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-rethinkdb` module.\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\nexport default RethinkDBAdapter\n"],"names":["Adapter","utils","withoutRelations","reserved"],"mappings":";;;;;;;;;AASA,IAAM,YAAYA,sBAAQ,SAA1B;;AAEA,IAAM,WAAW;;;;;;;WAON,EAPM;;;;;;;;;cAgBH,EAhBG;;;;;;;;;MAyBX,MAzBW;;;;;;;;;QAkCT,WAlCS;;;;;;;;;OA2CV,EA3CU;;;;;;;;;OAoDV,EApDU;;;;;;;;;QA6DT;CA7DR;;AAgEA,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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