From 183cecce0da89f950eaaa76760c2ba3f9f8a7b9c Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sun, 17 Apr 2016 19:33:43 -0700 Subject: [PATCH] 3.0.0-beta.1 --- AUTHORS | 6 +- CHANGELOG.md | 4 +- CONTRIBUTORS | 41 +++--- dist/js-data.es2015.js | 253 ++++++++++++++++++++---------------- dist/js-data.es2015.js.map | 2 +- dist/js-data.js | 254 +++++++++++++++++++++---------------- dist/js-data.js.map | 2 +- dist/js-data.min.js | 6 +- dist/js-data.min.map | 2 +- package.json | 6 +- 10 files changed, 326 insertions(+), 250 deletions(-) diff --git a/AUTHORS b/AUTHORS index 208673dc..5353ceae 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,10 +1,10 @@ # This is the official list of js-data project authors. # -# This file is controlled by scripts/authors.js -# # Names are formatted as: -# # commits Name or Organization +# Name or Organization [email address] +# # The email address is not required for organizations. +# antoinebrault David Madner InternalFX diff --git a/CHANGELOG.md b/CHANGELOG.md index fa7c69af..e4a768d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ -##### 3.0.0-alpha.30 - xx April 2016 +##### 3.0.0-beta.1 - 17 April 2016 + +Official beta release. ###### Other - Switched back to Mocha from Ava diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 82e9f71d..7e656aca 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,23 +1,22 @@ -# People who have contributed to the js-data project. +# This is the official list of js-data project contributors. # -# This file is controlled by scripts/authors.js +# Names are formatted as: +# Name [email address] # -# Names should be added to this file as: -# [commit count] Name - 1 David Madner - 2 InternalFX - 333 Jason Dobry - 1 Ken Børge Viktil - 4 Kent C. Dodds - 3 Matt Lewis - 2 Matt Winkler - 1 Mitranim - 2 Pencroff - 13 Robert Porter - 1 Simon Williams - 1 Trey Nelson - 1 Viktor Zozulyak - 1 Warren Taylor - 1 Yunchi Luo - 1 antoinebrault - 1 wilgert +antoinebrault +David Madner +InternalFX +Jason Dobry +Ken Børge Viktil +Kent C. Dodds +Matt Lewis +Matt Winkler +Mitranim +Pencroff +Robert Porter +Simon Williams +Trey Nelson +Viktor Zozulyak +Warren Taylor +wilgert +Yunchi Luo diff --git a/dist/js-data.es2015.js b/dist/js-data.es2015.js index 834fe176..2145c72d 100644 --- a/dist/js-data.es2015.js +++ b/dist/js-data.es2015.js @@ -1,6 +1,6 @@ /*! * js-data -* @version 3.0.0-alpha.29 - Homepage +* @version 3.0.0-beta.1 - Homepage * @author js-data project authors * @copyright (c) 2014-2016 js-data project authors * @license MIT @@ -69,13 +69,14 @@ babelHelpers; * @property {Function} isSorN TODO * @property {Function} isString TODO * @property {Function} isUndefined TODO - * @property {Function} possibleConstructorReturn TODO * @property {Function} reject TODO * @property {Function} resolve TODO * @property {Function} set TODO * @property {Function} toJson TODO */ +var DOMAIN = 'utils'; + var INFINITY = 1 / 0; var MAX_INTEGER = 1.7976931348623157e+308; var BOOL_TAG = '[object Boolean]'; @@ -88,6 +89,15 @@ var STRING_TAG = '[object String]'; var objToString = Object.prototype.toString; var PATH = /^(.+)\.(.+)$/; +var ERRORS = { + '400': function _() { + return 'expected: ' + arguments[0] + ', found: ' + (arguments[2] ? arguments[1] : babelHelpers.typeof(arguments[1])); + }, + '404': function _() { + return arguments[0] + ' not found'; + } +}; + var toInteger = function toInteger(value) { if (!value) { return 0; @@ -250,7 +260,7 @@ var utils = { */ classCallCheck: function classCallCheck(instance, ctor) { if (!(instance instanceof ctor)) { - throw new TypeError('Cannot call a class as a function'); + throw utils.err('' + ctor.name)(500, 'Cannot call a class as a function'); } }, @@ -283,7 +293,7 @@ var utils = { } } else { if (from === to) { - throw new Error('Cannot copy! Source and destination are identical.'); + throw utils.err(DOMAIN + '.copy')(500, 'Cannot copy! Source and destination are identical.'); } stackFrom = stackFrom || []; @@ -427,14 +437,25 @@ var utils = { /** * TODO - * - * @ignore */ equal: function equal(a, b) { return a == b; // eslint-disable-line }, + /** + * TODO + */ + err: function err(domain, target) { + return function (code) { + var prefix = '[' + domain + ':' + target + '] '; + var message = ERRORS[code].apply(null, Array.prototype.slice.call(arguments, 1)); + message = '' + prefix + message + '\nhttp://www.js-data.io/v3.0/docs/errors#' + code; + return new Error(message); + }; + }, + + /** * Add eventing capabilities into the target object. * @@ -445,7 +466,7 @@ var utils = { * @param {Function} [setter] Custom setter for setting the object's event * listeners. */ - eventify: function eventify(target, getter, setter, enumerable) { + eventify: function eventify(target, getter, setter) { target = target || this; var _events = {}; if (!getter && !setter) { @@ -458,7 +479,6 @@ var utils = { } Object.defineProperties(target, { emit: { - enumerable: !!enumerable, value: function value() { var events = getter.call(this) || {}; @@ -480,7 +500,6 @@ var utils = { } }, off: { - enumerable: !!enumerable, value: function value(type, func) { var events = getter.call(this); var listeners = events[type]; @@ -499,7 +518,6 @@ var utils = { } }, on: { - enumerable: !!enumerable, value: function value(type, func, ctx) { if (!getter.call(this)) { setter.call(this, {}); @@ -539,11 +557,11 @@ var utils = { args[_key2] = arguments[_key2]; } - var _this = utils.possibleConstructorReturn(this, (_subClass.__super__ || Object.getPrototypeOf(_subClass)).apply(this, args)); - return _this; + superClass.apply(this, args); }; } + // Setup inheritance of instance members _subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { configurable: true, @@ -554,6 +572,7 @@ var utils = { }); var obj = Object; + // Setup inheritance of static members if (obj.setPrototypeOf) { obj.setPrototypeOf(_subClass, superClass); } else if (classProps.strictEs6Class) { @@ -603,6 +622,9 @@ var utils = { */ findIndex: function findIndex(array, fn) { var index = -1; + if (!array) { + return index; + } array.forEach(function (record, i) { if (fn(record)) { index = i; @@ -918,6 +940,9 @@ var utils = { * @ignore */ noDupeAdd: function noDupeAdd(array, record, fn) { + if (!array) { + return; + } var index = this.findIndex(array, fn); if (index < 0) { array.push(record); @@ -952,20 +977,6 @@ var utils = { }, - /** - * TODO - * - * @ignore - */ - possibleConstructorReturn: function possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called'); - } - - return call && ((typeof call === 'undefined' ? 'undefined' : babelHelpers.typeof(call)) === 'object' || typeof call === 'function') ? call : self; - }, - - /** * Proxy for `Promise.reject`. * @@ -984,6 +995,9 @@ var utils = { * @ignore */ remove: function remove(array, fn) { + if (!array || !array.length) { + return; + } var index = this.findIndex(array, fn); if (index >= 0) { array.splice(index, 1); @@ -1166,6 +1180,9 @@ utils$1.eventify(Component.prototype, function () { this._listeners = value; }); +var DOMAIN$2 = 'Query'; +var INDEX_ERR = 'Index inaccessible after first operation'; + // Reserved words used by JSData's Query Syntax var reserved = { limit: '', @@ -1250,7 +1267,7 @@ var Query = Component.extend({ var self = this; opts || (opts = {}); if (self.data) { - throw new Error('Cannot access index after first operation!'); + throw utils$1.err(DOMAIN$2 + '#between')(500, 'Cannot access index'); } self.data = self.collection.getIndex(opts.index).between(leftKeys, rightKeys, opts); return self; @@ -1517,7 +1534,7 @@ var Query = Component.extend({ keyList || (keyList = []); opts || (opts = {}); if (self.data) { - throw new Error('Cannot access index after first operation!'); + throw utils$1.err(DOMAIN$2 + '#get')(500, INDEX_ERR); } if (keyList && !utils$1.isArray(keyList)) { keyList = [keyList]; @@ -1559,7 +1576,7 @@ var Query = Component.extend({ var self = this; var opts = {}; if (self.data) { - throw new Error('Cannot access index after first operation!'); + throw utils$1.err(DOMAIN$2 + '#getAll')(500, INDEX_ERR); } for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { @@ -1618,7 +1635,7 @@ var Query = Component.extend({ */ limit: function limit(num) { if (!utils$1.isNumber(num)) { - throw new TypeError('limit: Expected number but found ' + (typeof num === 'undefined' ? 'undefined' : babelHelpers.typeof(num)) + '!'); + throw utils$1.err(DOMAIN$2 + '#limit', 'num')(400, 'number', num); } var data = this.getData(); this.data = data.slice(0, Math.min(data.length, num)); @@ -1693,7 +1710,7 @@ var Query = Component.extend({ */ skip: function skip(num) { if (!utils$1.isNumber(num)) { - throw new TypeError('skip: Expected number but found ' + (typeof num === 'undefined' ? 'undefined' : babelHelpers.typeof(num)) + '!'); + throw utils$1.err(DOMAIN$2 + '#skip', 'num')(400, 'number', num); } var data = this.getData(); if (num < data.length) { @@ -2086,6 +2103,8 @@ utils$1.addHiddenPropsToTarget(Index.prototype, { } }); +var DOMAIN$1 = 'Collection'; + var COLLECTION_DEFAULTS = { /** * Field to be used as the unique identifier for records in this collection. @@ -2153,7 +2172,7 @@ var Collection = Component.extend({ utils$1.classCallCheck(self, Collection); Collection.__super__.call(self); - if (utils$1.isObject(records) && !utils$1.isArray(records)) { + if (records && !utils$1.isArray(records)) { opts = records; records = []; } @@ -2219,16 +2238,10 @@ var Collection = Component.extend({ } }); - var mapper = self.mapper; - // Insert initial data into the collection - records.forEach(function (record) { - record = mapper ? mapper.createRecord(record, opts) : record; - self.index.insertRecord(record); - if (record && utils$1.isFunction(record.on)) { - record.on('all', self._onRecordEvent, self); - } - }); + if (records) { + self.add(records); + } }, /** @@ -2275,9 +2288,13 @@ var Collection = Component.extend({ // Track whether just one record or an array of records is being inserted var singular = false; var idAttribute = self.recordId(); - if (utils$1.isObject(records) && !utils$1.isArray(records)) { - records = [records]; - singular = true; + if (!utils$1.isArray(records)) { + if (utils$1.isObject(records)) { + records = [records]; + singular = true; + } else { + throw utils$1.err(DOMAIN$1 + '#add', 'records')(400, 'object or array', records); + } } // Map the provided records to existing records. @@ -2287,7 +2304,7 @@ var Collection = Component.extend({ records = records.map(function (record) { var id = self.recordId(record); if (!utils$1.isSorN(id)) { - throw new TypeError('Collection#add: Expected string or number for ' + idAttribute + ', found ' + (typeof id === 'undefined' ? 'undefined' : babelHelpers.typeof(id)) + '!'); + throw utils$1.err(DOMAIN$1 + '#add', 'record.' + idAttribute)(400, 'string or number', id); } // Grab existing record if there is one var existing = self.get(id); @@ -2310,6 +2327,8 @@ var Collection = Component.extend({ } }); existing.set(record); + } else { + throw utils$1.err(DOMAIN$1 + '#add', 'opts.onConflict')(400, 'one of (merge, replace)', onConflict, true); } record = existing; // Update all indexes in the collection @@ -2330,7 +2349,7 @@ var Collection = Component.extend({ return record; }); // Finally, return the inserted data - var result = singular ? records.length ? records[0] : undefined : records; + var result = singular ? records[0] : records; // TODO: Make this more performant (batch events?) self.emit('add', result); return self.afterAdd(records, opts, result) || result; @@ -2583,7 +2602,7 @@ var Collection = Component.extend({ getIndex: function getIndex(name) { var index = name ? this.indexes[name] : this.index; if (!index) { - throw new Error('Index ' + name + ' does not exist!'); + throw utils$1.err(DOMAIN$1 + '#getIndex', name)(404, 'index'); } return index; }, @@ -2669,7 +2688,7 @@ var Collection = Component.extend({ if (record) { return utils$1.get(record, self.recordId()); } - return self.mapper ? self.mapper.idAttribute : self.idAttribute || 'id'; + return self.mapper ? self.mapper.idAttribute : self.idAttribute; }, @@ -2847,30 +2866,33 @@ var belongsToType = 'belongsTo'; var hasManyType = 'hasMany'; var hasOneType = 'hasOne'; +var DOMAIN$4 = 'Relation'; + function Relation(related, opts) { var self = this; + var DOMAIN_ERR = 'new ' + DOMAIN$4; opts || (opts = {}); var localField = opts.localField; if (!localField) { - throw new Error('localField is required!'); + throw utils$1.err(DOMAIN_ERR, 'opts.localField')(400, 'string', localField); } var foreignKey = opts.foreignKey = opts.foreignKey || opts.localKey; if (!foreignKey && (opts.type === belongsToType || opts.type === hasOneType)) { - throw new Error('foreignKey is required!'); + throw utils$1.err(DOMAIN_ERR, 'opts.foreignKey')(400, 'string', foreignKey); } var localKeys = opts.localKeys; var foreignKeys = opts.foreignKeys; if (!foreignKey && !localKeys && !foreignKeys && opts.type === hasManyType) { - throw new Error('one of (foreignKey, localKeys, foreignKeys) is required!'); + throw utils$1.err(DOMAIN_ERR, 'opts.')(400, 'string', foreignKey); } if (utils$1.isString(related)) { opts.relation = related; if (!utils$1.isFunction(opts.getRelation)) { - throw new Error('you must provide a reference to the related mapper!'); + throw utils$1.err(DOMAIN_ERR, 'opts.getRelation')(400, 'function', opts.getRelation); } } else if (related) { opts.relation = related.name; @@ -2878,7 +2900,7 @@ function Relation(related, opts) { value: related }); } else { - throw new Error('no relation provided!'); + throw utils$1.err(DOMAIN_ERR, 'related')(400, 'Mapper or string', related); } Object.defineProperty(self, 'inverse', { @@ -2893,7 +2915,6 @@ utils$1.addHiddenPropsToTarget(Relation.prototype, { getRelation: function getRelation() { return this.relatedMapper; }, - getLocalKeys: function getLocalKeys(record) {}, getForeignKey: function getForeignKey(record) { if (this.type === belongsToType) { return utils$1.get(record, this.foreignKey); @@ -3023,6 +3044,8 @@ var _hasOne = function hasOne(related, opts) { }; }; +var DOMAIN$6 = 'Record'; + var superMethod = function superMethod(mapper, name) { var store = mapper.datastore; if (store && store[name]) { @@ -3096,10 +3119,12 @@ var Record = Component.extend({ * @ignore */ _mapper: function _mapper() { - if (!this.constructor.mapper) { - throw new Error('This recordClass has no Mapper!'); + var self = this; + var mapper = self.constructor.mapper; + if (!mapper) { + throw utils$1.err(DOMAIN$6 + '#_mapper', '')(404, 'mapper'); } - return this.constructor.mapper; + return mapper; }, @@ -3246,9 +3271,6 @@ var Record = Component.extend({ // beforeLoadRelations lifecycle hook op = opts.op = 'beforeLoadRelations'; return utils$1.resolve(self[op](relations, opts)).then(function () { - if (utils$1.isString(relations)) { - relations = [relations]; - } // Now delegate to the adapter op = opts.op = 'loadRelations'; mapper.dbg(op, self, relations, opts); @@ -3259,9 +3281,14 @@ var Record = Component.extend({ optsCopy.raw = false; if (utils$1.isFunction(def.load)) { task = def.load(mapper, def, self, opts); - } else if (def.type === 'hasMany') { + } else if (def.type === 'hasMany' || def.type === 'hasOne') { if (def.foreignKey) { - task = superMethod(relatedMapper, 'findAll')(babelHelpers.defineProperty({}, def.foreignKey, utils$1.get(self, mapper.idAttribute)), optsCopy); + task = superMethod(relatedMapper, 'findAll')(babelHelpers.defineProperty({}, def.foreignKey, utils$1.get(self, mapper.idAttribute)), optsCopy).then(function (relatedData) { + if (def.type === 'hasOne') { + return relatedData.length ? relatedData[0] : undefined; + } + return relatedData; + }); } else if (def.localKeys) { task = superMethod(relatedMapper, 'findAll')({ where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { @@ -3275,7 +3302,7 @@ var Record = Component.extend({ }) }, opts); } - } else if (def.type === 'belongsTo' || def.type === 'hasOne') { + } else if (def.type === 'belongsTo') { var key = utils$1.get(self, def.foreignKey); if (utils$1.isSorN(key)) { task = superMethod(relatedMapper, 'find')(key, optsCopy); @@ -3468,6 +3495,8 @@ utils$1.eventify(Record.prototype, function () { this._set('events', value); }); +var DOMAIN$7 = 'Schema'; + /** * TODO * @@ -4087,7 +4116,7 @@ var _validate = function _validate(value, schema, opts) { return; } if (!utils$1.isObject(schema)) { - throw new Error('Invalid schema at path: "' + opts.path + '"'); + throw utils$1.err(DOMAIN$7 + '#validate')(500, 'Invalid schema at path: "' + opts.path + '"'); } if (utils$1.isUndefined(opts.path)) { opts.path = []; @@ -4417,6 +4446,8 @@ var Schema = Component.extend({ validationKeywords: validationKeywords }); +var DOMAIN$5 = 'Mapper'; + var makeNotify = function makeNotify(num) { return function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { @@ -4717,7 +4748,7 @@ var Mapper = Component.extend({ * @type {string} */ if (!self.name) { - throw new Error('name is required!'); + throw utils$1.err('new ' + DOMAIN$5, 'opts.name')(400, 'string', self.name); } // Setup schema, with an empty default schema if necessary @@ -5184,12 +5215,12 @@ var Mapper = Component.extend({ })); } else if (def.type === hasManyType && def.localKeys) { // Create his hasMany relation first because it uses localKeys - tasks.push(relatedMapper.createMany(relationData, optsCopy)).then(function (data) { + tasks.push(relatedMapper.createMany(relationData, optsCopy).then(function (data) { def.setLocalField(belongsToRelationData, data); utils$1.set(props, def.localKeys, data.map(function (record) { return utils$1.get(record, relatedIdAttribute); })); - }); + })); } }); return utils$1.Promise.all(tasks).then(function () { @@ -5206,21 +5237,24 @@ var Mapper = Component.extend({ if (!relationData) { return; } + optsCopy.raw = false; var task = void 0; // Create hasMany and hasOne after the main create because we needed // a generated id to attach to these items if (def.type === hasManyType && def.foreignKey) { def.setForeignKey(createdRecord, relationData); task = def.getRelation().createMany(relationData, optsCopy).then(function (data) { - def.setLocalField(createdRecord, opts.raw ? data.data : data); + def.setLocalField(createdRecord, data); }); } else if (def.type === hasOneType) { def.setForeignKey(createdRecord, relationData); task = def.getRelation().create(relationData, optsCopy).then(function (data) { - def.setLocalField(createdRecord, opts.raw ? data.data : data); + def.setLocalField(createdRecord, data); }); } else if (def.type === belongsToType && def.getLocalField(belongsToRelationData)) { def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData)); + } else if (def.type === hasManyType && def.localKeys && def.getLocalField(belongsToRelationData)) { + def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData)); } if (task) { tasks.push(task); @@ -5400,7 +5434,7 @@ var Mapper = Component.extend({ }); } if (!utils$1.isObject(props)) { - throw new Error('Cannot create a record from ' + props + '!'); + throw utils$1.err(DOMAIN$5 + '#createRecord', 'props')(400, 'array or object', props); } var recordClass = self.recordClass; var relationList = self.relationList || []; @@ -5436,7 +5470,7 @@ var Mapper = Component.extend({ var self = this; var config = self.lifecycleMethods[method]; if (!config) { - throw new Error(method + ': No such CRUD method!'); + throw utils$1.err(DOMAIN$5 + '#crud', method)(404, 'method'); } var upper = '' + method.charAt(0).toUpperCase() + method.substr(1); @@ -5613,7 +5647,7 @@ var Mapper = Component.extend({ self.dbg('getAdapter', 'name:', name); var adapter = self.getAdapterName(name); if (!adapter) { - throw new ReferenceError(adapter + ' not found!'); + throw utils$1.err(DOMAIN$5 + '#getAdapter', 'name')(400, 'string', name); } return self.getAdapters()[adapter]; }, @@ -5925,18 +5959,22 @@ var Mapper = Component.extend({ validate: function validate(record, opts) { var self = this; var schema = self.getSchema(); - if (!schema) { - throw new Error(self.name + ' mapper has no schema!'); - } if (utils$1.isArray(record)) { - return record.map(function (_record) { + var errors = record.map(function (_record) { return schema.validate(_record, opts); }); - } else if (utils$1.isObject(record)) { - return schema.validate(record, opts); - } else { - throw new Error('not a record!'); + var hasErrors = false; + errors.forEach(function (err) { + if (err) { + hasErrors = true; + } + }); + if (hasErrors) { + return errors; + } + return undefined; } + return schema.validate(record, opts); }, @@ -5955,6 +5993,8 @@ var Mapper = Component.extend({ } }); +var DOMAIN$3 = 'Container'; + var toProxy = [ /** * Proxy for {@link Mapper#count}. @@ -6252,12 +6292,10 @@ var props = { // For backwards compatibility with defineResource if (utils$1.isObject(name)) { opts = name; - if (!opts.name) { - throw new Error('name is required!'); - } name = opts.name; - } else if (!utils$1.isString(name)) { - throw new Error('name is required!'); + } + if (!utils$1.isString(name)) { + throw utils$1.err(DOMAIN$3 + '#defineMapper', 'name')(400, 'string', name); } // Default values for arguments @@ -6275,6 +6313,7 @@ var props = { // Instantiate a mapper var mapper = self._mappers[name] = new mapperClass(opts); // eslint-disable-line + mapper.relations || (mapper.relations = {}); // Make sure the mapper's name is set mapper.name = name; // All mappers in this datastore will share adapters @@ -6333,7 +6372,7 @@ var props = { var self = this; var adapter = self.getAdapterName(name); if (!adapter) { - throw new ReferenceError(adapter + ' not found!'); + throw utils$1.err(DOMAIN$3 + '#getAdapter', 'name')(400, 'string', name); } return self.getAdapters()[adapter]; }, @@ -6386,7 +6425,7 @@ var props = { getMapper: function getMapper(name) { var mapper = this._mappers[name]; if (!mapper) { - throw new ReferenceError(name + ' is not a registered mapper!'); + throw utils$1.err(DOMAIN$3 + '#getMapper', name)(404, 'mapper'); } return mapper; }, @@ -6507,6 +6546,8 @@ toProxy.forEach(function (method) { */ var Container = Component.extend(props); +var DOMAIN$9 = 'LinkedCollection'; + /** * TODO * @@ -6528,11 +6569,13 @@ var LinkedCollection = Collection.extend({ LinkedCollection.__super__.call(self, records, opts); // Make sure this collection has somewhere to store "added" timestamps - self._added = {}; + Object.defineProperty(self, '_added', { + value: {} + }); - // Make sure this collection a reference to a datastore + // Make sure this collection has a reference to a datastore if (!self.datastore) { - throw new Error('This collection must have a datastore!'); + throw utils$1.err('new ' + DOMAIN$9, 'opts.datastore')(400, 'DataStore', self.datastore); } return self; }, @@ -6556,7 +6599,7 @@ var LinkedCollection = Collection.extend({ var self = this; var datastore = self.datastore; var mapper = self.mapper; - var relationList = mapper.relationList || []; + var relationList = mapper.relationList; var timestamp = new Date().getTime(); var usesRecordClass = !!mapper.recordClass; var idAttribute = mapper.idAttribute; @@ -6616,12 +6659,6 @@ var LinkedCollection = Collection.extend({ } return toInsertItem; }); - // If it's the parent that has the localKeys - if (def.localKeys && !utils$1.get(record, def.localKeys)) { - utils$1.set(record, def.localKeys, relatedData.map(function (inserted) { - return utils$1.get(inserted, relationIdAttribute); - })); - } } else { var relatedDataId = utils$1.get(relatedData, relationIdAttribute); // Handle inserting belongsTo and hasOne relations @@ -6649,10 +6686,10 @@ var LinkedCollection = Collection.extend({ if (foreignKey) { var _records2 = relatedCollection.filter(babelHelpers.defineProperty({}, foreignKey, id)); relatedData = _records2.length ? _records2 : undefined; - } else if (def.localKeys) { + } else if (def.localKeys && utils$1.get(record, def.localKeys)) { var _records3 = relatedCollection.filter({ where: babelHelpers.defineProperty({}, relationIdAttribute, { - 'in': utils$1.get(record, def.localKeys || []) + 'in': utils$1.get(record, def.localKeys) }) }); relatedData = _records3.length ? _records3 : undefined; @@ -6668,7 +6705,7 @@ var LinkedCollection = Collection.extend({ } if (relatedData) { def.setLocalField(record, relatedData); - } + } else {} }); }); } @@ -6710,6 +6747,7 @@ var LinkedCollection = Collection.extend({ } }); +var DOMAIN$8 = 'DataStore'; var DATASTORE_DEFAULTS = {}; var safeSet = function safeSet(record, field, value) { @@ -7432,7 +7470,7 @@ var props$1 = { getCollection: function getCollection(name) { var collection = this._collections[name]; if (!collection) { - throw new ReferenceError(name + ' is not a registered collection!'); + throw utils$1.err(DOMAIN$8 + '#getCollection', name)(404, 'collection'); } return collection; }, @@ -7653,13 +7691,12 @@ var DataStore = Container.extend(props$1); * if the current version is not beta. */ var version = { - alpha: '29', - beta: 'false', - full: '3.0.0-alpha.29', - major: parseInt('3', 10), - minor: parseInt('0', 10), - patch: parseInt('0', 10) + beta: 1, + full: '3.0.0-beta.1', + major: 3, + minor: 0, + patch: 0 }; -export { version, Collection, Component, Container, DataStore, LinkedCollection, Mapper, Query, Record, Schema, utils$1 as utils, belongsToType, hasManyType, hasOneType, _belongsTo as belongsTo, _hasMany as hasMany, _hasOne as hasOne }; +export { version, Collection, Component, Container, DataStore, Index, LinkedCollection, Mapper, Query, Record, Schema, utils$1 as utils, belongsToType, hasManyType, hasOneType, _belongsTo as belongsTo, _hasMany as hasMany, _hasOne as hasOne }; //# sourceMappingURL=js-data.es2015.js.map \ No newline at end of file diff --git a/dist/js-data.es2015.js.map b/dist/js-data.es2015.js.map index 2d1a34ce..9475540a 100644 --- a/dist/js-data.es2015.js.map +++ b/dist/js-data.es2015.js.map @@ -1 +1 @@ -{"version":3,"file":"js-data.es2015.js","sources":["../src/utils.js","../src/Component.js","../src/Query.js","../lib/mindex/utils.js","../lib/mindex/index.js","../src/Collection.js","../src/decorators.js","../src/Record.js","../src/Schema.js","../src/Mapper.js","../src/Container.js","../src/LinkedCollection.js","../src/DataStore.js","../src/index.js"],"sourcesContent":["/**\n * @name utils\n * @memberof module:js-data\n * @type {Object}\n * @property {Function} addHiddenPropsToTarget TODO\n * @property {Function} classCallCheck TODO\n * @property {Function} copy TODO\n * @property {Function} deepMixIn TODO\n * @property {Function} eventify TODO\n * @property {Function} extend TODO\n * @property {Function} fillIn TODO\n * @property {Function} fromJson TODO\n * @property {Function} get TODO\n * @property {Function} getSuper TODO\n * @property {Function} intersection TODO\n * @property {Function} isArray TODO\n * @property {Function} isBlacklisted TODO\n * @property {boolean} isBrowser TODO\n * @property {Function} isBoolean TODO\n * @property {Function} isFunction TODO\n * @property {Function} isInteger TODO\n * @property {Function} isNull TODO\n * @property {Function} isNumber TODO\n * @property {Function} isObject TODO\n * @property {Function} isRegExp TODO\n * @property {Function} isSorN TODO\n * @property {Function} isString TODO\n * @property {Function} isUndefined TODO\n * @property {Function} possibleConstructorReturn TODO\n * @property {Function} reject TODO\n * @property {Function} resolve TODO\n * @property {Function} set TODO\n * @property {Function} toJson TODO\n */\n\nconst INFINITY = 1 / 0\nconst MAX_INTEGER = 1.7976931348623157e+308\nconst BOOL_TAG = '[object Boolean]'\nconst DATE_TAG = '[object Date]'\nconst FUNC_TAG = '[object Function]'\nconst NUMBER_TAG = '[object Number]'\nconst OBJECT_TAG = '[object Object]'\nconst REGEXP_TAG = '[object RegExp]'\nconst STRING_TAG = '[object String]'\nconst objToString = Object.prototype.toString\nconst PATH = /^(.+)\\.(.+)$/\n\nconst toInteger = function (value) {\n if (!value) {\n return 0\n }\n // Coerce to number\n value = +value\n if (value === INFINITY || value === -INFINITY) {\n const sign = (value < 0 ? -1 : 1)\n return sign * MAX_INTEGER\n }\n const remainder = value % 1\n return value === value ? (remainder ? value - remainder : value) : 0 // eslint-disable-line\n}\n\nconst toStr = function (value) {\n return objToString.call(value)\n}\n\nconst isPlainObject = function (value) {\n return (!!value && typeof value === 'object' && value.constructor === Object)\n}\n\nconst mkdirP = function (object, path) {\n if (!path) {\n return object\n }\n const parts = path.split('.')\n parts.forEach(function (key) {\n if (!object[key]) {\n object[key] = {}\n }\n object = object[key]\n })\n return object\n}\n\nconst utils = {\n /**\n * TODO\n *\n * @ignore\n */\n Promise: Promise,\n\n /**\n * Shallow copy properties from src to dest that meet the following criteria:\n * - own enumerable\n * - not a function\n * - does not start with \"_\"\n *\n * @ignore\n * @param {Object} dest Destination object.\n * @param {Object} src Source object.\n */\n _ (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (key && utils.isUndefined(dest[key]) && !utils.isFunction(value) && key.indexOf('_') !== 0) {\n dest[key] = value\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _forRelation (opts, def, fn, ctx) {\n const relationName = def.relation\n let containedName = null\n let index\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n if ((index = utils._getIndex(opts.with, relationName)) >= 0) {\n containedName = relationName\n } else if ((index = utils._getIndex(opts.with, def.localField)) >= 0) {\n containedName = def.localField\n }\n\n if (opts.withAll) {\n fn.call(ctx, def, {})\n return\n } else if (!containedName) {\n return\n }\n let optsCopy = {}\n utils.fillIn(optsCopy, def.getRelation())\n utils.fillIn(optsCopy, opts)\n optsCopy.with = opts.with.slice()\n optsCopy._activeWith = optsCopy.with.splice(index, 1)[0]\n optsCopy.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n optsCopy.with[i] = relation.substr(containedName.length + 1)\n } else {\n optsCopy.with[i] = ''\n }\n })\n fn.call(ctx, def, optsCopy)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _getIndex (list, relation) {\n let index = -1\n list.forEach(function (_relation, i) {\n if (_relation === relation) {\n index = i\n return false\n } else if (utils.isObject(_relation)) {\n if (_relation.relation === relation) {\n index = i\n return false\n }\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n addHiddenPropsToTarget (target, props) {\n const map = {}\n utils.forOwn(props, function (value, key) {\n map[key] = {\n writable: true,\n value\n }\n })\n Object.defineProperties(target, map)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n areDifferent (a, b, opts) {\n opts || (opts = {})\n const diff = utils.diffObjects(a, b, opts)\n const diffCount = Object.keys(diff.added).length +\n Object.keys(diff.removed).length +\n Object.keys(diff.changed).length\n return diffCount > 0\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n classCallCheck (instance, ctor) {\n if (!(instance instanceof ctor)) {\n throw new TypeError('Cannot call a class as a function')\n }\n },\n\n /**\n * Deep copy a value.\n *\n * @ignore\n * @param {*} from Value to deep copy.\n * @return {*} Deep copy of `from`.\n */\n copy (from, to, stackFrom, stackTo, blacklist, plain) {\n if (!to) {\n to = from\n if (from) {\n if (utils.isArray(from)) {\n to = utils.copy(from, [], stackFrom, stackTo, blacklist, plain)\n } else if (utils.isDate(from)) {\n to = new Date(from.getTime())\n } else if (utils.isRegExp(from)) {\n to = new RegExp(from.source, from.toString().match(/[^\\/]*$/)[0])\n to.lastIndex = from.lastIndex\n } else if (utils.isObject(from)) {\n if (plain) {\n to = utils.copy(from, {}, stackFrom, stackTo, blacklist, plain)\n } else {\n to = utils.copy(from, Object.create(Object.getPrototypeOf(from)), stackFrom, stackTo, blacklist, plain)\n }\n }\n }\n } else {\n if (from === to) {\n throw new Error('Cannot copy! Source and destination are identical.')\n }\n\n stackFrom = stackFrom || []\n stackTo = stackTo || []\n\n if (utils.isObject(from)) {\n let index = stackFrom.indexOf(from)\n if (index !== -1) {\n return stackTo[index]\n }\n\n stackFrom.push(from)\n stackTo.push(to)\n }\n\n let result\n if (utils.isArray(from)) {\n let i\n to.length = 0\n for (i = 0; i < from.length; i++) {\n result = utils.copy(from[i], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[i])) {\n stackFrom.push(from[i])\n stackTo.push(result)\n }\n to.push(result)\n }\n } else {\n if (utils.isArray(to)) {\n to.length = 0\n } else {\n utils.forOwn(to, function (value, key) {\n delete to[key]\n })\n }\n for (var key in from) {\n if (from.hasOwnProperty(key)) {\n if (utils.isBlacklisted(key, blacklist)) {\n continue\n }\n result = utils.copy(from[key], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[key])) {\n stackFrom.push(from[key])\n stackTo.push(result)\n }\n to[key] = result\n }\n }\n }\n }\n return to\n },\n\n /**\n * Recursively shallow fill in own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepFillIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepFillIn(existing, value)\n } else if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * Recursively shallow copy own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepMixIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepMixIn(existing, value)\n } else {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * @param {Object} a Base object.\n * @param {Object} b Comparison object.\n * @return {Object} Diff.\n */\n diffObjects (a, b, opts) {\n opts || (opts = {})\n let equalsFn = opts.equalsFn\n let bl = opts.ignore\n const diff = {\n added: {},\n changed: {},\n removed: {}\n }\n if (!utils.isFunction(equalsFn)) {\n equalsFn = utils.strictEqual\n }\n\n utils.forOwn(b, function (oldValue, key) {\n const newValue = a[key]\n\n if (utils.isBlacklisted(key, bl) || equalsFn(newValue, oldValue)) {\n return\n }\n\n if (utils.isUndefined(newValue)) {\n diff.removed[key] = undefined\n } else if (!equalsFn(newValue, oldValue)) {\n diff.changed[key] = newValue\n }\n })\n\n utils.forOwn(a, function (newValue, key) {\n if (!utils.isUndefined(b[key]) || utils.isBlacklisted(key, bl)) {\n return\n }\n diff.added[key] = newValue\n })\n\n return diff\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n equal (a, b) {\n return a == b // eslint-disable-line\n },\n\n /**\n * Add eventing capabilities into the target object.\n *\n * @ignore\n * @param {Object} target Target object.\n * @param {Function} [getter] Custom getter for retrieving the object's event\n * listeners.\n * @param {Function} [setter] Custom setter for setting the object's event\n * listeners.\n */\n eventify (target, getter, setter, enumerable) {\n target = target || this\n let _events = {}\n if (!getter && !setter) {\n getter = function () {\n return _events\n }\n setter = function (value) {\n _events = value\n }\n }\n Object.defineProperties(target, {\n emit: {\n enumerable: !!enumerable,\n value (...args) {\n const events = getter.call(this) || {}\n const type = args.shift()\n let listeners = events[type] || []\n let i\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n listeners = events.all || []\n args.unshift(type)\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n }\n },\n off: {\n enumerable: !!enumerable,\n value (type, func) {\n const events = getter.call(this)\n const listeners = events[type]\n if (!listeners) {\n setter.call(this, {})\n } else if (func) {\n for (let i = 0; i < listeners.length; i++) {\n if (listeners[i].f === func) {\n listeners.splice(i, 1)\n break\n }\n }\n } else {\n listeners.splice(0, listeners.length)\n }\n }\n },\n on: {\n enumerable: !!enumerable,\n value (type, func, ctx) {\n if (!getter.call(this)) {\n setter.call(this, {})\n }\n const events = getter.call(this)\n events[type] = events[type] || []\n events[type].push({\n c: ctx,\n f: func\n })\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n extend (props, classProps) {\n const superClass = this\n let subClass\n\n props || (props = {})\n classProps || (classProps = {})\n\n if (props.hasOwnProperty('constructor')) {\n subClass = props.constructor\n delete props.constructor\n } else {\n subClass = function (...args) {\n utils.classCallCheck(this, subClass)\n const _this = utils.possibleConstructorReturn(this, (subClass.__super__ || Object.getPrototypeOf(subClass)).apply(this, args))\n return _this\n }\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n configurable: true,\n enumerable: false,\n value: subClass,\n writable: true\n }\n })\n\n const obj = Object\n if (obj.setPrototypeOf) {\n obj.setPrototypeOf(subClass, superClass)\n } else if (classProps.strictEs6Class) {\n subClass.__proto__ = superClass // eslint-disable-line\n } else {\n utils.forOwn(superClass, function (value, key) {\n subClass[key] = value\n })\n }\n Object.defineProperty(subClass, '__super__', {\n configurable: true,\n value: superClass\n })\n\n utils.addHiddenPropsToTarget(subClass.prototype, props)\n utils.fillIn(subClass, classProps)\n\n return subClass\n },\n\n /**\n * Shallow copy own enumerable properties from `src` to `dest` that are on `src`\n * but are missing from `dest.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n fillIn (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n return dest\n },\n\n /**\n * Find the index of something according to the given checker function.\n *\n * @ignore\n * @param {Array} array The array to search.\n * @param {Function} fn Checker function.\n * @param {number} Index if found or -1 if not found.\n */\n findIndex (array, fn) {\n let index = -1\n array.forEach(function (record, i) {\n if (fn(record)) {\n index = i\n return false\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n forEachRelation (mapper, opts, fn, ctx) {\n const relationList = mapper.relationList || []\n if (!relationList.length) {\n return\n }\n relationList.forEach(function (def) {\n utils._forRelation(opts, def, fn, ctx)\n })\n },\n\n /**\n * Iterate over an object's own enumerable properties.\n *\n * @ignore\n * @param {Object} object The object whose properties are to be enumerated.\n * @param {Function} fn Iteration function.\n * @param {Object} [thisArg] Content to which to bind `fn`.\n */\n forOwn (obj, fn, thisArg) {\n const keys = Object.keys(obj)\n const len = keys.length\n let i\n for (i = 0; i < len; i++) {\n fn.call(thisArg, obj[keys[i]], keys[i], obj)\n }\n },\n\n /**\n * Proxy for `JSON.parse`.\n *\n * @ignore\n * @param {string} json JSON to parse.\n * @return {Object} Parsed object.\n */\n fromJson (json) {\n return utils.isString(json) ? JSON.parse(json) : json\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n 'get': function (object, prop) {\n if (!prop) {\n return\n }\n const parts = prop.split('.')\n const last = parts.pop()\n\n while (prop = parts.shift()) { // eslint-disable-line\n object = object[prop]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n return object[last]\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n getSuper (instance, isCtor) {\n const ctor = isCtor ? instance : instance.constructor\n return (ctor.__super__ || Object.getPrototypeOf(ctor) || ctor.__proto__) // eslint-disable-line\n },\n\n /**\n * Return the intersection of two arrays.\n *\n * @ignore\n * @param {Array} array1 First array.\n * @param {Array} array2 Second array.\n * @return {Array} Array of elements common to both arrays.\n */\n intersection (array1, array2) {\n if (!array1 || !array2) {\n return []\n }\n const result = []\n let item\n let i\n const len = array1.length\n for (i = 0; i < len; i++) {\n item = array1[i]\n if (result.indexOf(item) !== -1) {\n continue\n }\n if (array2.indexOf(item) !== -1) {\n result.push(item)\n }\n }\n return result\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isArray: Array.isArray,\n\n /**\n * Return whether `prop` is matched by any string or regular expression in `bl`.\n *\n * @ignore\n * @param {string} prop The name of a property.\n * @param {Array} bl Array of strings and regular expressions.\n * @return {boolean} Whether `prop` was matched.\n */\n isBlacklisted (prop, bl) {\n if (!bl || !bl.length) {\n return false\n }\n let matches\n for (var i = 0; i < bl.length; i++) {\n if ((toStr(bl[i]) === REGEXP_TAG && bl[i].test(prop)) || bl[i] === prop) {\n matches = prop\n return matches\n }\n }\n return !!matches\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBoolean (value) {\n return toStr(value) === BOOL_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBrowser: false,\n\n /**\n * TODO\n *\n * @ignore\n */\n isDate (value) {\n return (value && typeof value === 'object' && toStr(value) === DATE_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isFunction (value) {\n return typeof value === 'function' || (value && toStr(value) === FUNC_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isInteger (value) {\n return toStr(value) === NUMBER_TAG && value == toInteger(value) // eslint-disable-line\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNull (value) {\n return value === null\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNumber (value) {\n const type = typeof value\n return type === 'number' || (value && type === 'object' && toStr(value) === NUMBER_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isObject (value) {\n return toStr(value) === OBJECT_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isRegExp (value) {\n return toStr(value) === REGEXP_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isSorN (value) {\n return utils.isString(value) || utils.isNumber(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isString (value) {\n return typeof value === 'string' || (value && typeof value === 'object' && toStr(value) === STRING_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isUndefined (value) {\n return value === undefined\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n logify (target) {\n utils.addHiddenPropsToTarget(target, {\n dbg (...args) {\n this.log('debug', ...args)\n },\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (${this.name || this.constructor.name})`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n noDupeAdd (array, record, fn) {\n const index = this.findIndex(array, fn)\n if (index < 0) {\n array.push(record)\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n omit (props, keys) {\n // Remove relations\n const _props = {}\n utils.forOwn(props, function (value, key) {\n if (keys.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n return _props\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n plainCopy (from) {\n return utils.copy(from, undefined, undefined, undefined, undefined, true)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n possibleConstructorReturn (self, call) {\n if (!self) {\n throw new ReferenceError('this hasn\\'t been initialised - super() hasn\\'t been called')\n }\n\n return call && (typeof call === 'object' || typeof call === 'function') ? call : self\n },\n\n /**\n * Proxy for `Promise.reject`.\n *\n * @ignore\n * @param {*} [value] Value with which to reject the Promise.\n * @return {Promise} Promise reject with `value`.\n */\n reject (value) {\n return utils.Promise.reject(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n remove (array, fn) {\n const index = this.findIndex(array, fn)\n if (index >= 0) {\n array.splice(index, 1)\n }\n },\n\n /**\n * Proxy for `Promise.resolve`.\n *\n * @ignore\n * @param {*} [value] Value with which to resolve the Promise.\n * @return {Promise} Promise resolved with `value`.\n */\n resolve (value) {\n return utils.Promise.resolve(value)\n },\n\n /**\n * Set the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object on which to set a property.\n * @param {(string|Object)} path The key or path to the property. Can also\n * pass in an object of path/value pairs, which will all be set on the target\n * object.\n * @param {*} [value] The value to set.\n */\n set: function (object, path, value) {\n if (utils.isObject(path)) {\n utils.forOwn(path, function (value, _path) {\n utils.set(object, _path, value)\n })\n } else {\n const parts = PATH.exec(path)\n if (parts) {\n mkdirP(object, parts[1])[parts[2]] = value\n } else {\n object[path] = value\n }\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n strictEqual (a, b) {\n let _equal = a === b\n if (!_equal) {\n if (utils.isObject(a) && utils.isObject(b)) {\n utils.forOwn(a, function (value, key) {\n _equal = _equal && utils.strictEqual(value, b[key])\n })\n utils.forOwn(b, function (value, key) {\n _equal = _equal && utils.strictEqual(value, a[key])\n })\n } else if (utils.isArray(a) && utils.isArray(b)) {\n a.forEach(function (value, i) {\n _equal = _equal && utils.strictEqual(value, b[i])\n })\n }\n }\n return _equal\n },\n\n /**\n * Proxy for `JSON.stringify`.\n *\n * @ignore\n * @param {*} value Value to serialize to JSON.\n * @return {string} JSON string.\n */\n toJson: JSON.stringify,\n\n /**\n * Unset the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object from which to delete the property.\n * @param {string} path The key or path to the property.\n */\n unset (object, path) {\n const parts = path.split('.')\n const last = parts.pop()\n\n while (path = parts.shift()) { // eslint-disable-line\n object = object[path]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n object[last] = undefined\n }\n}\n\n// Attempt to detect whether we are in the browser.\ntry {\n utils.isBrowser = !!window\n} catch (e) {\n utils.isBrowser = false\n}\n\nexport default utils\n","import utils from './utils'\n\nexport default function Component () {\n /**\n * Event listeners attached to this Component. Do not modify. Use\n * {@link Component#on} and {@link Component#off} instead.\n *\n * @name Component#_listeners\n * @instance\n * @type {Object}\n */\n Object.defineProperty(this, '_listeners', { value: {} })\n}\n\n/**\n * Create a subclass of this component.\n *\n * @name Component.extend\n * @method\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @return {Function} Subclass of this component.\n */\nComponent.extend = utils.extend\n\n/**\n * TODO\n *\n * @name Component#dbg\n * @method\n */\n/**\n * TODO\n *\n * @name Component#log\n * @method\n */\nutils.logify(Component.prototype)\n\n/**\n * Register a new event listener on this Component.\n *\n * @name Component#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n/**\n * Remove an event listener from this Component. If no listener is provided,\n * then all listeners for the specified event will be removed. If no event is\n * specified then all listeners for all events will be removed.\n *\n * @name Component#off\n * @method\n * @param {string} [event] Name of event to unsubsribe to.\n * @param {Function} [listener] Listener to remove.\n */\n/**\n * Trigger an event on this Component.\n *\n * @name Component#emit\n * @method\n * @param {string} event Name of event to emit.\n * @param {...*} [args] Arguments to pass to any listeners.\n */\nutils.eventify(\n Component.prototype,\n function () {\n return this._listeners\n },\n function (value) {\n this._listeners = value\n }\n)\n","import utils from './utils'\nimport Component from './Component'\n\n// Reserved words used by JSData's Query Syntax\nconst reserved = {\n limit: '',\n offset: '',\n orderBy: '',\n skip: '',\n sort: '',\n where: ''\n}\n\n// Used by our JavaScript implementation of the LIKE operator\nconst escapeRegExp = /([.*+?^=!:${}()|[\\]\\/\\\\])/g\nconst percentRegExp = /%/g\nconst underscoreRegExp = /_/g\nconst escape = function (pattern) {\n return pattern.replace(escapeRegExp, '\\\\$1')\n}\n\n/**\n * A class used by the {@link Collection} class to build queries to be executed\n * against the collection's data. An instance of `Query` is returned by\n * {@link Collection#query}. Query instances are typically short-lived.\n *\n * ```javascript\n * import {Query} from 'js-data'\n * ```\n *\n * @class Query\n * @extends Component\n * @param {Collection} collection The collection on which this query operates.\n */\nexport default Component.extend({\n constructor: function Query (collection) {\n const self = this\n utils.classCallCheck(self, Query)\n\n /**\n * The {@link Collection} on which this query operates.\n *\n * @name Query#collection\n * @type {Collection}\n */\n self.collection = collection\n\n /**\n * The current data result of this query.\n *\n * @name Query#data\n * @type {Array}\n */\n self.data = null\n },\n\n /**\n * Find all entities between two boundaries.\n *\n * Get the users ages 18 to 30\n * ```js\n * const users = query.between(18, 30, { index: 'age' }).run()\n * ```\n * Same as above\n * ```js\n * const users = query.between([18], [30], { index: 'age' }).run()\n * ```\n *\n * @name Query#between\n * @method\n * @param {Array} leftKeys - Keys defining the left boundary.\n * @param {Array} rightKeys - Keys defining the right boundary.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.limit] - Limit the result to a certain number.\n * @param {boolean} [opts.offset] - The number of resulting entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n between (leftKeys, rightKeys, opts) {\n const self = this\n opts || (opts = {})\n if (self.data) {\n throw new Error('Cannot access index after first operation!')\n }\n self.data = self.collection.getIndex(opts.index).between(leftKeys, rightKeys, opts)\n return self\n },\n\n /**\n * The comparison function used by the Query class.\n *\n * @name Query#compare\n * @method\n * @param {Array} orderBy An orderBy clause used for sorting and sub-sorting.\n * @param {number} index The index of the current orderBy clause being used.\n * @param {*} a The first item in the comparison.\n * @param {*} b The second item in the comparison.\n * @return {number} -1 if `b` should preceed `a`. 0 if `a` and `b` are equal.\n * 1 if `a` should preceed `b`.\n */\n compare (orderBy, index, a, b) {\n const def = orderBy[index]\n let cA = utils.get(a, def[0])\n let cB = utils.get(b, def[0])\n if (cA && utils.isString(cA)) {\n cA = cA.toUpperCase()\n }\n if (cB && utils.isString(cB)) {\n cB = cB.toUpperCase()\n }\n if (a === undefined) {\n a = null\n }\n if (b === undefined) {\n b = null\n }\n if (def[1].toUpperCase() === 'DESC') {\n const temp = cB\n cB = cA\n cA = temp\n }\n if (cA < cB) {\n return -1\n } else if (cA > cB) {\n return 1\n } else {\n if (index < orderBy.length - 1) {\n return this.compare(orderBy, index + 1, a, b)\n } else {\n return 0\n }\n }\n },\n\n /**\n * Predicate evaluation function used by the Query class.\n *\n * @name Query#evaluate\n * @method\n * @param {*} value The value to evaluate.\n * @param {string} op The operator to use in this evaluation.\n * @param {*} predicate The predicate to use in this evaluation.\n * @return {boolean} Whether the value passed the evaluation or not.\n */\n evaluate (value, op, predicate) {\n const ops = this.constructor.ops\n if (ops[op]) {\n return ops[op](value, predicate)\n }\n if (op.indexOf('like') === 0) {\n return !utils.isNull(this.like(predicate, op.substr(4)).exec(value))\n } else if (op.indexOf('notLike') === 0) {\n return utils.isNull(this.like(predicate, op.substr(7)).exec(value))\n }\n },\n\n /**\n * Find the entity or entities that match the provided query or pass the\n * provided filter function.\n *\n * #### Example\n *\n * Get the draft posts created less than three months\n * ```js\n * const posts = query.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * }).run()\n * ```\n * Use a custom filter function\n * ```js\n * const posts = query.filter(function (post) {\n * return post.isReady()\n * }).run()\n * ```\n *\n * @name Query#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Function} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Query} A reference to itself for chaining.\n */\n filter (query, thisArg) {\n const self = this\n query || (query = {})\n self.getData()\n if (utils.isObject(query)) {\n let where = {}\n // Filter\n if (utils.isObject(query.where)) {\n where = query.where\n }\n utils.forOwn(query, function (value, key) {\n if (!(key in reserved) && !(key in where)) {\n where[key] = {\n '==': value\n }\n }\n })\n\n const fields = []\n const ops = []\n const predicates = []\n utils.forOwn(where, function (clause, field) {\n if (!utils.isObject(clause)) {\n clause = {\n '==': clause\n }\n }\n utils.forOwn(clause, function (expr, op) {\n fields.push(field)\n ops.push(op)\n predicates.push(expr)\n })\n })\n if (fields.length) {\n let i\n let len = fields.length\n self.data = self.data.filter(function (item) {\n let first = true\n let keep = true\n\n for (i = 0; i < len; i++) {\n let op = ops[i]\n const isOr = op.charAt(0) === '|'\n op = isOr ? op.substr(1) : op\n const expr = self.evaluate(utils.get(item, fields[i]), op, predicates[i])\n if (expr !== undefined) {\n keep = first ? expr : (isOr ? keep || expr : keep && expr)\n }\n first = false\n }\n return keep\n })\n }\n\n // Sort\n let orderBy = query.orderBy || query.sort\n\n if (utils.isString(orderBy)) {\n orderBy = [\n [orderBy, 'ASC']\n ]\n }\n if (!utils.isArray(orderBy)) {\n orderBy = null\n }\n\n // Apply 'orderBy'\n if (orderBy) {\n let index = 0\n orderBy.forEach(function (def, i) {\n if (utils.isString(def)) {\n orderBy[i] = [def, 'ASC']\n }\n })\n self.data.sort(function (a, b) {\n return self.compare(orderBy, index, a, b)\n })\n }\n\n // Skip\n if (utils.isNumber(query.skip)) {\n self.skip(query.skip)\n } else if (utils.isNumber(query.offset)) {\n self.skip(query.offset)\n }\n // Limit\n if (utils.isNumber(query.limit)) {\n self.limit(query.limit)\n }\n } else if (utils.isFunction(query)) {\n self.data = self.data.filter(query, thisArg)\n }\n return self\n },\n\n /**\n * Iterate over all entities.\n *\n * @name Query#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Query} A reference to itself for chaining.\n */\n forEach (forEachFn, thisArg) {\n this.getData().forEach(forEachFn, thisArg)\n return this\n },\n\n /**\n * Find the entity or entities that match the provided key.\n *\n * #### Example\n *\n * Get the entity whose primary key is 25\n * ```js\n * const entities = query.get(25).run()\n * ```\n * Same as above\n * ```js\n * const entities = query.get([25]).run()\n * ```\n * Get all users who are active and have the \"admin\" role\n * ```js\n * const activeAdmins = query.get(['active', 'admin'], {\n * index: 'activityAndRoles'\n * }).run()\n * ```\n * Get all entities that match a certain weather condition\n * ```js\n * const niceDays = query.get(['sunny', 'humid', 'calm'], {\n * index: 'weatherConditions'\n * }).run()\n * ```\n *\n * @name Query#get\n * @method\n * @param {Array} keyList - Key(s) defining the entity to retrieve. If\n * `keyList` is not an array (i.e. for a single-value key), it will be\n * wrapped in an array.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.string] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n get (keyList, opts) {\n const self = this\n keyList || (keyList = [])\n opts || (opts = {})\n if (self.data) {\n throw new Error('Cannot access index after first operation!')\n }\n if (keyList && !utils.isArray(keyList)) {\n keyList = [keyList]\n }\n if (!keyList.length) {\n self.getData()\n return self\n }\n self.data = self.collection.getIndex(opts.index).get(keyList)\n return self\n },\n\n /**\n * Find the entity or entities that match the provided keyLists.\n *\n * #### Example\n *\n * Get the posts where \"status\" is \"draft\" or \"inReview\"\n * ```js\n * const posts = query.getAll('draft', 'inReview', { index: 'status' }).run()\n * ```\n * Same as above\n * ```js\n * const posts = query.getAll(['draft'], ['inReview'], { index: 'status' }).run()\n * ```\n *\n * @name Query#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * entities matching each keyList will be retrieved. If no keyLists are\n * provided, all entities will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n getAll (...args) {\n const self = this\n let opts = {}\n if (self.data) {\n throw new Error('Cannot access index after first operation!')\n }\n if (!args.length || args.length === 1 && utils.isObject(args[0])) {\n self.getData()\n return self\n } else if (args.length && utils.isObject(args[args.length - 1])) {\n opts = args[args.length - 1]\n args.pop()\n }\n const collection = self.collection\n const index = collection.getIndex(opts.index)\n self.data = []\n args.forEach(function (keyList) {\n self.data = self.data.concat(index.get(keyList))\n })\n return self\n },\n\n /**\n * Return the current data result of this query.\n * @name Query#getData\n * @method\n * @return {Array} The data in this query.\n */\n getData () {\n const self = this\n if (!self.data) {\n self.data = self.collection.index.getAll()\n }\n return self.data\n },\n\n like (pattern, flags) {\n return new RegExp(`^${(escape(pattern).replace(percentRegExp, '.*').replace(underscoreRegExp, '.'))}$`, flags)\n },\n\n /**\n * Limit the result.\n *\n * #### Example\n *\n * Get only the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).limit(10).run()\n * ```\n *\n * @name Query#limit\n * @method\n * @param {number} num - The maximum number of entities to keep in the result.\n * @return {Query} A reference to itself for chaining.\n */\n limit (num) {\n if (!utils.isNumber(num)) {\n throw new TypeError(`limit: Expected number but found ${typeof num}!`)\n }\n const data = this.getData()\n this.data = data.slice(0, Math.min(data.length, num))\n return this\n },\n\n /**\n * Apply a mapping function to the result data.\n *\n * @name Query#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Query} A reference to itself for chaining.\n */\n map (mapFn, thisArg) {\n this.data = this.getData().map(mapFn, thisArg)\n return this\n },\n\n /**\n * Return the result of calling the specified function on each item in this\n * collection's main index.\n * @name Query#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Query} A reference to itself for chaining.\n */\n mapCall (funcName, ...args) {\n this.data = this.getData().map(function (item) {\n return item[funcName](...args)\n })\n return this\n },\n\n /**\n * Complete the execution of the query and return the resulting data.\n *\n * @name Query#run\n * @method\n * @return {Array} The result of executing this query.\n */\n run () {\n const data = this.data\n this.data = null\n return data\n },\n\n /**\n * Skip a number of results.\n *\n * #### Example\n *\n * Get all but the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).skip(10).run()\n * ```\n *\n * @name Query#skip\n * @method\n * @param {number} num - The number of entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n skip (num) {\n if (!utils.isNumber(num)) {\n throw new TypeError(`skip: Expected number but found ${typeof num}!`)\n }\n const data = this.getData()\n if (num < data.length) {\n this.data = data.slice(num)\n } else {\n this.data = []\n }\n return this\n }\n}, {\n /**\n * TODO\n *\n * @name Query.ops\n * @type {Object}\n */\n ops: {\n '==': function (value, predicate) {\n return value == predicate // eslint-disable-line\n },\n '===': function (value, predicate) {\n return value === predicate\n },\n '!=': function (value, predicate) {\n return value != predicate // eslint-disable-line\n },\n '!==': function (value, predicate) {\n return value !== predicate\n },\n '>': function (value, predicate) {\n return value > predicate\n },\n '>=': function (value, predicate) {\n return value >= predicate\n },\n '<': function (value, predicate) {\n return value < predicate\n },\n '<=': function (value, predicate) {\n return value <= predicate\n },\n 'isectEmpty': function (value, predicate) {\n return !utils.intersection((value || []), (predicate || [])).length\n },\n 'isectNotEmpty': function (value, predicate) {\n return utils.intersection((value || []), (predicate || [])).length\n },\n 'in': function (value, predicate) {\n return predicate.indexOf(value) !== -1\n },\n 'notIn': function (value, predicate) {\n return predicate.indexOf(value) === -1\n },\n 'contains': function (value, predicate) {\n return (value || []).indexOf(predicate) !== -1\n },\n 'notContains': function (value, predicate) {\n return (value || []).indexOf(predicate) === -1\n }\n }\n})\n","export function sort (a, b, hashCode) {\n // Short-curcuit comparison if a and b are strictly equal\n // This is absolutely necessary for indexed objects that\n // don't have the idAttribute field\n if (a === b) {\n return 0\n }\n if (hashCode) {\n a = hashCode(a)\n b = hashCode(b)\n }\n if (a === null && b === null) {\n return 0\n }\n\n if (a === null) {\n return -1\n }\n\n if (b === null) {\n return 1\n }\n\n if (a < b) {\n return -1\n }\n\n if (a > b) {\n return 1\n }\n\n return 0\n}\n\nexport function insertAt (array, index, value) {\n array.splice(index, 0, value)\n return array\n}\n\nexport function removeAt (array, index) {\n array.splice(index, 1)\n return array\n}\n\nexport function binarySearch (array, value, field) {\n let lo = 0\n let hi = array.length\n let compared\n let mid\n\n while (lo < hi) {\n mid = ((lo + hi) / 2) | 0\n compared = sort(value, array[mid], field)\n if (compared === 0) {\n return {\n found: true,\n index: mid\n }\n } else if (compared < 0) {\n hi = mid\n } else {\n lo = mid + 1\n }\n }\n\n return {\n found: false,\n index: hi\n }\n}\n","// Copyright (c) 2015, InternalFX.\n\n// Permission to use, copy, modify, and/or distribute this software for any purpose with or\n// without fee is hereby granted, provided that the above copyright notice and this permission\n// notice appear in all copies.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO\n// THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT\n// SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR\n// ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE\n// USE OR PERFORMANCE OF THIS SOFTWARE.\n\n// Modifications\n// Copyright 2015-2016 Jason Dobry\n//\n// Summary of modifications:\n// Converted to ES6 Class syntax\n// Reworked dependencies so as to re-use code already in js-data\nimport utils from '../../src/utils'\nimport {binarySearch, insertAt, removeAt} from './utils'\n\nexport default function Index (fieldList, opts) {\n utils.classCallCheck(this, Index)\n fieldList || (fieldList = [])\n\n if (!utils.isArray(fieldList)) {\n throw new Error('fieldList must be an array.')\n }\n\n opts || (opts = {})\n this.fieldList = fieldList\n this.fieldGetter = opts.fieldGetter\n this.hashCode = opts.hashCode\n this.isIndex = true\n this.keys = []\n this.values = []\n}\n\nutils.addHiddenPropsToTarget(Index.prototype, {\n 'set' (keyList, value) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n let dataLocation = binarySearch(this.values[pos.index], value, this.hashCode)\n if (!dataLocation.found) {\n insertAt(this.values[pos.index], dataLocation.index, value)\n }\n } else {\n insertAt(this.keys, pos.index, key)\n insertAt(this.values, pos.index, [value])\n }\n } else {\n if (pos.found) {\n this.values[pos.index].set(keyList, value)\n } else {\n insertAt(this.keys, pos.index, key)\n let newIndex = new Index([], { hashCode: this.hashCode })\n newIndex.set(keyList, value)\n insertAt(this.values, pos.index, newIndex)\n }\n }\n },\n\n 'get' (keyList) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n if (this.values[pos.index].isIndex) {\n return this.values[pos.index].getAll()\n } else {\n return this.values[pos.index]\n }\n } else {\n return []\n }\n } else {\n if (pos.found) {\n return this.values[pos.index].get(keyList)\n } else {\n return []\n }\n }\n },\n\n getAll () {\n let results = []\n this.values.forEach(function (value) {\n if (value.isIndex) {\n results = results.concat(value.getAll())\n } else {\n results = results.concat(value)\n }\n })\n return results\n },\n\n visitAll (cb, thisArg) {\n this.values.forEach(function (value) {\n if (value.isIndex) {\n value.visitAll(cb, thisArg)\n } else {\n value.forEach(cb, thisArg)\n }\n })\n },\n\n between (leftKeys, rightKeys, opts) {\n opts || (opts = {})\n if (!utils.isArray(leftKeys)) {\n leftKeys = [leftKeys]\n }\n if (!utils.isArray(rightKeys)) {\n rightKeys = [rightKeys]\n }\n utils.fillIn(opts, {\n leftInclusive: true,\n rightInclusive: false,\n limit: undefined,\n offset: 0\n })\n\n let results = this._between(leftKeys, rightKeys, opts)\n\n if (opts.limit) {\n return results.slice(opts.offset, opts.limit + opts.offset)\n } else {\n return results.slice(opts.offset)\n }\n },\n\n _between (leftKeys, rightKeys, opts) {\n let results = []\n\n let leftKey = leftKeys.shift()\n let rightKey = rightKeys.shift()\n\n let pos\n\n if (leftKey !== undefined) {\n pos = binarySearch(this.keys, leftKey)\n } else {\n pos = {\n found: false,\n index: 0\n }\n }\n\n if (leftKeys.length === 0) {\n if (pos.found && opts.leftInclusive === false) {\n pos.index += 1\n }\n\n for (let i = pos.index; i < this.keys.length; i += 1) {\n if (rightKey !== undefined) {\n if (opts.rightInclusive) {\n if (this.keys[i] > rightKey) { break }\n } else {\n if (this.keys[i] >= rightKey) { break }\n }\n }\n\n if (this.values[i].isIndex) {\n results = results.concat(this.values[i].getAll())\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n } else {\n for (let i = pos.index; i < this.keys.length; i += 1) {\n let currKey = this.keys[i]\n if (currKey > rightKey) { break }\n\n if (this.values[i].isIndex) {\n if (currKey === leftKey) {\n results = results.concat(this.values[i]._between(utils.copy(leftKeys), rightKeys.map(function () { return undefined }), opts))\n } else if (currKey === rightKey) {\n results = results.concat(this.values[i]._between(leftKeys.map(function () { return undefined }), utils.copy(rightKeys), opts))\n } else {\n results = results.concat(this.values[i].getAll())\n }\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n }\n\n if (opts.limit) {\n return results.slice(0, opts.limit + opts.offset)\n } else {\n return results\n }\n },\n\n peek () {\n if (this.values.length) {\n if (this.values[0].isIndex) {\n return this.values[0].peek()\n } else {\n return this.values[0]\n }\n }\n return []\n },\n\n clear () {\n this.keys = []\n this.values = []\n },\n\n insertRecord (data) {\n let keyList = this.fieldList.map(function (field) {\n if (utils.isFunction(field)) {\n return field(data) || null\n } else {\n return data[field] || null\n }\n })\n this.set(keyList, data)\n },\n\n removeRecord (data) {\n let removed\n this.values.forEach((value, i) => {\n if (value.isIndex) {\n if (value.removeRecord(data)) {\n if (value.keys.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n } else {\n const dataLocation = binarySearch(value, data, this.hashCode)\n if (dataLocation.found) {\n removeAt(value, dataLocation.index)\n if (value.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n }\n })\n return removed ? data : undefined\n },\n\n updateRecord (data) {\n this.removeRecord(data)\n this.insertRecord(data)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Query from './Query'\nimport Index from '../lib/mindex/index'\n\nconst COLLECTION_DEFAULTS = {\n /**\n * Field to be used as the unique identifier for records in this collection.\n * Defaults to `\"id\"` unless {@link Collection#mapper} is set, in which case\n * this will default to {@link Mapper#idAttribute}.\n *\n * @name Collection#idAttribute\n * @type {string}\n * @default \"id\"\n */\n idAttribute: 'id',\n\n /**\n * What to do when inserting a record into this Collection that shares a\n * primary key with a record already in this Collection.\n *\n * Possible values:\n * - merge\n * - replace\n *\n * Merge:\n *\n * Recursively shallow copy properties from the new record onto the existing\n * record.\n *\n * Replace:\n *\n * Shallow copy top-level properties from the new record onto the existing\n * record. Any top-level own properties of the existing record that are _not_\n * on the new record will be removed.\n *\n * @name Collection#onConflict\n * @type {string}\n * @default \"merge\"\n */\n onConflict: 'merge'\n}\n\n/**\n * ```javascript\n * import {Collection} from 'js-data'\n * ```\n *\n * An ordered set of {@link Record} instances.\n *\n * @example\n * import {Collection, Record} from 'js-data'\n * const user1 = new Record({ id: 1 })\n * const user2 = new Record({ id: 2 })\n * const UserCollection = new Collection([user1, user2])\n * UserCollection.get(1) === user1 // true\n *\n * @class Collection\n * @extends Component\n * @param {Array} [records] Initial set of records to insert into the\n * collection.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.idAttribute] See {@link Collection#idAttribute}.\n * @param {string} [opts.onConflict=\"merge\"] See {@link Collection#onConflict}.\n * @param {string} [opts.mapper] See {@link Collection#mapper}.\n */\nexport default Component.extend({\n constructor: function Collection (records, opts) {\n const self = this\n utils.classCallCheck(self, Collection)\n Collection.__super__.call(self)\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n opts = records\n records = []\n }\n if (utils.isString(opts)) {\n opts = { idAttribute: opts }\n }\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n /**\n * Default Mapper for this collection. Optional. If a Mapper is provided, then\n * the collection will use the {@link Mapper#idAttribute} setting, and will\n * wrap records in {@link Mapper#recordClass}.\n *\n * @example\n * import {Collection, Mapper} from 'js-data'\n *\n * class MyMapperClass extends Mapper {\n * foo () { return 'bar' }\n * }\n * const myMapper = new MyMapperClass()\n * const collection = new Collection(null, { mapper: myMapper })\n *\n * @name Collection#mapper\n * @type {Mapper}\n * @default null\n */\n Object.defineProperty(self, 'mapper', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n utils.fillIn(self, utils.copy(COLLECTION_DEFAULTS))\n\n const idAttribute = self.recordId()\n\n Object.defineProperties(self, {\n /**\n * The main index, which uses @{link Collection#recordId} as the key.\n *\n * @name Collection#index\n * @type {Index}\n */\n index: {\n value: new Index([idAttribute], {\n hashCode (obj) {\n return utils.get(obj, idAttribute)\n }\n })\n },\n\n /**\n * Object that holds the secondary indexes of this collection.\n *\n * @name Collection#indexes\n * @type {Object.}\n */\n indexes: {\n value: {}\n }\n })\n\n const mapper = self.mapper\n\n // Insert initial data into the collection\n records.forEach(function (record) {\n record = mapper ? mapper.createRecord(record, opts) : record\n self.index.insertRecord(record)\n if (record && utils.isFunction(record.on)) {\n record.on('all', self._onRecordEvent, self)\n }\n })\n },\n\n /**\n * Used to bind to events emitted by records in this Collection.\n *\n * @name Collection#_onRecordEvent\n * @method\n * @private\n * @param {...*} [arg] Args passed to {@link Collection#emit}.\n */\n _onRecordEvent (...args) {\n this.emit(...args)\n },\n\n /**\n * Insert the provided record or records.\n *\n * If a record is already in the collection then the provided record will\n * either merge with or replace the existing record based on the value of the\n * `onConflict` option.\n *\n * The collection's secondary indexes will be updated as each record is\n * visited.\n *\n * @name Collection#add\n * @method\n * @param {(Object|Object[]|Record|Record[])} data The record or records to insert.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.onConflict] What to do when a record is already in\n * the collection. Possible values are `merge` or `replace`.\n * @return {(Object|Object[]|Record|Record[])} The added record or records.\n */\n add (records, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n\n // Fill in \"opts\" with the Collection's configuration\n utils._(opts, self)\n records = self.beforeAdd(records, opts) || records\n\n // Track whether just one record or an array of records is being inserted\n let singular = false\n const idAttribute = self.recordId()\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n singular = true\n }\n\n // Map the provided records to existing records.\n // New records will be inserted. If any records map to existing records,\n // they will be merged into the existing records according to the onConflict\n // option.\n records = records.map(function (record) {\n let id = self.recordId(record)\n if (!utils.isSorN(id)) {\n throw new TypeError(`Collection#add: Expected string or number for ${idAttribute}, found ${typeof id}!`)\n }\n // Grab existing record if there is one\n const existing = self.get(id)\n // If the currently visited record is just a reference to an existing\n // record, then there is nothing to be done. Exit early.\n if (record === existing) {\n return existing\n }\n\n if (existing) {\n // Here, the currently visited record corresponds to a record already\n // in the collection, so we need to merge them\n const onConflict = opts.onConflict || self.onConflict\n if (onConflict === 'merge') {\n utils.deepMixIn(existing, record)\n } else if (onConflict === 'replace') {\n utils.forOwn(existing, (value, key) => {\n if (key !== idAttribute && !record.hasOwnProperty(key)) {\n delete existing[key]\n }\n })\n existing.set(record)\n }\n record = existing\n // Update all indexes in the collection\n self.updateIndexes(record)\n } else {\n // Here, the currently visted record does not correspond to any record\n // in the collection, so (optionally) instantiate this record and insert\n // it into the collection\n record = self.mapper ? self.mapper.createRecord(record, opts) : record\n self.index.insertRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.insertRecord(record)\n })\n if (record && utils.isFunction(record.on)) {\n record.on('all', self._onRecordEvent, self)\n }\n }\n return record\n })\n // Finally, return the inserted data\n const result = singular ? (records.length ? records[0] : undefined) : records\n // TODO: Make this more performant (batch events?)\n self.emit('add', result)\n return self.afterAdd(records, opts, result) || result\n },\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then {@link Collection#add} will return that same value.\n *\n * @name Collection#method\n * @method\n * @param {(Object|Object[]|Record|Record[])} result The record or records\n * that were added to this Collection by {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n afterAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}. If this method returns\n * a value then {@link Collection#remove} will return that same value.\n *\n * @name Collection#afterRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n * @param {Object} record The result that will be returned by {@link Collection#remove}.\n */\n afterRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}. If this method\n * returns a value then {@link Collection#removeAll} will return that same\n * value.\n *\n * @name Collection#afterRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n * @param {Object} records The result that will be returned by {@link Collection#removeAll}.\n */\n afterRemoveAll () {},\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then the `records` argument in {@link Collection#add} will be\n * re-assigned to the returned value.\n *\n * @name Collection#beforeAdd\n * @method\n * @param {(Object|Object[]|Record|Record[])} records The `records` argument passed to {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n beforeAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}.\n *\n * @name Collection#beforeRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n */\n beforeRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}.\n *\n * @name Collection#beforeRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n */\n beforeRemoveAll () {},\n\n /**\n * Find all records between two boundaries.\n *\n * Shortcut for `collection.query().between(18, 30, { index: 'age' }).run()`\n *\n * @example Get all users ages 18 to 30\n * const users = collection.between(18, 30, { index: 'age' })\n *\n * @example Same as above\n * const users = collection.between([18], [30], { index: 'age' })\n *\n * @name Collection#between\n * @method\n * @param {Array} leftKeys Keys defining the left boundary.\n * @param {Array} rightKeys Keys defining the right boundary.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.index] Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.limit] Limit the result to a certain number.\n * @param {boolean} [opts.offset] The number of resulting records to skip.\n * @return {Array} The result.\n */\n between (leftKeys, rightKeys, opts) {\n return this.query().between(leftKeys, rightKeys, opts).run()\n },\n\n /**\n * Create a new secondary index on the contents of the collection.\n *\n * @example Index users by age\n * collection.createIndex('age')\n *\n * @example Index users by status and role\n * collection.createIndex('statusAndRole', ['status', 'role'])\n *\n * @name Collection#createIndex\n * @method\n * @param {string} name - The name of the new secondary index.\n * @param {string[]} [fieldList] - Array of field names to use as the key or\n * compound key of the new secondary index. If no fieldList is provided, then\n * the name will also be the field that is used to index the collection.\n * @return {Collection} A reference to itself for chaining.\n */\n createIndex (name, fieldList, opts) {\n const self = this\n if (utils.isString(name) && fieldList === undefined) {\n fieldList = [name]\n }\n opts || (opts = {})\n opts.hashCode = opts.hashCode || function (obj) {\n return self.recordId(obj)\n }\n const index = self.indexes[name] = new Index(fieldList, opts)\n self.index.visitAll(index.insertRecord, index)\n return self\n },\n\n /**\n * Find the record or records that match the provided query or pass the\n * provided filter function.\n *\n * Shortcut for `collection.query().filter(queryOrFn[, thisArg]).run()`\n *\n * @example Get the draft posts created less than three months\n * const posts = collection.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * })\n *\n * @example Use a custom filter function\n * const posts = collection.filter(function (post) {\n * return post.isReady()\n * })\n *\n * @name Collection#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Object} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Array} The result.\n */\n filter (query, thisArg) {\n return this.query().filter(query, thisArg).run()\n },\n\n /**\n * Iterate over all records.\n *\n * @example\n * collection.forEach(function (record) {\n * // do something\n * })\n *\n * @name Collection#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Array} The result.\n */\n forEach (cb, thisArg) {\n this.index.visitAll(cb, thisArg)\n },\n\n /**\n * Get the record with the given id.\n *\n * @name Collection#get\n * @method\n * @param {(string|number)} id - The primary key of the record to get.\n * @return {(Object|Record)} The record with the given id.\n */\n get (id) {\n const instances = this.query().get(id).run()\n return instances.length ? instances[0] : undefined\n },\n\n /**\n * Find the record or records that match the provided keyLists.\n *\n * Shortcut for `collection.query().getAll(keyList1, keyList2, ...).run()`\n *\n * @example Get the posts where \"status\" is \"draft\" or \"inReview\"\n * const posts = collection.getAll('draft', 'inReview', { index: 'status' })\n *\n * @example Same as above\n * const posts = collection.getAll(['draft'], ['inReview'], { index: 'status' })\n *\n * @name Collection#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * records matching each keyList will be retrieved. If no keyLists are\n * provided, all records will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Array} The result.\n */\n getAll (...args) {\n return this.query().getAll(...args).run()\n },\n\n /**\n * Return the index with the given name. If no name is provided, return the\n * main index. Throws an error if the specified index does not exist.\n *\n * @name Collection#getIndex\n * @method\n * @param {string} [name] The name of the index to retrieve.\n */\n getIndex (name) {\n const index = name ? this.indexes[name] : this.index\n if (!index) {\n throw new Error(`Index ${name} does not exist!`)\n }\n return index\n },\n\n /**\n * Limit the result.\n *\n * Shortcut for `collection.query().limit(maximumNumber).run()`\n *\n * @example\n * const posts = collection.limit(10)\n *\n * @name Collection#limit\n * @method\n * @param {number} num - The maximum number of records to keep in the result.\n * @return {Array} The result.\n */\n limit (num) {\n return this.query().limit(num).run()\n },\n\n /**\n * Apply a mapping function to all records.\n *\n * @example\n * const names = collection.map(function (user) {\n * return user.name\n * })\n *\n * @name Collection#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Array} The result of the mapping.\n */\n map (cb, thisArg) {\n const data = []\n this.index.visitAll(function (value) {\n data.push(cb.call(thisArg, value))\n })\n return data\n },\n\n /**\n * Return the result of calling the specified function on each record in this\n * collection's main index.\n *\n * @name Collection#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Array} The result.\n */\n mapCall (funcName, ...args) {\n const data = []\n this.index.visitAll(function (record) {\n data.push(record[funcName](...args))\n })\n return data\n },\n\n /**\n * Return the primary key of the given, or if no record is provided, return the\n * name of the field that holds the primary key of records in this Collection.\n *\n * @name Collection#recordId\n * @method\n * @param {(Object|Record)} [record] The record whose primary key is to be\n * returned.\n * @return {(string|number)} Primary key or name of field that holds primary\n * key.\n */\n recordId (record) {\n const self = this\n if (record) {\n return utils.get(record, self.recordId())\n }\n return self.mapper ? self.mapper.idAttribute : self.idAttribute || 'id'\n },\n\n /**\n * Create a new query to be executed against the contents of the collection.\n * The result will be all or a subset of the contents of the collection.\n *\n * @example Grab page 2 of users between ages 18 and 30\n * collection.query()\n * .between(18, 30, { index: 'age' }) // between ages 18 and 30\n * .skip(10) // second page\n * .limit(10) // page size\n * .run()\n *\n * @name Collection#query\n * @method\n * @return {Query} New query object.\n */\n query () {\n return new Query(this)\n },\n\n /**\n * Reduce the data in the collection to a single value and return the result.\n *\n * @example\n * const totalVotes = collection.reduce(function (prev, record) {\n * return prev + record.upVotes + record.downVotes\n * }, 0)\n *\n * @name Collection#reduce\n * @method\n * @param {Function} cb - Reduction callback.\n * @param {*} initialValue - Initial value of the reduction.\n * @return {*} The result.\n */\n reduce (cb, initialValue) {\n const data = this.getAll()\n return data.reduce(cb, initialValue)\n },\n\n /**\n * Remove the record with the given id from this Collection.\n *\n * @name Collection#remove\n * @method\n * @param {(string|number)} id - The primary key of the record to be removed.\n * @param {Object} [opts] - Configuration options.\n * @return {Object|Record} The removed record, if any.\n */\n remove (id, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemove(id, opts)\n const record = self.get(id)\n\n // The record is in the collection, remove it\n if (record) {\n self.index.removeRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.removeRecord(record)\n })\n if (record && utils.isFunction(record.off)) {\n record.off('all', self._onRecordEvent, self)\n self.emit('remove', record)\n }\n }\n return self.afterRemove(id, opts, record) || record\n },\n\n /**\n * Remove the record selected by \"query\" from this collection.\n *\n * @name Collection#removeAll\n * @method\n * @param {Object} [query={}] - Selection query.\n * @param {Object} [query.where] - Filtering criteria.\n * @param {number} [query.skip] - Number to skip.\n * @param {number} [query.limit] - Number to limit to.\n * @param {Array} [query.orderBy] - Sorting criteria.\n * @param {Object} [opts] - Configuration options.\n * @return {(Object[]|Record[])} The removed records, if any.\n */\n removeAll (query, opts) {\n const self = this\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemoveAll(query, opts)\n const records = self.filter(query)\n\n // Remove each selected record from the collection\n records.forEach(function (item) {\n self.remove(self.recordId(item), opts)\n })\n return self.afterRemoveAll(query, opts, records) || records\n },\n\n /**\n * Skip a number of results.\n *\n * Shortcut for `collection.query().skip(numberToSkip).run()`\n *\n * @example\n * const posts = collection.skip(10)\n *\n * @name Collection#skip\n * @method\n * @param {number} num - The number of records to skip.\n * @return {Array} The result.\n */\n skip (num) {\n return this.query().skip(num).run()\n },\n\n /**\n * Return the plain JSON representation of all items in this collection.\n * Assumes records in this collection have a toJSON method.\n *\n * @name Collection#toJSON\n * @method\n * @param {Object} [opts] - Configuration options.\n * @param {string[]} [opts.with] - Array of relation names or relation fields\n * to include in the representation.\n * @return {Array} The records.\n */\n toJSON (opts) {\n return this.mapCall('toJSON', opts)\n },\n\n /**\n * Update a record's position in a single index of this collection. See\n * {@link Collection#updateIndexes} to update a record's position in all\n * indexes at once.\n *\n * @name Collection#updateIndex\n * @method\n * @param {Object} record - The record to update.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] The index in which to update the record's\n * position. If you don't specify an index then the record will be updated\n * in the main index.\n */\n updateIndex (record, opts) {\n opts || (opts = {})\n this.getIndex(opts.index).updateRecord(record)\n },\n\n /**\n * TODO\n *\n * @name Collection#updateIndexes\n * @method\n * @param {Object} record - TODO\n * @param {Object} [opts] - Configuration options.\n */\n updateIndexes (record) {\n const self = this\n self.index.updateRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.updateRecord(record)\n })\n }\n})\n","import utils from './utils'\n\nexport const belongsToType = 'belongsTo'\nexport const hasManyType = 'hasMany'\nexport const hasOneType = 'hasOne'\n\nfunction Relation (related, opts) {\n const self = this\n\n opts || (opts = {})\n\n const localField = opts.localField\n if (!localField) {\n throw new Error('localField is required!')\n }\n\n const foreignKey = opts.foreignKey = opts.foreignKey || opts.localKey\n if (!foreignKey && (opts.type === belongsToType || opts.type === hasOneType)) {\n throw new Error('foreignKey is required!')\n }\n const localKeys = opts.localKeys\n const foreignKeys = opts.foreignKeys\n if (!foreignKey && !localKeys && !foreignKeys && opts.type === hasManyType) {\n throw new Error('one of (foreignKey, localKeys, foreignKeys) is required!')\n }\n\n if (utils.isString(related)) {\n opts.relation = related\n if (!utils.isFunction(opts.getRelation)) {\n throw new Error('you must provide a reference to the related mapper!')\n }\n } else if (related) {\n opts.relation = related.name\n Object.defineProperty(self, 'relatedMapper', {\n value: related\n })\n } else {\n throw new Error('no relation provided!')\n }\n\n Object.defineProperty(self, 'inverse', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n}\n\nutils.addHiddenPropsToTarget(Relation.prototype, {\n getRelation () {\n return this.relatedMapper\n },\n getLocalKeys (record) {\n\n },\n getForeignKey (record) {\n if (this.type === belongsToType) {\n return utils.get(record, this.foreignKey)\n }\n return utils.get(record, this.mapper.idAttribute)\n },\n setForeignKey (record, relatedRecord) {\n const self = this\n if (!record || !relatedRecord) {\n return\n }\n if (self.type === belongsToType) {\n utils.set(record, self.foreignKey, utils.get(relatedRecord, self.getRelation().idAttribute))\n } else {\n const idAttribute = self.mapper.idAttribute\n if (utils.isArray(relatedRecord)) {\n relatedRecord.forEach(function (relatedRecordItem) {\n utils.set(relatedRecordItem, self.foreignKey, utils.get(record, idAttribute))\n })\n } else {\n utils.set(relatedRecord, self.foreignKey, utils.get(record, idAttribute))\n }\n }\n },\n getLocalField (record) {\n return utils.get(record, this.localField)\n },\n setLocalField (record, data) {\n return utils.set(record, this.localField, data)\n },\n getInverse (mapper) {\n const self = this\n if (self.inverse) {\n return self.inverse\n }\n self.getRelation().relationList.forEach(function (def) {\n if (def.getRelation() === mapper) {\n if (def.foreignKey && def.foreignKey !== self.foreignKey) {\n return\n }\n self.inverse = def\n return false\n }\n })\n return self.inverse\n }\n})\n\nconst relatedTo = function (mapper, related, opts) {\n opts.name = mapper.name\n const relation = new Relation(related, opts)\n Object.defineProperty(relation, 'mapper', {\n value: mapper\n })\n\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n mapper.relationFields || Object.defineProperty(mapper, 'relationFields', { value: [] })\n mapper.relationList.push(relation)\n mapper.relationFields.push(relation.localField)\n}\n\n/**\n * TODO\n *\n * @name module:js-data.belongsTo\n * @method\n * @param {Mapper} related The relation the target belongs to.\n * @param {Object} opts Configuration options.\n * @param {string} opts.foreignKey The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const belongsTo = function (related, opts) {\n opts || (opts = {})\n opts.type = belongsToType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasMany\n * @method\n * @param {Mapper} related The relation of which the target has many.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasMany = function (related, opts) {\n opts || (opts = {})\n opts.type = hasManyType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasOne\n * @method\n * @param {Mapper} related The relation of which the target has one.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasOne = function (related, opts) {\n opts || (opts = {})\n opts.type = hasOneType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n","import utils from './utils'\nimport Component from './Component'\n\nconst superMethod = function (mapper, name) {\n const store = mapper.datastore\n if (store && store[name]) {\n return function (...args) {\n return store[name](mapper.name, ...args)\n }\n }\n return mapper[name].bind(mapper)\n}\n\n/**\n * js-data's Record class.\n *\n * ```javascript\n * import {Record} from 'js-data'\n * ```\n *\n * @class Record\n * @extends Component\n * @param {Object} [props] The initial properties of the new Record instance.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation on the\n * initial properties.\n */\nconst Record = Component.extend({\n constructor: function Record (props, opts) {\n const self = this\n utils.classCallCheck(self, Record)\n\n props || (props = {})\n opts || (opts = {})\n const _props = {}\n Object.defineProperties(self, {\n _get: { value (key) { return utils.get(_props, key) } },\n _set: { value (key, value) { return utils.set(_props, key, value) } },\n _unset: { value (key) { return utils.unset(_props, key) } }\n })\n const _set = self._set\n // TODO: Optimize these strings\n _set('creating', true)\n if (opts.noValidate) {\n _set('noValidate', true)\n }\n utils.fillIn(self, props)\n _set('creating', false)\n _set('noValidate', false)\n _set('previous', utils.copy(props))\n },\n\n /**\n * TODO\n *\n * @name Record#_mapper\n * @method\n * @ignore\n */\n _mapper () {\n if (!this.constructor.mapper) {\n throw new Error('This recordClass has no Mapper!')\n }\n return this.constructor.mapper\n },\n\n /**\n * TODO\n *\n * @name Record#afterLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n afterLoadRelations () {},\n\n /**\n * TODO\n *\n * @name Record#beforeLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n beforeLoadRelations () {},\n\n /**\n * Return changes to this record since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#changes\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n changes (opts) {\n const self = this\n opts || (opts = {})\n return utils.diffObjects(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#commit\n * @method\n */\n commit () {\n const self = this\n self._set('changed') // unset\n self._set('previous', utils.copy(self))\n return self\n },\n\n /**\n * Call {@link Mapper#destroy} using this record's primary key.\n *\n * @name Record#destroy\n * @method\n * @param {Object} [opts] Configuration options passed to {@link Mapper#destroy}.\n * @return {Promise} The result of calling {@link Mapper#destroy}.\n */\n destroy (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n return superMethod(mapper, 'destroy')(utils.get(self, mapper.idAttribute), opts)\n },\n\n /**\n * Return the value at the given path for this instance.\n *\n * @name Record#get\n * @method\n * @param {string} key - Path of value to retrieve.\n * @return {*} Value at path.\n */\n 'get' (key) {\n return utils.get(this, key)\n },\n\n /**\n * Return whether this record has changed since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#hasChanges\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n hasChanges (opts) {\n const self = this\n const quickHasChanges = !!(self._get('changed') || []).length\n return quickHasChanges || utils.areDifferent(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#hashCode\n * @method\n */\n hashCode () {\n const self = this\n return utils.get(self, self._mapper().idAttribute)\n },\n\n isValid (opts) {\n const self = this\n return !self._mapper().validate(self, opts)\n },\n\n /**\n * TODO\n *\n * @name Record#loadRelations\n * @method\n * @param {string[]} [relations] TODO\n * @param {Object} [opts] TODO\n */\n loadRelations (relations, opts) {\n let op\n const self = this\n const mapper = self._mapper()\n\n // Default values for arguments\n relations || (relations = [])\n if (utils.isString(relations)) {\n relations = [relations]\n }\n opts || (opts = {})\n opts.with = relations\n\n // Fill in \"opts\" with the Model's configuration\n utils._(opts, mapper)\n opts.adapter = mapper.getAdapterName(opts)\n\n // beforeLoadRelations lifecycle hook\n op = opts.op = 'beforeLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n if (utils.isString(relations)) {\n relations = [relations]\n }\n // Now delegate to the adapter\n op = opts.op = 'loadRelations'\n mapper.dbg(op, self, relations, opts)\n let tasks = []\n let task\n utils.forEachRelation(mapper, opts, function (def, optsCopy) {\n const relatedMapper = def.getRelation()\n optsCopy.raw = false\n if (utils.isFunction(def.load)) {\n task = def.load(mapper, def, self, opts)\n } else if (def.type === 'hasMany') {\n if (def.foreignKey) {\n task = superMethod(relatedMapper, 'findAll')({\n [def.foreignKey]: utils.get(self, mapper.idAttribute)\n }, optsCopy)\n } else if (def.localKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [relatedMapper.idAttribute]: {\n 'in': utils.get(self, def.localKeys)\n }\n }\n })\n } else if (def.foreignKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [def.foreignKeys]: {\n 'contains': utils.get(self, mapper.idAttribute)\n }\n }\n }, opts)\n }\n } else if (def.type === 'belongsTo' || def.type === 'hasOne') {\n const key = utils.get(self, def.foreignKey)\n if (utils.isSorN(key)) {\n task = superMethod(relatedMapper, 'find')(key, optsCopy)\n }\n }\n if (task) {\n task = task.then(function (relatedData) {\n def.setLocalField(self, relatedData)\n })\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterLoadRelations lifecycle hook\n op = opts.op = 'afterLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n return self\n })\n })\n },\n\n /**\n * TODO\n *\n * @name Record#previous\n * @method\n * @param {string} [key] TODO\n */\n previous (key) {\n const self = this\n if (key) {\n return self._get(`previous.${key}`)\n }\n return self._get('previous')\n },\n\n /**\n * TODO\n *\n * @name Record#revert\n * @method\n * @param {Object} [opts] Configuration options.\n */\n revert (opts) {\n const self = this\n const previous = self._get('previous')\n opts || (opts = {})\n opts.preserve || (opts.preserve = [])\n utils.forOwn(self, (value, key) => {\n if (key !== self._mapper().idAttribute && !previous.hasOwnProperty(key) && self.hasOwnProperty(key) && opts.preserve.indexOf(key) === -1) {\n delete self[key]\n }\n })\n utils.forOwn(previous, (value, key) => {\n if (opts.preserve.indexOf(key) === -1) {\n self[key] = value\n }\n })\n self.commit()\n return self\n },\n\n /**\n * Delegates to {@link Mapper#create} or {@link Mapper#update}.\n *\n * @name Record#save\n * @method\n * @param {Object} [opts] Configuration options. See {@link Mapper#create}.\n * @param [opts] Configuration options.\n * @param {boolean} [opts.changesOnly] Equality function. Default uses `===`.\n * @param {Function} [opts.equalsFn] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @param {Array} [opts.ignore] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @return {Promise} The result of calling {@link Mapper#create} or\n * {@link Mapper#update}.\n */\n save (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n const id = utils.get(self, mapper.idAttribute)\n let props = self\n if (utils.isUndefined(id)) {\n return superMethod(mapper, 'create')(props, opts)\n }\n if (opts.changesOnly) {\n const changes = self.changes(opts)\n props = {}\n utils.fillIn(props, changes.added)\n utils.fillIn(props, changes.changed)\n }\n return superMethod(mapper, 'update')(id, props, opts)\n },\n\n /**\n * Set the value for a given key, or the values for the given keys if \"key\" is\n * an object.\n *\n * @name Record#set\n * @method\n * @param {(string|Object)} key - Key to set or hash of key-value pairs to set.\n * @param {*} [value] - Value to set for the given key.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n 'set' (key, value, opts) {\n const self = this\n if (utils.isObject(key)) {\n opts = value\n }\n opts || (opts = {})\n if (opts.silent) {\n self._set('silent', true)\n }\n utils.set(self, key, value)\n if (!self._get('eventId')) {\n self._set('silent') // unset\n }\n },\n\n // TODO: move logic for single-item async operations onto the instance.\n\n /**\n * Return a plain object representation of this record. If the class from\n * which this record was created has a mapper, then {@link Mapper#toJSON} will\n * be called instead.\n *\n * @name Record#toJSON\n * @method\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation. Only available as an option if the class\n * from which this record was created has a mapper.\n * @return {Object} Plain object representation of this record.\n */\n toJSON (opts) {\n const mapper = this.constructor.mapper\n if (mapper) {\n return mapper.toJSON(this, opts)\n } else {\n const json = {}\n utils.forOwn(this, function (prop, key) {\n json[key] = utils.copy(prop)\n })\n return json\n }\n },\n\n /**\n * Unset the value for a given key.\n *\n * @name Record#unset\n * @method\n * @param {string} key - Key to unset.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n unset (key, opts) {\n this.set(key, undefined, opts)\n },\n\n validate (opts) {\n return this._mapper().validate(this, opts)\n }\n})\n\n/**\n * Allow records to emit events.\n *\n * An record's registered listeners are stored in the record's private data.\n */\nutils.eventify(\n Record.prototype,\n function () {\n return this._get('events')\n },\n function (value) {\n this._set('events', value)\n }\n)\n\nexport default Record\n","import utils from './utils'\nimport Component from './Component'\n\n/**\n * TODO\n *\n * @name Schema.types\n * @type {Object}\n */\nconst types = {\n array: utils.isArray,\n boolean: utils.isBoolean,\n integer: utils.isInteger,\n 'null': utils.isNull,\n number: utils.isNumber,\n object: utils.isObject,\n string: utils.isString\n}\n\n/**\n * @ignore\n */\nconst segmentToString = function (segment, prev) {\n let str = ''\n if (segment) {\n if (utils.isNumber(segment)) {\n str += `[${segment}]`\n } else if (prev) {\n str += `.${segment}`\n } else {\n str += `${segment}`\n }\n }\n return str\n}\n\n/**\n * @ignore\n */\nconst makePath = function (opts) {\n opts || (opts = {})\n let path = ''\n const segments = opts.path || []\n segments.forEach(function (segment) {\n path += segmentToString(segment, path)\n })\n path += segmentToString(opts.prop, path)\n return path\n}\n\n/**\n * @ignore\n */\nconst makeError = function (actual, expected, opts) {\n return {\n expected,\n actual: '' + actual,\n path: makePath(opts)\n }\n}\n\n/**\n * @ignore\n */\nconst addError = function (actual, expected, opts, errors) {\n errors.push(makeError(actual, expected, opts))\n}\n\n/**\n * @ignore\n */\nconst maxLengthCommon = function (keyword, value, schema, opts) {\n const max = schema[keyword]\n if (value.length > max) {\n return makeError(value.length, `length no more than ${max}`, opts)\n }\n}\n\n/**\n * @ignore\n */\nconst minLengthCommon = function (keyword, value, schema, opts) {\n const min = schema[keyword]\n if (value.length < min) {\n return makeError(value.length, `length no less than ${min}`, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name Schema.validationKeywords\n * @type {Object}\n */\nconst validationKeywords = {\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor82\n *\n * @name Schema.validationKeywords.allOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n allOf (value, schema, opts) {\n let allErrors = []\n schema.allOf.forEach(function (_schema) {\n allErrors = allErrors.concat(validate(value, _schema, opts) || [])\n })\n return allErrors.length ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor85\n *\n * @name Schema.validationKeywords.anyOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n anyOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.anyOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor70\n *\n * @name Schema.validationKeywords.dependencies\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n dependencies (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor76\n *\n * @name Schema.validationKeywords.enum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n enum (value, schema, opts) {\n const possibleValues = schema['enum']\n if (possibleValues.indexOf(value) === -1) {\n return makeError(value, `one of (${possibleValues.join(', ')})`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor37\n *\n * @name Schema.validationKeywords.items\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n items (value, schema, opts) {\n opts || (opts = {})\n // TODO: additionalItems\n let items = schema.items\n let errors = []\n const checkingTuple = utils.isArray(items)\n const length = value.length\n for (var prop = 0; prop < length; prop++) {\n if (checkingTuple) {\n // Validating a tuple, instead of just checking each item against the\n // same schema\n items = schema.items[prop]\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], items, opts) || [])\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor17\n *\n * @name Schema.validationKeywords.maximum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maximum (value, schema, opts) {\n // Must be a number\n const maximum = schema.maximum\n // Must be a boolean\n // Depends on maximum\n // default: false\n const exclusiveMaximum = schema.exclusiveMaximum\n if (typeof value === typeof maximum && (exclusiveMaximum ? maximum < value : maximum <= value)) {\n // TODO: Account for value of exclusiveMaximum in messaging\n return makeError(value, `no more than ${maximum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.maxItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxItems (value, schema, opts) {\n return maxLengthCommon('maxItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor26\n *\n * @name Schema.validationKeywords.maxLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxLength (value, schema, opts) {\n return maxLengthCommon('maxLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor54\n *\n * @name Schema.validationKeywords.maxProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxProperties (value, schema, opts) {\n const maxProperties = schema.maxProperties\n const length = Object.keys(value).length\n if (length > maxProperties) {\n return makeError(length, `no more than ${maxProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor21\n *\n * @name Schema.validationKeywords.minimum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minimum (value, schema, opts) {\n // Must be a number\n const minimum = schema.minimum\n // Must be a boolean\n // Depends on minimum\n // default: false\n const exclusiveMinimum = schema.exclusiveMinimum\n if (typeof value === typeof minimum && (exclusiveMinimum ? minimum > value : minimum >= value)) {\n // TODO: Account for value of exclusiveMinimum in messaging\n return makeError(value, `no less than ${minimum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.minItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minItems (value, schema, opts) {\n return minLengthCommon('minItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor29\n *\n * @name Schema.validationKeywords.minLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minLength (value, schema, opts) {\n return minLengthCommon('minLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor57\n *\n * @name Schema.validationKeywords.minProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minProperties (value, schema, opts) {\n const minProperties = schema.minProperties\n const length = Object.keys(value).length\n if (length < minProperties) {\n return makeError(length, `no more than ${minProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor14\n *\n * @name Schema.validationKeywords.multipleOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n multipleOf (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor91\n *\n * @name Schema.validationKeywords.not\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n not (value, schema, opts) {\n if (!validate(value, schema.not, opts)) {\n // TODO: better messaging\n return makeError('succeeded', 'should have failed', opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor88\n *\n * @name Schema.validationKeywords.oneOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n oneOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.oneOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else if (validated) {\n allErrors = [makeError('valid against more than one', 'valid against only one', opts)]\n validated = false\n return false\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor33\n *\n * @name Schema.validationKeywords.pattern\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n pattern (value, schema, opts) {\n const pattern = schema.pattern\n if (utils.isString(value) && !value.match(pattern)) {\n return makeError(value, pattern, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor64\n *\n * @name Schema.validationKeywords.properties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n properties (value, schema, opts) {\n opts || (opts = {})\n // Can be a boolean or an object\n // Technically the default is an \"empty schema\", but here \"true\" is\n // functionally the same\n const additionalProperties = utils.isUndefined(schema.additionalProperties) ? true : schema.additionalProperties\n // \"s\": The property set of the instance to validate.\n const toValidate = {}\n // \"p\": The property set from \"properties\".\n // Default is an object\n const properties = schema.properties || {}\n // \"pp\": The property set from \"patternProperties\".\n // Default is an object\n const patternProperties = schema.patternProperties || {}\n let errors = []\n\n // Collect set \"s\"\n utils.forOwn(value, function (_value, prop) {\n toValidate[prop] = undefined\n })\n // Remove from \"s\" all elements of \"p\", if any.\n utils.forOwn(properties || {}, function (_schema, prop) {\n if (utils.isUndefined(value[prop]) && !utils.isUndefined(_schema['default'])) {\n value[prop] = utils.copy(_schema['default'])\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n })\n // For each regex in \"pp\", remove all elements of \"s\" which this regex\n // matches.\n utils.forOwn(patternProperties, function (_schema, pattern) {\n utils.forOwn(toValidate, function (undef, prop) {\n if (prop.match(pattern)) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n }\n })\n })\n const keys = Object.keys(toValidate)\n // If \"s\" is not empty, validation fails\n if (additionalProperties === false) {\n if (keys.length) {\n addError(`extra fields: ${keys.join(', ')}`, 'no extra fields', opts, errors)\n }\n } else if (utils.isObject(additionalProperties)) {\n // Otherwise, validate according to provided schema\n keys.forEach(function (prop) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], additionalProperties, opts) || [])\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor61\n *\n * @name Schema.validationKeywords.required\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n required (value, schema, opts) {\n const required = schema.required\n let errors = []\n if (!opts.existingOnly) {\n required.forEach(function (prop) {\n if (utils.isUndefined(utils.get(value, prop))) {\n const prevProp = opts.prop\n opts.prop = prop\n addError(undefined, 'a value', opts, errors)\n opts.prop = prevProp\n }\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor79\n *\n * @name Schema.validationKeywords.type\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n type (value, schema, opts) {\n let type = schema.type\n let validType\n // Can be one of several types\n if (utils.isString(type)) {\n type = [type]\n }\n // Try to match the value against an expected type\n type.forEach(function (_type) {\n // TODO: throw an error if type is not defined\n if (types[_type](value, schema, opts)) {\n // Matched a type\n validType = _type\n return false\n }\n })\n // Value did not match any expected type\n if (!validType) {\n return makeError(value ? typeof value : '' + value, `one of (${type.join(', ')})`, opts)\n }\n // Run keyword validators for matched type\n // http://json-schema.org/latest/json-schema-validation.html#anchor12\n const validator = typeGroupValidators[validType]\n if (validator) {\n return validator(value, schema, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor49\n *\n * @name Schema.validationKeywords.uniqueItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n uniqueItems (value, schema, opts) {\n if (value && value.length && schema.uniqueItems) {\n const length = value.length\n let item, i, j\n // Check n - 1 items\n for (i = length - 1; i > 0; i--) {\n item = value[i]\n // Only compare against unchecked items\n for (j = i - 1; j >= 0; j--) {\n // Found a duplicate\n if (item === value[j]) {\n return makeError(item, 'no duplicates', opts)\n }\n }\n }\n }\n }\n}\n\n/**\n * @ignore\n */\nconst validateKeyword = function (op, value, schema, opts) {\n return !utils.isUndefined(schema[op]) && validationKeywords[op](value, schema, opts)\n}\n\n/**\n * @ignore\n */\nconst runOps = function (ops, value, schema, opts) {\n let errors = []\n ops.forEach(function (op) {\n errors = errors.concat(validateKeyword(op, value, schema, opts) || [])\n })\n return errors.length ? errors : undefined\n}\n\nconst ANY_OPS = ['enum', 'type', 'allOf', 'anyOf', 'oneOf', 'not']\nconst ARRAY_OPS = ['items', 'maxItems', 'minItems', 'uniqueItems']\nconst NUMERIC_OPS = ['multipleOf', 'maximum', 'minimum']\nconst OBJECT_OPS = ['maxProperties', 'minProperties', 'required', 'properties', 'dependencies']\nconst STRING_OPS = ['maxLength', 'minLength', 'pattern']\n\n/**\n * http://json-schema.org/latest/json-schema-validation.html#anchor75\n * @ignore\n */\nconst validateAny = function (value, schema, opts) {\n return runOps(ANY_OPS, value, schema, opts)\n}\n\n/**\n * TODO\n *\n * @name Schema.validate\n * @method\n * @param {*} value TODO\n * @param {Object} [schema] TODO\n * @param {Object} [opts] Configuration options.\n */\nconst validate = function (value, schema, opts) {\n let errors = []\n opts || (opts = {})\n let shouldPop\n let prevProp = opts.prop\n if (utils.isUndefined(schema)) {\n return\n }\n if (!utils.isObject(schema)) {\n throw new Error(`Invalid schema at path: \"${opts.path}\"`)\n }\n if (utils.isUndefined(opts.path)) {\n opts.path = []\n }\n // Track our location as we recurse\n if (!utils.isUndefined(opts.prop)) {\n shouldPop = true\n opts.path.push(opts.prop)\n opts.prop = undefined\n }\n // Validate against parent schema\n if (schema['extends']) {\n // opts.path = path\n // opts.prop = prop\n if (utils.isFunction(schema['extends'].validate)) {\n errors = errors.concat(schema['extends'].validate(value, opts) || [])\n } else {\n errors = errors.concat(validate(value, schema['extends'], opts) || [])\n }\n }\n if (utils.isUndefined(value)) {\n // Check if property is required\n if (schema.required === true) {\n addError(value, 'a value', opts, errors)\n }\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n }\n errors = errors.concat(validateAny(value, schema, opts) || [])\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n}\n\n// These strings are cached for optimal performance of the change detection\n// boolean - Whether a Record is changing in the current execution frame\nconst changingPath = 'changing'\n// string[] - Properties that have changed in the current execution frame\nconst changedPath = 'changed'\n// boolean - Whether a Record is currently being instantiated\nconst creatingPath = 'creating'\n// number - The setTimeout change event id of a Record, if any\nconst eventIdPath = 'eventId'\n// boolean - Whether to skip validation for a Record's currently changing property\nconst noValidatePath = 'noValidate'\n// boolean - Whether to skip change notification for a Record's currently\n// changing property\nconst silentPath = 'silent'\nconst validationFailureMsg = 'validation failed'\n\n/**\n * Assemble a property descriptor which will be added to the prototype of\n * {@link Mapper#recordClass}. This method is called when\n * {@link Mapper#applySchema} is set to `true`.\n *\n * TODO: Make this more configurable, i.e. not so tied to the Record class.\n *\n * @ignore\n */\nconst makeDescriptor = function (prop, schema, opts) {\n const descriptor = {\n // These properties are enumerable by default, but regardless of their\n // enumerability, they won't be \"own\" properties of individual records\n enumerable: utils.isUndefined(schema.enumerable) ? true : !!schema.enumerable\n }\n // Cache a few strings for optimal performance\n const keyPath = `props.${prop}`\n const previousPath = `previous.${prop}`\n const getter = opts.getter\n const setter = opts.setter\n const unsetter = opts.unsetter\n\n descriptor.get = function () { return this._get(keyPath) }\n descriptor.set = function (value) {\n const self = this\n // These are accessed a lot\n const _get = self[getter]\n const _set = self[setter]\n const _unset = self[unsetter]\n\n // Optionally check that the new value passes validation\n if (!_get(noValidatePath)) {\n const errors = schema.validate(value)\n if (errors) {\n // Immediately throw an error, preventing the record from getting into\n // an invalid state\n const error = new Error(validationFailureMsg)\n error.errors = errors\n throw error\n }\n }\n // TODO: Make it so tracking can be turned on for all properties instead of\n // only per-property\n if (schema.track && !_get(creatingPath)) {\n const previous = _get(previousPath)\n const current = _get(keyPath)\n let changing = _get(changingPath)\n let changed = _get(changedPath)\n\n if (!changing) {\n // Track properties that are changing in the current event loop\n changed = []\n }\n\n // Add changing properties to this array once at most\n const index = changed.indexOf(prop)\n if (current !== value && index === -1) {\n changed.push(prop)\n }\n if (previous === value) {\n if (index >= 0) {\n changed.splice(index, 1)\n }\n }\n // No changes in current event loop\n if (!changed.length) {\n changing = false\n _unset(changingPath)\n _unset(changedPath)\n // Cancel pending change event\n if (_get(eventIdPath)) {\n clearTimeout(_get(eventIdPath))\n _unset(eventIdPath)\n }\n }\n // Changes detected in current event loop\n if (!changing && changed.length) {\n _set(changedPath, changed)\n _set(changingPath, true)\n // Saving the timeout id allows us to batch all changes in the same\n // event loop into a single \"change\"\n // TODO: Optimize\n _set(eventIdPath, setTimeout(() => {\n // Previous event loop where changes were gathered has ended, so\n // notify any listeners of those changes and prepare for any new\n // changes\n _unset(changedPath)\n _unset(eventIdPath)\n _unset(changingPath)\n // TODO: Optimize\n if (!_get(silentPath)) {\n let i\n for (i = 0; i < changed.length; i++) {\n self.emit('change:' + changed[i], self, utils.get(self, changed[i]))\n }\n self.emit('change', self, self.changes())\n }\n _unset(silentPath)\n }, 0))\n }\n }\n _set(keyPath, value)\n return value\n }\n\n return descriptor\n}\n\n/**\n * TODO\n *\n * @name Schema.typeGroupValidators\n * @type {Object}\n */\nconst typeGroupValidators = {\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.array\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n array: function (value, schema, opts) {\n return runOps(ARRAY_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.integer\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n integer: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.number\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n number: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor13.\n *\n * @name Schema.typeGroupValidators.numeric\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n numeric: function (value, schema, opts) {\n return runOps(NUMERIC_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor53.\n *\n * @name Schema.typeGroupValidators.object\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n object: function (value, schema, opts) {\n return runOps(OBJECT_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor25.\n *\n * @name Schema.typeGroupValidators.string\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n string: function (value, schema, opts) {\n return runOps(STRING_OPS, value, schema, opts)\n }\n}\n\n/**\n * js-data's Schema class.\n *\n * ```javascript\n * import {Schema} from 'js-data'\n * ```\n *\n * @class Schema\n * @extends Component\n * @param {Object} definition Schema definition according to json-schema.org\n */\nexport default Component.extend({\n constructor: function Schema (definition) {\n // const self = this\n definition || (definition = {})\n // TODO: schema validation\n utils.fillIn(this, definition)\n\n // TODO: rework this to make sure all possible keywords are converted\n if (definition.properties) {\n utils.forOwn(definition.properties, function (_definition, prop) {\n if (!(_definition instanceof Schema)) {\n definition.properties[prop] = new Schema(_definition)\n }\n })\n }\n },\n\n /**\n * This adds ES5 getters/setters to the target based on the \"properties\" in\n * this Schema, which makes possible change tracking and validation on\n * property assignment.\n *\n * @name Schema#validate\n * @method\n * @param {Object} target The prototype to which to apply this schema.\n */\n apply (target, opts) {\n opts || (opts = {})\n opts.getter = opts.getter || '_get'\n opts.setter = opts.setter || '_set'\n opts.unsetter = opts.unsetter || '_unset'\n const properties = this.properties || {}\n utils.forOwn(properties, function (schema, prop) {\n Object.defineProperty(\n target,\n prop,\n makeDescriptor(prop, schema, opts)\n )\n })\n },\n\n /**\n * Validate the provided value against this schema.\n *\n * @name Schema#validate\n * @method\n * @param {*} value Value to validate.\n * @param {Object} [opts] Configuration options.\n * @return {(array|undefined)} Array of errors or `undefined` if valid.\n */\n validate (value, opts) {\n return validate(value, this, opts)\n }\n}, {\n typeGroupValidators,\n types,\n validate,\n validationKeywords\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Record from './Record'\nimport Schema from './Schema'\nimport {\n belongsTo,\n belongsToType,\n hasMany,\n hasManyType,\n hasOne,\n hasOneType\n} from './decorators'\n\nconst makeNotify = function (num) {\n return function (...args) {\n const self = this\n const opts = args[args.length - num]\n self.dbg(opts.op, ...args)\n if (opts.notify || (opts.notify === undefined && self.notify)) {\n setTimeout(() => {\n self.emit(opts.op, ...args)\n })\n }\n }\n}\n\n// These are the default implementations of all of the lifecycle hooks\nconst notify = makeNotify(1)\nconst notify2 = makeNotify(2)\n\n// This object provides meta information used by Mapper#crud to actually\n// execute each lifecycle method\nconst LIFECYCLE_METHODS = {\n count: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroy: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroyAll: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n find: {\n defaults: [undefined, {}],\n types: []\n },\n findAll: {\n defaults: [{}, {}],\n types: []\n },\n sum: {\n defaults: [undefined, {}, {}],\n skip: true,\n types: []\n },\n update: {\n adapterArgs (mapper, id, props, opts) {\n return [id, mapper.toJSON(props, opts), opts]\n },\n beforeAssign: 1,\n defaults: [undefined, {}, {}],\n types: []\n },\n updateAll: {\n adapterArgs (mapper, props, query, opts) {\n return [mapper.toJSON(props, opts), query, opts]\n },\n beforeAssign: 0,\n defaults: [{}, {}, {}],\n types: []\n },\n updateMany: {\n adapterArgs (mapper, records, opts) {\n return [records.map(function (record) {\n return mapper.toJSON(record, opts)\n }), opts]\n },\n beforeAssign: 0,\n defaults: [[], {}],\n types: []\n }\n}\n\nconst MAPPER_DEFAULTS = {\n /**\n * Hash of registered adapters. Don't modify directly. Use {@link Mapper#registerAdapter}.\n *\n * @name Mapper#_adapters\n */\n _adapters: {},\n\n /**\n * Whether to augment {@link Mapper#recordClass} with getter/setter property\n * accessors according to the properties defined in {@link Mapper#schema}.\n * This makes possible validation and change tracking on individual properties\n * when using the dot (e.g. `user.name = \"Bob\"`) operator to modify a\n * property.\n *\n * @name Mapper#applySchema\n * @type {boolean}\n * @default true\n */\n applySchema: true,\n\n /**\n * Whether to enable debug-level logs.\n *\n * @name Mapper#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * The name of the registered adapter that this Mapper should used by default.\n *\n * @name Mapper#defaultAdapter\n * @type {string}\n * @default \"http\"\n */\n defaultAdapter: 'http',\n\n /**\n * The field used as the unique identifier on records handled by this Mapper.\n *\n * @name Mapper#idAttribute\n * @type {string}\n * @default id\n */\n idAttribute: 'id',\n\n /**\n * Whether this Mapper should emit operational events.\n *\n * Defaults to `true` in the browser and `false` in Node.js\n *\n * @name Mapper#notify\n * @type {boolean}\n */\n notify: utils.isBrowser,\n\n /**\n * Whether {@link Mapper#create}, {@link Mapper#createMany}, {@link Mapper#save},\n * {@link Mapper#update}, {@link Mapper#updateAll}, {@link Mapper#updateMany},\n * {@link Mapper#find}, {@link Mapper#findAll}, {@link Mapper#destroy}, and\n * {@link Mapper#destroyAll} should return a raw result object that contains\n * both the instance data returned by the adapter _and_ metadata about the\n * operation.\n *\n * The default is to NOT return the result object, and instead return just the\n * instance data.\n *\n * @name Mapper#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * ```javascript\n * import {Mapper} from 'js-data'\n * ```\n *\n * The core of JSData's [ORM/ODM][orm] implementation. Given a minimum amout of\n * meta information about a resource, a Mapper can perform generic CRUD\n * operations against that resource. Apart from its configuration, a Mapper is\n * stateless. The particulars of various persistence layers has been abstracted\n * into adapters, which a Mapper uses to perform its operations.\n *\n * The term \"Mapper\" comes from the [Data Mapper Pattern][pattern] described in\n * Martin Fowler's [Patterns of Enterprise Application Architecture][book]. A\n * Data Mapper moves data between [in-memory object instances][record] and a\n * relational or document-based database. JSData's Mapper can work with any\n * persistence layer you can write an adapter for.\n *\n * _(\"Model\" is a heavily overloaded term and is avoided in this documentation\n * to prevent confusion.)_\n *\n * [orm]: https://en.wikipedia.org/wiki/Object-relational_mapping\n * [pattern]: https://en.wikipedia.org/wiki/Data_mapper_pattern\n * [book]: http://martinfowler.com/books/eaa.html\n * [record]: Record.html\n *\n * @class Mapper\n * @extends Component\n * @param {Object} opts Configuration options.\n * @param {boolean} [opts.applySchema=true] Whether to apply this Mapper's\n * {@link Schema} to the prototype of this Mapper's Record class. The enables\n * features like active change detection, validation during use of the\n * assignment operator, etc.\n * @param {boolean} [opts.debug=false] Wether to log debugging information\n * during operation.\n * @param {string} [opts.defaultAdapter=http] The name of the adapter to use by\n * default.\n * @param {string} [opts.idAttribute=id] The field that uniquely identifies\n * Records that this Mapper will be dealing with. Typically called a primary\n * key.\n * @param {string} opts.name The name for this Mapper. This is the minimum\n * amount of meta information required for a Mapper to be able to execute CRUD\n * operations for a \"Resource\".\n * @param {boolean} [opts.notify] Whether to emit lifecycle events.\n * @param {boolean} [opts.raw=false] Whether lifecycle methods should return a\n * more detailed reponse object instead of just a Record instance or Record\n * instances.\n */\nexport default Component.extend({\n constructor: function Mapper (opts) {\n const self = this\n utils.classCallCheck(self, Mapper)\n Mapper.__super__.call(self)\n opts || (opts = {})\n\n // Prepare certain properties to be non-enumerable\n Object.defineProperties(self, {\n _adapters: {\n value: undefined,\n writable: true\n },\n\n /**\n * Set the `false` to force the Mapper to work with POJO objects only.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * const UserMapper = new Mapper({ recordClass: false })\n * UserMapper.recordClass // false\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * ```\n *\n * Set to a custom class to have records wrapped in your custom class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User {\n * constructor (props = {}) {\n * for (var key in props) {\n * if (props.hasOwnProperty(key)) {\n * this[key] = props[key]\n * }\n * }\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * user instanceof User // true\n * ```\n *\n * Extend the {@link Record} class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User extends Record {\n * constructor () {\n * super(props)\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // true\n * user instanceof User // true\n * ```\n *\n * @name Mapper#recordClass\n * @default {@link Record}\n */\n recordClass: {\n value: undefined,\n writable: true\n },\n\n lifecycleMethods: {\n value: LIFECYCLE_METHODS\n },\n\n schema: {\n value: undefined,\n writable: true\n }\n })\n\n // Apply user-provided configuration\n utils.fillIn(self, opts)\n // Fill in any missing options with the defaults\n utils.fillIn(self, utils.copy(MAPPER_DEFAULTS))\n\n /**\n * Minimum amount of meta information required for a Mapper to be able to\n * execute CRUD operations for a \"Resource\".\n *\n * @name Mapper#name\n * @type {string}\n */\n if (!self.name) {\n throw new Error('name is required!')\n }\n\n // Setup schema, with an empty default schema if necessary\n if (!(self.schema instanceof Schema)) {\n self.schema = new Schema(self.schema || {})\n }\n\n // Create a subclass of Record that's tied to this Mapper\n if (utils.isUndefined(self.recordClass)) {\n const superClass = Record\n self.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n\n if (self.recordClass) {\n self.recordClass.mapper = self\n\n // We can only apply the schema to the prototype of self.recordClass if the\n // class extends Record\n if (utils.getSuper(self.recordClass, true) === Record && self.schema && self.schema.apply && self.applySchema) {\n self.schema.apply(self.recordClass.prototype)\n }\n }\n },\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n * @param {*} result The result, if any.\n */\n afterCount: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n * @param {*} result The result, if any.\n */\n afterCreate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n * @param {*} result The result, if any.\n */\n afterCreateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n * @param {*} result The result, if any.\n */\n afterDestroy: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroyAll\n * @method\n * @param {*} data The `data` returned by the adapter.\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n * @param {*} result The result, if any.\n */\n afterDestroyAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n * @param {*} result The result, if any.\n */\n afterFind: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n * @param {*} result The result, if any.\n */\n afterFindAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterSum\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n * @param {*} result The result, if any.\n */\n afterSum: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n * @param {*} result The result, if any.\n */\n afterUpdate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n * @param {*} result The result, if any.\n */\n afterUpdateAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n * @param {*} result The result, if any.\n */\n afterUpdateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n */\n beforeCreate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n */\n beforeCreateMany: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n */\n beforeCount: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n */\n beforeDestroy: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroyAll\n * @method\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n */\n beforeDestroyAll: notify,\n\n /**\n * Mappers lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n */\n beforeFind: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n */\n beforeFindAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeSum\n * @method\n * @param {string} field The `field` argument passed to {@link Mapper#sum}.\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n */\n beforeSum: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n */\n beforeUpdate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n */\n beforeUpdateAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n */\n beforeUpdateMany: notify,\n\n /**\n * This method is called at the end of most lifecycle methods. It does the\n * following:\n *\n * 1. If `opts.raw` is `true`, add this Mapper's configuration to the `opts`\n * argument as metadata for the operation.\n * 2. Wrap the result data appropriately using {@link Mapper#wrap}, which\n * calls {@link Mapper#createRecord}.\n *\n * @name Mapper#_end\n * @method\n * @private\n */\n _end (result, opts, skip) {\n const self = this\n if (opts.raw) {\n utils._(result, opts)\n }\n if (skip) {\n return result\n }\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(self.wrap)) {\n _data = self.wrap(_data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Define a belongsTo relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * Post.belongsTo(User, {\n * localKey: 'myUserId'\n * })\n *\n * Comment.belongsTo(User)\n * Comment.belongsTo(Post, {\n * localField: '_post'\n * })\n * ```\n *\n * @name Mapper#belongsTo\n * @method\n */\n belongsTo (relatedMapper, opts) {\n return belongsTo(relatedMapper, opts)(this)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeCount} will be called before calling the adapter.\n * {@link Mapper#afterCount} will be called after calling the adapter.\n *\n * @name Mapper#count\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n count (query, opts) {\n return this.crud('count', query, opts)\n },\n\n /**\n * Create and save a new the record using the provided `props`.\n *\n * {@link Mapper#beforeCreate} will be called before calling the adapter.\n * {@link Mapper#afterCreate} will be called after calling the adapter.\n *\n * @name Mapper#create\n * @method\n * @param {Object} props The properties for the new record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * created data. If `true` return a response object that includes the created\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `props` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#create}\n * or {@link Mapper#createMany} call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n create (props, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n props || (props = {})\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n const relatedMapper = def.getRelation()\n const relatedIdAttribute = relatedMapper.idAttribute\n optsCopy.raw = false\n if (!relationData) {\n return\n }\n if (def.type === belongsToType) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(relatedMapper.create(relationData, optsCopy).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n def.setForeignKey(props, data)\n }))\n } else if (def.type === hasManyType && def.localKeys) {\n // Create his hasMany relation first because it uses localKeys\n tasks.push(relatedMapper.createMany(relationData, optsCopy)).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n utils.set(props, def.localKeys, data.map(function (record) {\n return utils.get(record, relatedIdAttribute)\n }))\n })\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter for the main create\n op = opts.op = 'create'\n self.dbg(op, props, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, self.toJSON(props, { with: opts.pass || [] }), opts))\n }).then(function (data) {\n const createdRecord = opts.raw ? data.data : data\n // Deep post-create hasMany and hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n if (!relationData) {\n return\n }\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType && def.foreignKey) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, opts.raw ? data.data : data)\n })\n } else if (def.type === hasOneType) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().create(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, opts.raw ? data.data : data)\n })\n } else if (def.type === belongsToType && def.getLocalField(belongsToRelationData)) {\n def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData))\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](props, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n createInstance (props, opts) {\n return this.createRecord(props, opts)\n },\n\n /**\n * Given an array of records, batch create them via an adapter.\n *\n * {@link Mapper#beforeCreateMany} will be called before calling the adapter.\n * {@link Mapper#afterCreateMany} will be called after calling the adapter.\n *\n * @name Mapper#createMany\n * @method\n * @param {Array} records Array of records to be created in one batch.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `records` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#createMany}\n * call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n createMany (records, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (def.type === belongsToType && relationData.length === records.length) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedRecords = optsCopy.raw ? data.data : data\n def.setLocalField(belongsToRelationData, relatedRecords)\n records.forEach(function (record, i) {\n def.setForeignKey(record, relatedRecords[i])\n })\n }))\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter\n op = opts.op = 'createMany'\n const json = records.map(function (record) {\n return self.toJSON(record, { with: opts.pass || [] })\n })\n self.dbg(op, records, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, json, opts))\n }).then(function (data) {\n const createdRecords = opts.raw ? data.data : data\n\n // Deep post-create hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (relationData.length !== records.length) {\n return\n }\n const belongsToData = def.getLocalField(belongsToRelationData)\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType) {\n // Not supported\n self.log('warn', 'deep createMany of hasMany type not supported!')\n } else if (def.type === hasOneType) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setForeignKey(createdRecord, relationData[i])\n })\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedData = opts.raw ? data.data : data\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, relatedData[i])\n })\n })\n } else if (def.type === belongsToType && belongsToData && belongsToData.length === createdRecords.length) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, belongsToData[i])\n })\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](records, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Create an unsaved, uncached instance of this Mapper's\n * {@link Mapper#recordClass}.\n *\n * Returns `props` if `props` is already an instance of\n * {@link Mapper#recordClass}.\n *\n * @name Mapper#createRecord\n * @method\n * @param {Object|Array} props The properties for the Record instance or an\n * array of property objects for the Record instances.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation when\n * the Record instances are created.\n * @return {Object|Array} The Record instance or Record instances.\n */\n createRecord (props, opts) {\n props || (props = {})\n const self = this\n if (utils.isArray(props)) {\n return props.map(function (_props) {\n return self.createRecord(_props, opts)\n })\n }\n if (!utils.isObject(props)) {\n throw new Error('Cannot create a record from ' + props + '!')\n }\n const recordClass = self.recordClass\n const relationList = self.relationList || []\n relationList.forEach(function (def) {\n const relatedMapper = def.getRelation()\n const relationData = def.getLocalField(props)\n if (relationData && !relatedMapper.is(relationData)) {\n if (utils.isArray(relationData) && (!relationData.length || relatedMapper.is(relationData[0]))) {\n return\n }\n utils.set(props, def.localField, relatedMapper.createRecord(relationData, opts))\n }\n })\n // Check to make sure \"props\" is not already an instance of this Mapper.\n return recordClass ? (props instanceof recordClass ? props : new recordClass(props, opts)) : props // eslint-disable-line\n },\n\n /**\n * Lifecycle invocation method.\n *\n * @name Mapper#crud\n * @method\n * @param {string} method Name of the lifecycle method to invoke.\n * @param {...*} args Arguments to pass to the lifecycle method.\n * @return {Promise}\n */\n crud (method, ...args) {\n const self = this\n const config = self.lifecycleMethods[method]\n if (!config) {\n throw new Error(`${method}: No such CRUD method!`)\n }\n\n const upper = `${method.charAt(0).toUpperCase()}${method.substr(1)}`\n const before = `before${upper}`\n const after = `after${upper}`\n\n let op, adapter\n\n // Default values for arguments\n config.defaults.forEach(function (value, i) {\n if (utils.isUndefined(args[i])) {\n args[i] = utils.copy(value)\n }\n })\n\n const opts = args[args.length - 1]\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // before lifecycle hook\n op = opts.op = before\n return utils.resolve(self[op](...args)).then(function (_value) {\n if (!utils.isUndefined(config.beforeAssign)) {\n // Allow for re-assignment from lifecycle hook\n args[config.beforeAssign] = utils.isUndefined(_value) ? args[config.beforeAssign] : _value\n }\n // Now delegate to the adapter\n op = opts.op = method\n args = config.adapterArgs ? config.adapterArgs(self, ...args) : args\n self.dbg(op, ...args)\n return utils.resolve(self.getAdapter(adapter)[op](self, ...args))\n }).then(function (result) {\n result = self._end(result, opts, !!config.skip)\n args.push(result)\n // after lifecycle hook\n op = opts.op = after\n return utils.resolve(self[op](...args)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Using an adapter, destroy the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeDestroy} will be called before destroying the record.\n * {@link Mapper#afterDestroy} will be called after destroying the record.\n *\n * @name Mapper#destroy\n * @method\n * @param {(string|number)} id The primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroy (id, opts) {\n return this.crud('destroy', id, opts)\n },\n\n /**\n * Using the `query` argument, destroy the selected records via an adapter.\n * If no `query` is provided then all records will be destroyed.\n *\n * {@link Mapper#beforeDestroyAll} will be called before destroying the records.\n * {@link Mapper#afterDestroyAll} will be called after destroying the records.\n *\n * @name Mapper#destroyAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroyAll (query, opts) {\n return this.crud('destroyAll', query, opts)\n },\n\n /**\n * Retrieve via an adapter the record with the given primary key.\n *\n * {@link Mapper#beforeFind} will be called before calling the adapter.\n * {@link Mapper#afterFind} will be called after calling the adapter.\n *\n * @name Mapper#find\n * @method\n * @param {(string|number)} id The primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n find (id, opts) {\n return this.crud('find', id, opts)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeFindAll} will be called before calling the adapter.\n * {@link Mapper#afterFindAll} will be called after calling the adapter.\n *\n * @name Mapper#findAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n findAll (query, opts) {\n return this.crud('findAll', query, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Mapper#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n self.dbg('getAdapter', 'name:', name)\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw new ReferenceError(`${adapter} not found!`)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Mapper#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || opts.defaultAdapter\n },\n\n /**\n * @name Mapper#getAdapters\n * @method\n * @return {Object} This Mapper's adapters\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Returns this Mapper's schema.\n *\n * @return {Schema} This Mapper's schema.\n */\n getSchema () {\n return this.schema\n },\n\n /**\n * Defines a hasMany relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasMany(Post, {\n * localField: 'my_posts'\n * })\n * ```\n *\n * @name Mapper#hasMany\n * @method\n */\n hasMany (relatedMapper, opts) {\n return hasMany(relatedMapper, opts)(this)\n },\n\n /**\n * Defines a hasOne relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasOne(Profile, {\n * localField: '_profile'\n * })\n * ```\n *\n * @name Mapper#hasOne\n * @method\n */\n hasOne (relatedMapper, opts) {\n return hasOne(relatedMapper, opts)(this)\n },\n\n /**\n * Return whether `record` is an instance of this Mapper's recordClass.\n *\n * @name Mapper#is\n * @method\n * @param {Object} record The record to check.\n * @return {boolean} Whether `record` is an instance of this Mapper's\n * {@link Mapper#recordClass}.\n */\n is (record) {\n const recordClass = this.recordClass\n return recordClass ? record instanceof recordClass : false\n },\n\n /**\n * Register an adapter on this mapper under the given name.\n *\n * @name Mapper#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for this Mapper.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.defaultAdapter = name\n }\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeSum} will be called before calling the adapter.\n * {@link Mapper#afterSum} will be called after calling the adapter.\n *\n * @name Mapper#sum\n * @method\n * @param {string} field The field to sum.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n sum (field, query, opts) {\n return this.crud('sum', field, query, opts)\n },\n\n /**\n * Return a plain object representation of the given record.\n *\n * @name Mapper#toJSON\n * @method\n * @param {Object} record Record from which to create a plain object\n * representation.\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation.\n * @return {Object} Plain object representation of the record.\n */\n toJSON (record, opts) {\n const self = this\n opts || (opts = {})\n const relationFields = (self ? self.relationFields : []) || []\n let json = {}\n let properties\n if (self && self.schema) {\n properties = self.schema.properties || {}\n // TODO: Make this work recursively\n utils.forOwn(properties, function (opts, prop) {\n json[prop] = utils.plainCopy(record[prop])\n })\n }\n properties || (properties = {})\n if (!opts.strict) {\n for (var key in record) {\n if (!properties[key] && relationFields.indexOf(key) === -1) {\n json[key] = utils.plainCopy(record[key])\n }\n }\n }\n // The user wants to include relations in the resulting plain object\n // representation\n if (self && opts.withAll) {\n opts.with = relationFields.slice()\n }\n if (self && opts.with) {\n if (utils.isString(opts.with)) {\n opts.with = [opts.with]\n }\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(record)\n if (relationData) {\n // The actual recursion\n if (utils.isArray(relationData)) {\n def.setLocalField(json, relationData.map(function (item) {\n return def.getRelation().toJSON(item, optsCopy)\n }))\n } else {\n def.setLocalField(json, def.getRelation().toJSON(relationData, optsCopy))\n }\n }\n })\n }\n return json\n },\n\n /**\n * Using an adapter, update the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeUpdate} will be called before updating the record.\n * {@link Mapper#afterUpdate} will be called after updating the record.\n *\n * @name Mapper#update\n * @method\n * @param {(string|number)} id The primary key of the record to update.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n update (id, props, opts) {\n return this.crud('update', id, props, opts)\n },\n\n /**\n * Using the `query` argument, perform the a single updated to the selected\n * records. Expects back from the adapter an array of the updated records.\n *\n * {@link Mapper#beforeUpdateAll} will be called before making the update.\n * {@link Mapper#afterUpdateAll} will be called after making the update.\n *\n * @name Mapper#updateAll\n * @method\n * @param {Object} props Update to apply to selected records.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n updateAll (props, query, opts) {\n return this.crud('updateAll', props, query, opts)\n },\n\n /**\n * Given an array of updates, perform each of the updates via an adapter. Each\n * \"update\" is a hash of properties with which to update an record. Each\n * update must contain the primary key to be updated.\n *\n * {@link Mapper#beforeUpdateMany} will be called before making the update.\n * {@link Mapper#afterUpdateMany} will be called after making the update.\n *\n * @name Mapper#updateMany\n * @method\n * @param {Array} records Array up record updates.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if each record update contains nested updates for relations. NOT\n * performed in a transaction.\n * @return {Promise}\n */\n updateMany (records, opts) {\n return this.crud('updateMany', records, opts)\n },\n\n /**\n * Validate the given record or records according to this Mapper's\n * {@link Schema}. No return value means no errors.\n *\n * @name Mapper#validate\n * @method\n * @param {Object|Array} record The record or records to validate.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Schema#validate}.\n * @return {Array} Array of errors or undefined if no errors.\n */\n validate (record, opts) {\n const self = this\n const schema = self.getSchema()\n if (!schema) {\n throw new Error(`${self.name} mapper has no schema!`)\n }\n if (utils.isArray(record)) {\n return record.map(function (_record) {\n return schema.validate(_record, opts)\n })\n } else if (utils.isObject(record)) {\n return schema.validate(record, opts)\n } else {\n throw new Error('not a record!')\n }\n },\n\n /**\n * Method used to wrap data returned by an adapter with this Mapper's Record\n * class.\n *\n * @name Mapper#wrap\n * @method\n * @param {Object|Array} data The data to be wrapped.\n * @param {Object} [opts] Configuration options. Passed to {@link Mapper#createRecord}.\n * @return {Object|Array}\n */\n wrap (data, opts) {\n return this.createRecord(data, opts)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Mapper from './Mapper'\n\nconst toProxy = [\n /**\n * Proxy for {@link Mapper#count}.\n *\n * @name Container#count\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.count}.\n * @param {Object} [opts] - Passed to {@link Model.count}.\n * @return {Promise}\n */\n 'count',\n\n /**\n * Proxy for {@link Mapper#create}.\n *\n * @name Container#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n 'create',\n\n /**\n * Proxy for {@link Mapper#createMany}.\n *\n * @name Container#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n 'createMany',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#createRecord\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} props Passed to {@link Mapper#createRecord}.\n * @param {Object} [opts] Passed to {@link Mapper#createRecord}. See\n * {@link Mapper#createRecord} for configuration options.\n * @return {Promise}\n */\n 'createRecord',\n\n /**\n * Proxy for {@link Mapper#dbg}.\n *\n * @name Container#dbg\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#dbg}.\n */\n 'dbg',\n\n /**\n * Proxy for {@link Mapper#destroy}.\n *\n * @name Container#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n 'destroy',\n\n /**\n * Proxy for {@link Mapper#destroyAll}.\n *\n * @name Container#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n 'destroyAll',\n\n /**\n * Proxy for {@link Mapper#find}.\n *\n * @name Container#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n 'find',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n 'findAll',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#getSchema\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n */\n 'getSchema',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#is\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#is}.\n */\n 'is',\n\n /**\n * Proxy for {@link Mapper#log}.\n *\n * @name Container#log\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#log}.\n */\n 'log',\n\n /**\n * Proxy for {@link Mapper#sum}.\n *\n * @name Container#sum\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {string} field - Passed to {@link Model.sum}.\n * @param {Object} [query] - Passed to {@link Model.sum}.\n * @param {Object} [opts] - Passed to {@link Model.sum}.\n * @return {Promise}\n */\n 'sum',\n\n /**\n * Proxy for {@link Mapper#toJSON}.\n *\n * @name Container#toJSON\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#toJSON}.\n */\n 'toJSON',\n\n /**\n * Proxy for {@link Mapper#update}.\n *\n * @name Container#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n 'update',\n\n /**\n * Proxy for {@link Mapper#updateAll}.\n *\n * @name Container#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object?} query - Passed to {@link Model.updateAll}.\n * @param {Object} props - Passed to {@link Model.updateAll}.\n * @param {Object} [opts] - Passed to {@link Model.updateAll}. See\n * {@link Model.updateAll} for more configuration options.\n * @return {Promise}\n */\n 'updateAll',\n\n /**\n * Proxy for {@link Mapper#updateMany}.\n *\n * @name Container#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n 'updateMany'\n]\n\nconst props = {\n constructor: function Container (opts) {\n const self = this\n utils.classCallCheck(self, Container)\n Container.__super__.call(self)\n opts || (opts = {})\n\n // Apply options provided by the user\n utils.fillIn(self, opts)\n /**\n * Defaults options to pass to {@link Container#mapperClass} when creating a\n * new mapper.\n *\n * @name Container#mapperDefaults\n * @type {Object}\n */\n self.mapperDefaults = self.mapperDefaults || {}\n /**\n * Constructor function to use in {@link Container#defineMapper} to create a\n * new mapper.\n *\n * @name Container#mapperClass\n * @type {Function}\n */\n self.mapperClass = self.mapperClass || Mapper\n\n // Initilize private data\n\n // Holds the adapters, shared by all mappers in this container\n self._adapters = {}\n // The the mappers in this container\n self._mappers = {}\n },\n\n /**\n * Register a new event listener on this Container.\n *\n * Proxy for {@link Component#on}. If an event was emitted by a Mapper in the\n * Container, then the name of the Mapper will be prepended to the arugments\n * passed to the listener.\n *\n * @name Container#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by mappers in this container.\n *\n * @name Container#_onMapperEvent\n * @method\n * @private\n * @param {string} name Name of the mapper that emitted the event.\n * @param {...*} [args] Args passed to {@link Mapper#emit}.\n */\n _onMapperEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * Create a new mapper and register it in this container.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container({\n * mapperDefaults: { foo: 'bar' }\n * })\n * const userMapper = container.defineMapper('user')\n * userMapper.foo // \"bar\"\n *\n * @name Container#defineMapper\n * @method\n * @param {string} name Name under which to register the new {@link Mapper}.\n * {@link Mapper#name} will be set to this value.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Container#mapperClass} when creating the new {@link Mapper}.\n * @return {Mapper}\n */\n defineMapper (name, opts) {\n const self = this\n\n // For backwards compatibility with defineResource\n if (utils.isObject(name)) {\n opts = name\n if (!opts.name) {\n throw new Error('name is required!')\n }\n name = opts.name\n } else if (!utils.isString(name)) {\n throw new Error('name is required!')\n }\n\n // Default values for arguments\n opts || (opts = {})\n // Set Mapper#name\n opts.name = name\n opts.relations || (opts.relations = {})\n\n // Check if the user is overriding the datastore's default mapperClass\n const mapperClass = opts.mapperClass || self.mapperClass\n delete opts.mapperClass\n\n // Apply the datastore's defaults to the options going into the mapper\n utils.fillIn(opts, self.mapperDefaults)\n\n // Instantiate a mapper\n const mapper = self._mappers[name] = new mapperClass(opts) // eslint-disable-line\n // Make sure the mapper's name is set\n mapper.name = name\n // All mappers in this datastore will share adapters\n mapper._adapters = self.getAdapters()\n\n mapper.datastore = self\n\n mapper.on('all', function (...args) {\n self._onMapperEvent(name, ...args)\n })\n\n // Setup the mapper's relations, including generating Mapper#relationList\n // and Mapper#relationFields\n utils.forOwn(mapper.relations, function (group, type) {\n utils.forOwn(group, function (relations, _name) {\n if (utils.isObject(relations)) {\n relations = [relations]\n }\n relations.forEach(function (def) {\n def.getRelation = function () {\n return self.getMapper(_name)\n }\n const relatedMapper = self._mappers[_name] || _name\n if (type === belongsToType) {\n mapper.belongsTo(relatedMapper, def)\n } else if (type === hasOneType) {\n mapper.hasOne(relatedMapper, def)\n } else if (type === hasManyType) {\n mapper.hasMany(relatedMapper, def)\n }\n })\n })\n })\n\n return mapper\n },\n\n defineResource (name, opts) {\n return this.defineMapper(name, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Container#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw new ReferenceError(`${adapter} not found!`)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Container#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || this.mapperDefaults.defaultAdapter\n },\n\n /**\n * Return the registered adapters of this container.\n *\n * @name Container#getAdapters\n * @method\n * @return {Adapter}\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Return the mapper registered under the specified name.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container()\n * const userMapper = container.defineMapper('user')\n * userMapper === container.getMapper('user') // true\n *\n * @name Container#getMapper\n * @method\n * @param {string} name {@link Mapper#name}.\n * @return {Mapper}\n */\n getMapper (name) {\n const mapper = this._mappers[name]\n if (!mapper) {\n throw new ReferenceError(`${name} is not a registered mapper!`)\n }\n return mapper\n },\n\n /**\n * Register an adapter on this container under the given name. Adapters\n * registered on a container are shared by all mappers in the container.\n *\n * @example\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * container.registerAdapter('http', new HttpAdapter, { default: true })\n *\n * @name Container#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for all Mappers in this container.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.mapperDefaults.defaultAdapter = name\n utils.forOwn(self._mappers, function (mapper) {\n mapper.defaultAdapter = name\n })\n }\n }\n}\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getMapper(name)[method](...args)\n }\n})\n\n/**\n * ```javascript\n * import {Container} from 'js-data'\n * ```\n *\n * The `Container` class is a place to store {@link Mapper} instances.\n *\n * Without a container, you need to manage mappers yourself, including resolving\n * circular dependencies among relations. All mappers in a container share the\n * same adapters, so you don't have to add each adapter to all of your mappers.\n *\n * @example Without Container\n * import {Mapper} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const adapter = new HttpAdapter()\n * const userMapper = new Mapper({ name: 'user' })\n * userMapper.registerAdapter('http', adapter, { default: true })\n * const commentMapper = new Mapper({ name: 'comment' })\n * commentMapper.registerAdapter('http', adapter, { default: true })\n *\n * // This might be more difficult if the mappers were defined in different\n * // modules.\n * userMapper.hasMany(commentMapper, {\n * localField: 'comments',\n * foreignKey: 'userId'\n * })\n * commentMapper.belongsTo(userMapper, {\n * localField: 'user',\n * foreignKey: 'userId'\n * })\n *\n * @example With Container\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * // All mappers in container share adapters\n * container.registerAdapter('http', new HttpAdapter(), { default: true })\n *\n * // These could be defined in separate modules without a problem.\n * container.defineMapper('user', {\n * relations: {\n * hasMany: {\n * comment: {\n * localField: 'comments',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n * container.defineMapper('comment', {\n * relations: {\n * belongsTo: {\n * user: {\n * localField: 'user',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n *\n * @class Container\n * @extends Component\n * @param {Object} [opts] Configuration options.\n * @param {Function} [opts.mapperClass] Constructor function to use in\n * {@link Container#defineMapper} to create a new mapper.\n * @param {Object} [opts.mapperDefaults] Defaults options to pass to\n * {@link Container#mapperClass} when creating a new mapper.\n * @return {Container}\n */\nexport default Component.extend(props)\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Collection from './Collection'\n\n/**\n * TODO\n *\n * ```javascript\n * import {LinkedCollection} from 'js-data'\n * ```\n *\n * @class LinkedCollection\n * @extends Collection\n * @param {Array} [records] Initial set of records to insert into the\n * collection. See {@link Collection}.\n * @param {Object} [opts] Configuration options. See {@link Collection}.\n * @return {Mapper}\n */\nexport default Collection.extend({\n constructor: function LinkedCollection (records, opts) {\n const self = this\n utils.classCallCheck(self, LinkedCollection)\n LinkedCollection.__super__.call(self, records, opts)\n\n // Make sure this collection has somewhere to store \"added\" timestamps\n self._added = {}\n\n // Make sure this collection a reference to a datastore\n if (!self.datastore) {\n throw new Error('This collection must have a datastore!')\n }\n return self\n },\n\n _onRecordEvent (...args) {\n const self = this\n utils.getSuper(self).prototype._onRecordEvent.apply(self, args)\n const event = args[0]\n // This is a very brute force method\n // Lots of room for optimization\n if (utils.isString(event) && event.indexOf('change') === 0) {\n self.updateIndexes(args[1])\n }\n },\n\n add (records, opts) {\n const self = this\n const datastore = self.datastore\n const mapper = self.mapper\n const relationList = mapper.relationList || []\n const timestamp = new Date().getTime()\n const usesRecordClass = !!mapper.recordClass\n const idAttribute = mapper.idAttribute\n let singular\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n\n records = utils.getSuper(self).prototype.add.call(self, records, opts)\n\n if (relationList.length && records.length) {\n // Check the currently visited record for relations that need to be\n // inserted into their respective collections.\n mapper.relationList.forEach(function (def) {\n const relationName = def.relation\n // A reference to the Mapper that this Mapper is related to\n const relatedMapper = datastore.getMapper(relationName)\n // The field used by the related Mapper as the primary key\n const relationIdAttribute = relatedMapper.idAttribute\n // Grab the foreign key in this relationship, if there is one\n const foreignKey = def.foreignKey\n // A lot of this is an optimization for being able to insert a lot of\n // data as quickly as possible\n const relatedCollection = datastore.getCollection(relationName)\n const type = def.type\n const isHasMany = type === hasManyType\n const shouldAdd = utils.isUndefined(def.add) ? true : !!def.add\n let relatedData\n\n records.forEach(function (record) {\n // Grab a reference to the related data attached or linked to the\n // currently visited record\n relatedData = def.getLocalField(record)\n const id = utils.get(record, idAttribute)\n\n if (utils.isFunction(def.add)) {\n relatedData = def.add(datastore, def, record)\n } else if (relatedData) {\n // Otherwise, if there is something to be added, add it\n if (isHasMany) {\n // Handle inserting hasMany relations\n relatedData = relatedData.map(function (toInsertItem) {\n // Check that this item isn't the same item that is already in the\n // store\n if (toInsertItem !== relatedCollection.get(relatedCollection.recordId(toInsertItem))) {\n // Make sure this item has its foreignKey\n if (foreignKey) {\n // TODO: slow, could be optimized? But user loses hook\n def.setForeignKey(record, toInsertItem)\n }\n // Finally add this related item\n if (shouldAdd) {\n toInsertItem = relatedCollection.add(toInsertItem)\n }\n }\n return toInsertItem\n })\n // If it's the parent that has the localKeys\n if (def.localKeys && !utils.get(record, def.localKeys)) {\n utils.set(record, def.localKeys, relatedData.map(function (inserted) {\n return utils.get(inserted, relationIdAttribute)\n }))\n }\n } else {\n const relatedDataId = utils.get(relatedData, relationIdAttribute)\n // Handle inserting belongsTo and hasOne relations\n if (relatedData !== relatedCollection.get(relatedDataId)) {\n // Make sure foreignKey field is set\n def.setForeignKey(record, relatedData)\n // Finally insert this related item\n if (shouldAdd) {\n relatedData = relatedCollection.add(relatedData)\n }\n }\n }\n }\n\n if (!relatedData || (utils.isArray(relatedData) && !relatedData.length)) {\n if (type === belongsToType) {\n const relatedId = utils.get(record, foreignKey)\n if (!utils.isUndefined(relatedId)) {\n relatedData = relatedCollection.get(relatedId)\n }\n } else if (type === hasOneType) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records[0] : undefined\n } else if (type === hasManyType) {\n if (foreignKey) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.localKeys) {\n const _records = relatedCollection.filter({\n where: {\n [relationIdAttribute]: {\n 'in': utils.get(record, def.localKeys || [])\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.foreignKeys) {\n const _records = relatedCollection.filter({\n where: {\n [def.foreignKeys]: {\n 'contains': id\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n }\n }\n }\n if (relatedData) {\n def.setLocalField(record, relatedData)\n }\n })\n })\n }\n\n records.forEach(function (record) {\n // Track when this record was added\n self._added[self.recordId(record)] = timestamp\n\n if (usesRecordClass) {\n record._set('$', timestamp)\n }\n })\n\n return singular ? records[0] : records\n },\n\n remove (id, opts) {\n const self = this\n const mapper = self.mapper\n const record = utils.getSuper(self).prototype.remove.call(self, id, opts)\n if (record) {\n delete self._added[id]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n }\n return record\n },\n\n removeAll (query, opts) {\n const self = this\n const mapper = self.mapper\n const records = utils.getSuper(self).prototype.removeAll.call(self, query, opts)\n records.forEach(function (record) {\n delete self._added[self.recordId(record)]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n })\n return records\n }\n})\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Container from './Container'\nimport LinkedCollection from './LinkedCollection'\n\nconst DATASTORE_DEFAULTS = {}\n\nconst safeSet = function (record, field, value) {\n if (record && record._set) {\n record._set(field, value)\n } else {\n utils.set(record, field, value)\n }\n}\n\nconst cachedFn = function (name, hashOrId, opts) {\n const self = this\n const cached = self._completedQueries[name][hashOrId]\n if (utils.isFunction(cached)) {\n return cached(name, hashOrId, opts)\n }\n return cached\n}\n\nconst props = {\n constructor: function DataStore (opts) {\n const self = this\n utils.classCallCheck(self, DataStore)\n DataStore.__super__.call(self, opts)\n\n self.collectionClass = self.collectionClass || LinkedCollection\n self._collections = {}\n utils.fillIn(self, DATASTORE_DEFAULTS)\n self._pendingQueries = {}\n self._completedQueries = {}\n return self\n },\n\n _callSuper (method, ...args) {\n return this.constructor.__super__.prototype[method].apply(this, args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#_end\n * @method\n * @private\n * @param {string} name Name of the {@link LinkedCollection} to which to\n * add the data.\n * @param {Object} data TODO.\n * @param {Object} [opts] Configuration options.\n * @return {(Object|Array)} Result.\n */\n _end (name, result, opts) {\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(this.addToCache)) {\n _data = this.addToCache(name, _data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Register a new event listener on this DataStore.\n *\n * Proxy for {@link Container#on}. If an event was emitted by a Mapper or\n * Collection in the DataStore, then the name of the Mapper or Collection will\n * be prepended to the arugments passed to the provided event handler.\n *\n * @name DataStore#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by collections in this store.\n *\n * @name DataStore#_onCollectionEvent\n * @method\n * @private\n * @param {string} name Name of the collection that emitted the event.\n * @param {...*} [args] Args passed to {@link Collection#emit}.\n */\n _onCollectionEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#addToCache\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {*} data - Data from which data should be selected for add.\n * @param {Object} [opts] - Configuration options.\n */\n addToCache (name, data, opts) {\n return this.getCollection(name).add(data, opts)\n },\n\n /**\n * Retrieve a cached `find` result, if any.\n *\n * @name DataStore#cachedFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cachedFind: cachedFn,\n\n /**\n * Retrieve a cached `findAll` result, if any.\n *\n * @name DataStore#cachedFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cachedFindAll: cachedFn,\n\n /**\n * Cache a `find` result. The default implementation does the following:\n *\n * ```\n * // Find and return the record from the data store\n * return this.get(name, id)\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {*} data The result to cache.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cacheFind (name, data, id, opts) {\n const self = this\n self._completedQueries[name][id] = function (name, id, opts) {\n return self.get(name, id)\n }\n },\n\n /**\n * Cache a `findAll` result. The default implementation does the following:\n *\n * ```\n * // Find and return the records from the data store\n * return this.filter(name, utils.fromJson(hash))\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {*} data The result to cache.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cacheFindAll (name, data, hash, opts) {\n const self = this\n self._completedQueries[name][hash] = function (name, hash, opts) {\n return self.filter(name, utils.fromJson(hash))\n }\n },\n\n /**\n * TODO\n *\n * @name DataStore#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n create (name, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('create', name, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n createMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('createMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n defineMapper (name, opts) {\n const self = this\n const mapper = utils.getSuper(self).prototype.defineMapper.call(self, name, opts)\n self._pendingQueries[name] = {}\n self._completedQueries[name] = {}\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n\n // The datastore uses a subclass of Collection that is \"datastore-aware\"\n const collection = self._collections[name] = new self.collectionClass(null, { // eslint-disable-line\n // Make sure the collection has somewhere to store \"added\" timestamps\n _added: {},\n // Give the collection a reference to this datastore\n datastore: self,\n // The mapper tied to the collection\n mapper\n })\n\n const schema = mapper.schema || {}\n const properties = schema.properties || {}\n // TODO: Make it possible index nested properties?\n utils.forOwn(properties, function (opts, prop) {\n if (opts.indexed) {\n collection.createIndex(prop)\n }\n })\n\n // Create a secondary index on the \"added\" timestamps of records in the\n // collection\n collection.createIndex('addedTimestamps', ['$'], {\n fieldGetter (obj) {\n return collection._added[collection.recordId(obj)]\n }\n })\n\n collection.on('all', function (...args) {\n self._onCollectionEvent(name, ...args)\n })\n\n const idAttribute = mapper.idAttribute\n\n mapper.relationList.forEach(function (def) {\n const relation = def.relation\n const localField = def.localField\n const path = `links.${localField}`\n const foreignKey = def.foreignKey\n const type = def.type\n const updateOpts = { index: foreignKey }\n let descriptor\n\n const getter = function () { return this._get(path) }\n\n if (type === belongsToType) {\n if (!collection.indexes[foreignKey]) {\n collection.createIndex(foreignKey)\n }\n\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const id = utils.get(_self, idAttribute)\n const inverseDef = def.getInverse(mapper)\n\n if (record) {\n const relatedIdAttribute = def.getRelation().idAttribute\n const relatedId = utils.get(record, relatedIdAttribute)\n\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n safeSet(_self, foreignKey, relatedId)\n collection.updateIndex(_self, updateOpts)\n\n // Update (set) inverse relation\n if (inverseDef.type === hasOneType) {\n utils.set(record, inverseDef.localField, _self)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(record, inverseDef.localField)\n utils.noDupeAdd(children, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n } else {\n // Unset locals\n _self._set(path, undefined)\n safeSet(_self, foreignKey, undefined)\n collection.updateIndex(_self, updateOpts)\n }\n if (current) {\n if (inverseDef.type === hasOneType) {\n utils.set(current, inverseDef.localField, undefined)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(current, inverseDef.localField)\n utils.remove(children, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n }\n return record\n }\n }\n\n if (mapper.recordClass.prototype.hasOwnProperty(foreignKey)) {\n const superClass = mapper.recordClass\n mapper.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n Object.defineProperty(mapper.recordClass.prototype, foreignKey, {\n enumerable: true,\n get () { return this._get(foreignKey) },\n set (value) {\n const _self = this\n if (utils.isUndefined(value)) {\n // Unset locals\n utils.set(_self, localField, undefined)\n } else {\n safeSet(_self, foreignKey, value)\n let storeRecord = self.get(relation, value)\n if (storeRecord) {\n utils.set(_self, localField, storeRecord)\n }\n }\n }\n })\n } else if (type === hasManyType) {\n const localKeys = def.localKeys\n const foreignKeys = def.foreignKeys\n\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n\n descriptor = {\n get () {\n const _self = this\n let current = getter.call(_self)\n if (!current) {\n _self._set(path, [])\n }\n return getter.call(_self)\n },\n set (records) {\n const _self = this\n records || (records = [])\n if (records && !utils.isArray(records)) {\n records = [records]\n }\n const id = utils.get(_self, idAttribute)\n const relatedIdAttribute = def.getRelation().idAttribute\n const inverseDef = def.getInverse(mapper)\n const inverseLocalField = inverseDef.localField\n let linked = _self._get(path)\n if (!linked) {\n linked = []\n }\n\n const current = linked\n linked = []\n const toLink = {}\n records.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId)) {\n // Prefer store record\n record = self.get(relation, relatedId) || record\n toLink[relatedId] = record\n }\n linked.push(record)\n })\n if (foreignKey) {\n records.forEach(function (record) {\n // Update (set) inverse relation\n safeSet(record, foreignKey, id)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n })\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update (unset) inverse relation\n safeSet(record, foreignKey, undefined)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (localKeys) {\n const _localKeys = []\n records.forEach(function (record) {\n // Update (set) inverse relation\n utils.set(record, inverseLocalField, _self)\n _localKeys.push(utils.get(record, relatedIdAttribute))\n })\n // Update locals\n utils.set(_self, localKeys, _localKeys)\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update inverse relation\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (foreignKeys) {\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.remove(_localKeys, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.remove(_localField, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n // Update (set) inverse relation\n records.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.noDupeAdd(_localKeys, id, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.noDupeAdd(_localField, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n }\n\n _self._set(path, linked)\n return linked\n }\n }\n } else if (type === hasOneType) {\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const relatedId = utils.get(record, def.getRelation().idAttribute)\n const inverseLocalField = def.getInverse(mapper).localField\n // Update (unset) inverse relation\n if (current) {\n safeSet(current, foreignKey, undefined)\n self.getCollection(relation).updateIndex(current, updateOpts)\n utils.set(current, inverseLocalField, undefined)\n }\n if (record) {\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n\n // Update (set) inverse relation\n safeSet(record, foreignKey, utils.get(_self, idAttribute))\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n } else {\n // Set locals\n _self._set(path, undefined)\n }\n return record\n }\n }\n }\n\n if (descriptor) {\n descriptor.enumerable = utils.isUndefined(def.enumerable) ? true : def.enumerable\n if (def.get) {\n let origGet = descriptor.get\n descriptor.get = function () {\n return def.get(def, this, (...args) => origGet.apply(this, args))\n }\n }\n if (def.set) {\n let origSet = descriptor.set\n descriptor.set = function (related) {\n return def.set(def, this, related, (value) => origSet.call(this, value === undefined ? related : value))\n }\n }\n Object.defineProperty(mapper.recordClass.prototype, localField, descriptor)\n }\n })\n\n return mapper\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n destroy (name, id, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroy', name, id, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).remove(id, opts)\n } else {\n data = self.getCollection(name).remove(id, opts)\n }\n delete self._pendingQueries[name][id]\n delete self._completedQueries[name][id]\n return data\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n destroyAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroyAll', name, query, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).removeAll(query, opts)\n } else {\n data = self.getCollection(name).removeAll(query, opts)\n }\n const hash = self.hashQuery(name, query, opts)\n delete self._pendingQueries[name][hash]\n delete self._completedQueries[name][hash]\n return data\n })\n },\n\n eject (id, opts) {\n return this.remove(id, opts)\n },\n\n ejectAll (query, opts) {\n return this.removeAll(query, opts)\n },\n\n /**\n * TODO\n *\n * @name DataStore#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n find (name, id, opts) {\n const self = this\n opts || (opts = {})\n const pendingQuery = self._pendingQueries[name][id]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n const item = self.cachedFind(name, id, opts)\n let promise\n\n if (opts.force || !item) {\n promise = self._pendingQueries[name][id] = self._callSuper('find', name, id, opts).then(function (data) {\n delete self._pendingQueries[name][id]\n const result = self._end(name, data, opts)\n self.cacheFind(name, result, id, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][id]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(item)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n findAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n const hash = self.hashQuery(name, query, opts)\n const pendingQuery = self._pendingQueries[name][hash]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n\n const items = self.cachedFindAll(name, hash, opts)\n let promise\n\n if (opts.force || !items) {\n promise = self._pendingQueries[name][hash] = self._callSuper('findAll', name, query, opts).then(function (data) {\n delete self._pendingQueries[name][hash]\n const result = self._end(name, data, opts)\n self.cacheFindAll(name, result, hash, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][hash]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(items)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#getCollection\n * @method\n * @param {string} name Name of the {@link LinkedCollection} to retrieve.\n * @return {LinkedCollection}\n */\n getCollection (name) {\n const collection = this._collections[name]\n if (!collection) {\n throw new ReferenceError(`${name} is not a registered collection!`)\n }\n return collection\n },\n\n hashQuery (name, query, opts) {\n return utils.toJson(query)\n },\n\n inject (records, opts) {\n return this.add(records, opts)\n },\n\n remove (name, id, opts) {\n const self = this\n const record = self.getCollection(name).remove(id, opts)\n if (record) {\n self.removeRelated(name, [record], opts)\n }\n return record\n },\n\n removeAll (name, query, opts) {\n const self = this\n const records = self.getCollection(name).removeAll(query, opts)\n if (records.length) {\n self.removeRelated(name, records, opts)\n }\n return records\n },\n\n removeRelated (name, records, opts) {\n const self = this\n utils.forEachRelation(self.getMapper(name), opts, function (def, optsCopy) {\n records.forEach(function (record) {\n let relatedData\n let query\n if (def.foreignKey && (def.type === hasOneType || def.type === hasManyType)) {\n query = { [def.foreignKey]: def.getForeignKey(record) }\n } else if (def.type === hasManyType && def.localKeys) {\n query = {\n where: {\n [def.getRelation().idAttribute]: {\n 'in': utils.get(record, def.localKeys)\n }\n }\n }\n } else if (def.type === hasManyType && def.foreignKeys) {\n query = {\n where: {\n [def.foreignKeys]: {\n 'contains': def.getForeignKey(record)\n }\n }\n }\n } else if (def.type === belongsToType) {\n relatedData = self.remove(def.relation, def.getForeignKey(record), optsCopy)\n }\n if (query) {\n relatedData = self.removeAll(def.relation, query, optsCopy)\n }\n if (relatedData) {\n if (utils.isArray(relatedData) && !relatedData.length) {\n return\n }\n if (def.type === hasOneType) {\n relatedData = relatedData[0]\n }\n def.setLocalField(record, relatedData)\n }\n })\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n update (name, id, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('update', name, id, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} props - Passed to {@link Mapper#updateAll}.\n * @param {Object} [query] - Passed to {@link Mapper#updateAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#updateAll}. See\n * {@link Mapper#updateAll} for more configuration options.\n * @return {Promise}\n */\n updateAll (name, props, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateAll', name, query, props, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n updateMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n }\n}\n\nconst toProxy = [\n 'add',\n 'between',\n 'createIndex',\n 'filter',\n 'get',\n 'getAll',\n 'query',\n 'toJson'\n]\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getCollection(name)[method](...args)\n }\n})\n\n/**\n * The `DataStore` class is an extension of {@link Container}. Not only does\n * `DataStore` manage mappers, but also collections. `DataStore` implements the\n * asynchronous {@link Mapper} methods, such as {@link Mapper#find} and\n * {@link Mapper#create}. If you use the asynchronous `DataStore` methods\n * instead of calling them directly on the mappers, then the results of the\n * method calls will be inserted into the store's collections. You can think of\n * a `DataStore` as an [Identity Map](https://en.wikipedia.org/wiki/Identity_map_pattern)\n * for the [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)\n * (the Mappers).\n *\n * ```javascript\n * import {DataStore} from 'js-data'\n * ```\n *\n * @example\n * import {DataStore} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const store = new DataStore()\n * const UserMapper = store.defineMapper('user')\n *\n * // Call \"find\" on \"UserMapper\" (Stateless ORM)\n * UserMapper.find(1).then(function (user) {\n * // retrieved a \"user\" record via the http adapter, but that's it\n *\n * // Call \"find\" on \"store\" for the \"user\" mapper (Stateful DataStore)\n * return store.find('user', 1)\n * }).then(function (user) {\n * // not only was a \"user\" record retrieved, but it was added to the\n * // store's \"user\" collection\n * const cachedUser = store.getCollection('user').get(1)\n * user === cachedUser // true\n * })\n *\n * @class DataStore\n * @extends Container\n * @param {Object} [opts] Configuration options. See {@link Container}.\n * @return {DataStore}\n */\nexport default Container.extend(props)\n","/**\n * Registered as `js-data` in NPM and Bower.\n * #### Script tag\n * ```js\n * window.JSData\n * ```\n * #### CommonJS\n * ```js\n * var JSData = require('js-data')\n * ```\n * #### ES6 Modules\n * ```js\n * import JSData from 'js-data'\n * ```\n * #### AMD\n * ```js\n * define('myApp', ['js-data'], function (JSData) { ... })\n * ```\n *\n * @module js-data\n */\n\n/**\n * Details of the current version of the `js-data` module.\n *\n * @name version\n * @memberof module:js-data\n * @type {Object}\n * @property {string} full The full semver value.\n * @property {number} major The major version number.\n * @property {number} minor The minor version number.\n * @property {number} patch The patch version number.\n * @property {(string|boolean)} alpha The alpha version value, otherwise `false`\n * if the current version is not alpha.\n * @property {(string|boolean)} beta The beta version value, otherwise `false`\n * if the current version is not beta.\n */\nexport const version = {\n alpha: '<%= alpha %>' !== 'false' ? '<%= alpha %>' : false,\n beta: '<%= beta %>' !== 'false' ? '<%= beta %>' : false,\n full: '<%= pkg.version %>',\n major: parseInt('<%= major %>', 10),\n minor: parseInt('<%= minor %>', 10),\n patch: parseInt('<%= patch %>', 10)\n}\n\nimport utils from './utils'\n\n/**\n * {@link Collection} class.\n * @name module:js-data.Collection\n */\nimport Collection from './Collection'\n\n/**\n * {@link Component} class.\n * @name module:js-data.Component\n */\nimport Component from './Component'\n\n/**\n * {@link Container} class.\n * @name module:js-data.Container\n */\nimport Container from './Container'\n\n/**\n * {@link DataStore} class.\n * @name module:js-data.DataStore\n */\nimport DataStore from './DataStore'\n\n/**\n * {@link LinkedCollection} class.\n * @name module:js-data.LinkedCollection\n */\nimport LinkedCollection from './LinkedCollection'\n\n/**\n * {@link Mapper} class.\n * @name module:js-data.Mapper\n */\nimport Mapper from './Mapper'\n\n/**\n * {@link Query} class.\n * @name module:js-data.Query\n */\nimport Query from './Query'\n\n/**\n * {@link Record} class.\n * @name module:js-data.Record\n */\nimport Record from './Record'\n\n/**\n * {@link Schema} class.\n * @name module:js-data.Schema\n */\nimport Schema from './Schema'\n\nexport * from './decorators'\n\nexport {\n Collection,\n Component,\n Container,\n DataStore,\n LinkedCollection,\n Mapper,\n Query,\n Record,\n Schema,\n utils\n}\n"],"names":["utils","belongsTo","hasMany","hasOne","props","toProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAM,WAAW,IAAI,CAAJ;AACjB,IAAM,cAAc,uBAAd;AACN,IAAM,WAAW,kBAAX;AACN,IAAM,WAAW,eAAX;AACN,IAAM,WAAW,mBAAX;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,cAAc,OAAO,SAAP,CAAiB,QAAjB;AACpB,IAAM,OAAO,cAAP;;AAEN,IAAM,YAAY,SAAZ,SAAY,CAAU,KAAV,EAAiB;MAC7B,CAAC,KAAD,EAAQ;WACH,CAAP,CADU;GAAZ;;OAIA,GAAQ,CAAC,KAAD,CALyB;MAM7B,UAAU,QAAV,IAAsB,UAAU,CAAC,QAAD,EAAW;QACvC,OAAQ,QAAQ,CAAR,GAAY,CAAC,CAAD,GAAK,CAAjB,CAD+B;WAEtC,OAAO,WAAP,CAFsC;GAA/C;MAIM,YAAY,QAAQ,CAAR,CAVe;SAW1B,UAAU,KAAV,GAAmB,YAAY,QAAQ,SAAR,GAAoB,KAAhC,GAAyC,CAA5D;CAXS;;AAclB,IAAM,QAAQ,SAAR,KAAQ,CAAU,KAAV,EAAiB;SACtB,YAAY,IAAZ,CAAiB,KAAjB,CAAP,CAD6B;CAAjB;;AAId,IAAM,gBAAgB,SAAhB,aAAgB,CAAU,KAAV,EAAiB;SAC7B,CAAC,CAAC,KAA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B,CAAP;SACO,SAAS,cAAT,EAAyB,EAAzB,CAAP;SACO,SAAS,cAAT,EAAyB,EAAzB,CAAP;CANW,CAAb;;"} \ No newline at end of file +{"version":3,"file":"js-data.es2015.js","sources":["../src/utils.js","../src/Component.js","../src/Query.js","../lib/mindex/_utils.js","../lib/mindex/index.js","../src/Collection.js","../src/decorators.js","../src/Record.js","../src/Schema.js","../src/Mapper.js","../src/Container.js","../src/LinkedCollection.js","../src/DataStore.js","../src/index.js"],"sourcesContent":["/**\n * @name utils\n * @memberof module:js-data\n * @type {Object}\n * @property {Function} addHiddenPropsToTarget TODO\n * @property {Function} classCallCheck TODO\n * @property {Function} copy TODO\n * @property {Function} deepMixIn TODO\n * @property {Function} eventify TODO\n * @property {Function} extend TODO\n * @property {Function} fillIn TODO\n * @property {Function} fromJson TODO\n * @property {Function} get TODO\n * @property {Function} getSuper TODO\n * @property {Function} intersection TODO\n * @property {Function} isArray TODO\n * @property {Function} isBlacklisted TODO\n * @property {boolean} isBrowser TODO\n * @property {Function} isBoolean TODO\n * @property {Function} isFunction TODO\n * @property {Function} isInteger TODO\n * @property {Function} isNull TODO\n * @property {Function} isNumber TODO\n * @property {Function} isObject TODO\n * @property {Function} isRegExp TODO\n * @property {Function} isSorN TODO\n * @property {Function} isString TODO\n * @property {Function} isUndefined TODO\n * @property {Function} reject TODO\n * @property {Function} resolve TODO\n * @property {Function} set TODO\n * @property {Function} toJson TODO\n */\n\nconst DOMAIN = 'utils'\n\nconst INFINITY = 1 / 0\nconst MAX_INTEGER = 1.7976931348623157e+308\nconst BOOL_TAG = '[object Boolean]'\nconst DATE_TAG = '[object Date]'\nconst FUNC_TAG = '[object Function]'\nconst NUMBER_TAG = '[object Number]'\nconst OBJECT_TAG = '[object Object]'\nconst REGEXP_TAG = '[object RegExp]'\nconst STRING_TAG = '[object String]'\nconst objToString = Object.prototype.toString\nconst PATH = /^(.+)\\.(.+)$/\n\nconst ERRORS = {\n '400' () { return `expected: ${arguments[0]}, found: ${arguments[2] ? arguments[1] : typeof arguments[1]}` },\n '404' () { return `${arguments[0]} not found` }\n}\n\nconst toInteger = function (value) {\n if (!value) {\n return 0\n }\n // Coerce to number\n value = +value\n if (value === INFINITY || value === -INFINITY) {\n const sign = (value < 0 ? -1 : 1)\n return sign * MAX_INTEGER\n }\n const remainder = value % 1\n return value === value ? (remainder ? value - remainder : value) : 0 // eslint-disable-line\n}\n\nconst toStr = function (value) {\n return objToString.call(value)\n}\n\nconst isPlainObject = function (value) {\n return (!!value && typeof value === 'object' && value.constructor === Object)\n}\n\nconst mkdirP = function (object, path) {\n if (!path) {\n return object\n }\n const parts = path.split('.')\n parts.forEach(function (key) {\n if (!object[key]) {\n object[key] = {}\n }\n object = object[key]\n })\n return object\n}\n\nconst utils = {\n /**\n * TODO\n *\n * @ignore\n */\n Promise: Promise,\n\n /**\n * Shallow copy properties from src to dest that meet the following criteria:\n * - own enumerable\n * - not a function\n * - does not start with \"_\"\n *\n * @ignore\n * @param {Object} dest Destination object.\n * @param {Object} src Source object.\n */\n _ (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (key && utils.isUndefined(dest[key]) && !utils.isFunction(value) && key.indexOf('_') !== 0) {\n dest[key] = value\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _forRelation (opts, def, fn, ctx) {\n const relationName = def.relation\n let containedName = null\n let index\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n if ((index = utils._getIndex(opts.with, relationName)) >= 0) {\n containedName = relationName\n } else if ((index = utils._getIndex(opts.with, def.localField)) >= 0) {\n containedName = def.localField\n }\n\n if (opts.withAll) {\n fn.call(ctx, def, {})\n return\n } else if (!containedName) {\n return\n }\n let optsCopy = {}\n utils.fillIn(optsCopy, def.getRelation())\n utils.fillIn(optsCopy, opts)\n optsCopy.with = opts.with.slice()\n optsCopy._activeWith = optsCopy.with.splice(index, 1)[0]\n optsCopy.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n optsCopy.with[i] = relation.substr(containedName.length + 1)\n } else {\n optsCopy.with[i] = ''\n }\n })\n fn.call(ctx, def, optsCopy)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _getIndex (list, relation) {\n let index = -1\n list.forEach(function (_relation, i) {\n if (_relation === relation) {\n index = i\n return false\n } else if (utils.isObject(_relation)) {\n if (_relation.relation === relation) {\n index = i\n return false\n }\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n addHiddenPropsToTarget (target, props) {\n const map = {}\n utils.forOwn(props, function (value, key) {\n map[key] = {\n writable: true,\n value\n }\n })\n Object.defineProperties(target, map)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n areDifferent (a, b, opts) {\n opts || (opts = {})\n const diff = utils.diffObjects(a, b, opts)\n const diffCount = Object.keys(diff.added).length +\n Object.keys(diff.removed).length +\n Object.keys(diff.changed).length\n return diffCount > 0\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n classCallCheck (instance, ctor) {\n if (!(instance instanceof ctor)) {\n throw utils.err(`${ctor.name}`)(500, 'Cannot call a class as a function')\n }\n },\n\n /**\n * Deep copy a value.\n *\n * @ignore\n * @param {*} from Value to deep copy.\n * @return {*} Deep copy of `from`.\n */\n copy (from, to, stackFrom, stackTo, blacklist, plain) {\n if (!to) {\n to = from\n if (from) {\n if (utils.isArray(from)) {\n to = utils.copy(from, [], stackFrom, stackTo, blacklist, plain)\n } else if (utils.isDate(from)) {\n to = new Date(from.getTime())\n } else if (utils.isRegExp(from)) {\n to = new RegExp(from.source, from.toString().match(/[^\\/]*$/)[0])\n to.lastIndex = from.lastIndex\n } else if (utils.isObject(from)) {\n if (plain) {\n to = utils.copy(from, {}, stackFrom, stackTo, blacklist, plain)\n } else {\n to = utils.copy(from, Object.create(Object.getPrototypeOf(from)), stackFrom, stackTo, blacklist, plain)\n }\n }\n }\n } else {\n if (from === to) {\n throw utils.err(`${DOMAIN}.copy`)(500, 'Cannot copy! Source and destination are identical.')\n }\n\n stackFrom = stackFrom || []\n stackTo = stackTo || []\n\n if (utils.isObject(from)) {\n let index = stackFrom.indexOf(from)\n if (index !== -1) {\n return stackTo[index]\n }\n\n stackFrom.push(from)\n stackTo.push(to)\n }\n\n let result\n if (utils.isArray(from)) {\n let i\n to.length = 0\n for (i = 0; i < from.length; i++) {\n result = utils.copy(from[i], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[i])) {\n stackFrom.push(from[i])\n stackTo.push(result)\n }\n to.push(result)\n }\n } else {\n if (utils.isArray(to)) {\n to.length = 0\n } else {\n utils.forOwn(to, function (value, key) {\n delete to[key]\n })\n }\n for (var key in from) {\n if (from.hasOwnProperty(key)) {\n if (utils.isBlacklisted(key, blacklist)) {\n continue\n }\n result = utils.copy(from[key], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[key])) {\n stackFrom.push(from[key])\n stackTo.push(result)\n }\n to[key] = result\n }\n }\n }\n }\n return to\n },\n\n /**\n * Recursively shallow fill in own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepFillIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepFillIn(existing, value)\n } else if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * Recursively shallow copy own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepMixIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepMixIn(existing, value)\n } else {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * @param {Object} a Base object.\n * @param {Object} b Comparison object.\n * @return {Object} Diff.\n */\n diffObjects (a, b, opts) {\n opts || (opts = {})\n let equalsFn = opts.equalsFn\n let bl = opts.ignore\n const diff = {\n added: {},\n changed: {},\n removed: {}\n }\n if (!utils.isFunction(equalsFn)) {\n equalsFn = utils.strictEqual\n }\n\n utils.forOwn(b, function (oldValue, key) {\n const newValue = a[key]\n\n if (utils.isBlacklisted(key, bl) || equalsFn(newValue, oldValue)) {\n return\n }\n\n if (utils.isUndefined(newValue)) {\n diff.removed[key] = undefined\n } else if (!equalsFn(newValue, oldValue)) {\n diff.changed[key] = newValue\n }\n })\n\n utils.forOwn(a, function (newValue, key) {\n if (!utils.isUndefined(b[key]) || utils.isBlacklisted(key, bl)) {\n return\n }\n diff.added[key] = newValue\n })\n\n return diff\n },\n\n /**\n * TODO\n */\n equal (a, b) {\n return a == b // eslint-disable-line\n },\n\n /**\n * TODO\n */\n err (domain, target) {\n return function (code) {\n const prefix = `[${domain}:${target}] `\n let message = ERRORS[code].apply(null, Array.prototype.slice.call(arguments, 1))\n message = `${prefix}${message}\\nhttp://www.js-data.io/v3.0/docs/errors#${code}`\n return new Error(message)\n }\n },\n\n /**\n * Add eventing capabilities into the target object.\n *\n * @ignore\n * @param {Object} target Target object.\n * @param {Function} [getter] Custom getter for retrieving the object's event\n * listeners.\n * @param {Function} [setter] Custom setter for setting the object's event\n * listeners.\n */\n eventify (target, getter, setter) {\n target = target || this\n let _events = {}\n if (!getter && !setter) {\n getter = function () { return _events }\n setter = function (value) { _events = value }\n }\n Object.defineProperties(target, {\n emit: {\n value (...args) {\n const events = getter.call(this) || {}\n const type = args.shift()\n let listeners = events[type] || []\n let i\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n listeners = events.all || []\n args.unshift(type)\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n }\n },\n off: {\n value (type, func) {\n const events = getter.call(this)\n const listeners = events[type]\n if (!listeners) {\n setter.call(this, {})\n } else if (func) {\n for (let i = 0; i < listeners.length; i++) {\n if (listeners[i].f === func) {\n listeners.splice(i, 1)\n break\n }\n }\n } else {\n listeners.splice(0, listeners.length)\n }\n }\n },\n on: {\n value (type, func, ctx) {\n if (!getter.call(this)) {\n setter.call(this, {})\n }\n const events = getter.call(this)\n events[type] = events[type] || []\n events[type].push({\n c: ctx,\n f: func\n })\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n extend (props, classProps) {\n const superClass = this\n let subClass\n\n props || (props = {})\n classProps || (classProps = {})\n\n if (props.hasOwnProperty('constructor')) {\n subClass = props.constructor\n delete props.constructor\n } else {\n subClass = function (...args) {\n utils.classCallCheck(this, subClass)\n superClass.apply(this, args)\n }\n }\n\n // Setup inheritance of instance members\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n configurable: true,\n enumerable: false,\n value: subClass,\n writable: true\n }\n })\n\n const obj = Object\n // Setup inheritance of static members\n if (obj.setPrototypeOf) {\n obj.setPrototypeOf(subClass, superClass)\n } else if (classProps.strictEs6Class) {\n subClass.__proto__ = superClass // eslint-disable-line\n } else {\n utils.forOwn(superClass, function (value, key) {\n subClass[key] = value\n })\n }\n Object.defineProperty(subClass, '__super__', {\n configurable: true,\n value: superClass\n })\n\n utils.addHiddenPropsToTarget(subClass.prototype, props)\n utils.fillIn(subClass, classProps)\n\n return subClass\n },\n\n /**\n * Shallow copy own enumerable properties from `src` to `dest` that are on `src`\n * but are missing from `dest.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n fillIn (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n return dest\n },\n\n /**\n * Find the index of something according to the given checker function.\n *\n * @ignore\n * @param {Array} array The array to search.\n * @param {Function} fn Checker function.\n * @param {number} Index if found or -1 if not found.\n */\n findIndex (array, fn) {\n let index = -1\n if (!array) {\n return index\n }\n array.forEach(function (record, i) {\n if (fn(record)) {\n index = i\n return false\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n forEachRelation (mapper, opts, fn, ctx) {\n const relationList = mapper.relationList || []\n if (!relationList.length) {\n return\n }\n relationList.forEach(function (def) {\n utils._forRelation(opts, def, fn, ctx)\n })\n },\n\n /**\n * Iterate over an object's own enumerable properties.\n *\n * @ignore\n * @param {Object} object The object whose properties are to be enumerated.\n * @param {Function} fn Iteration function.\n * @param {Object} [thisArg] Content to which to bind `fn`.\n */\n forOwn (obj, fn, thisArg) {\n const keys = Object.keys(obj)\n const len = keys.length\n let i\n for (i = 0; i < len; i++) {\n fn.call(thisArg, obj[keys[i]], keys[i], obj)\n }\n },\n\n /**\n * Proxy for `JSON.parse`.\n *\n * @ignore\n * @param {string} json JSON to parse.\n * @return {Object} Parsed object.\n */\n fromJson (json) {\n return utils.isString(json) ? JSON.parse(json) : json\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n 'get': function (object, prop) {\n if (!prop) {\n return\n }\n const parts = prop.split('.')\n const last = parts.pop()\n\n while (prop = parts.shift()) { // eslint-disable-line\n object = object[prop]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n return object[last]\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n getSuper (instance, isCtor) {\n const ctor = isCtor ? instance : instance.constructor\n return (ctor.__super__ || Object.getPrototypeOf(ctor) || ctor.__proto__) // eslint-disable-line\n },\n\n /**\n * Return the intersection of two arrays.\n *\n * @ignore\n * @param {Array} array1 First array.\n * @param {Array} array2 Second array.\n * @return {Array} Array of elements common to both arrays.\n */\n intersection (array1, array2) {\n if (!array1 || !array2) {\n return []\n }\n const result = []\n let item\n let i\n const len = array1.length\n for (i = 0; i < len; i++) {\n item = array1[i]\n if (result.indexOf(item) !== -1) {\n continue\n }\n if (array2.indexOf(item) !== -1) {\n result.push(item)\n }\n }\n return result\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isArray: Array.isArray,\n\n /**\n * Return whether `prop` is matched by any string or regular expression in `bl`.\n *\n * @ignore\n * @param {string} prop The name of a property.\n * @param {Array} bl Array of strings and regular expressions.\n * @return {boolean} Whether `prop` was matched.\n */\n isBlacklisted (prop, bl) {\n if (!bl || !bl.length) {\n return false\n }\n let matches\n for (var i = 0; i < bl.length; i++) {\n if ((toStr(bl[i]) === REGEXP_TAG && bl[i].test(prop)) || bl[i] === prop) {\n matches = prop\n return matches\n }\n }\n return !!matches\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBoolean (value) {\n return toStr(value) === BOOL_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBrowser: false,\n\n /**\n * TODO\n *\n * @ignore\n */\n isDate (value) {\n return (value && typeof value === 'object' && toStr(value) === DATE_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isFunction (value) {\n return typeof value === 'function' || (value && toStr(value) === FUNC_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isInteger (value) {\n return toStr(value) === NUMBER_TAG && value == toInteger(value) // eslint-disable-line\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNull (value) {\n return value === null\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNumber (value) {\n const type = typeof value\n return type === 'number' || (value && type === 'object' && toStr(value) === NUMBER_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isObject (value) {\n return toStr(value) === OBJECT_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isRegExp (value) {\n return toStr(value) === REGEXP_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isSorN (value) {\n return utils.isString(value) || utils.isNumber(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isString (value) {\n return typeof value === 'string' || (value && typeof value === 'object' && toStr(value) === STRING_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isUndefined (value) {\n return value === undefined\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n logify (target) {\n utils.addHiddenPropsToTarget(target, {\n dbg (...args) {\n this.log('debug', ...args)\n },\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (${this.name || this.constructor.name})`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n noDupeAdd (array, record, fn) {\n if (!array) {\n return\n }\n const index = this.findIndex(array, fn)\n if (index < 0) {\n array.push(record)\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n omit (props, keys) {\n // Remove relations\n const _props = {}\n utils.forOwn(props, function (value, key) {\n if (keys.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n return _props\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n plainCopy (from) {\n return utils.copy(from, undefined, undefined, undefined, undefined, true)\n },\n\n /**\n * Proxy for `Promise.reject`.\n *\n * @ignore\n * @param {*} [value] Value with which to reject the Promise.\n * @return {Promise} Promise reject with `value`.\n */\n reject (value) {\n return utils.Promise.reject(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n remove (array, fn) {\n if (!array || !array.length) {\n return\n }\n const index = this.findIndex(array, fn)\n if (index >= 0) {\n array.splice(index, 1)\n }\n },\n\n /**\n * Proxy for `Promise.resolve`.\n *\n * @ignore\n * @param {*} [value] Value with which to resolve the Promise.\n * @return {Promise} Promise resolved with `value`.\n */\n resolve (value) {\n return utils.Promise.resolve(value)\n },\n\n /**\n * Set the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object on which to set a property.\n * @param {(string|Object)} path The key or path to the property. Can also\n * pass in an object of path/value pairs, which will all be set on the target\n * object.\n * @param {*} [value] The value to set.\n */\n set: function (object, path, value) {\n if (utils.isObject(path)) {\n utils.forOwn(path, function (value, _path) {\n utils.set(object, _path, value)\n })\n } else {\n const parts = PATH.exec(path)\n if (parts) {\n mkdirP(object, parts[1])[parts[2]] = value\n } else {\n object[path] = value\n }\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n strictEqual (a, b) {\n let _equal = a === b\n if (!_equal) {\n if (utils.isObject(a) && utils.isObject(b)) {\n utils.forOwn(a, function (value, key) {\n _equal = _equal && utils.strictEqual(value, b[key])\n })\n utils.forOwn(b, function (value, key) {\n _equal = _equal && utils.strictEqual(value, a[key])\n })\n } else if (utils.isArray(a) && utils.isArray(b)) {\n a.forEach(function (value, i) {\n _equal = _equal && utils.strictEqual(value, b[i])\n })\n }\n }\n return _equal\n },\n\n /**\n * Proxy for `JSON.stringify`.\n *\n * @ignore\n * @param {*} value Value to serialize to JSON.\n * @return {string} JSON string.\n */\n toJson: JSON.stringify,\n\n /**\n * Unset the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object from which to delete the property.\n * @param {string} path The key or path to the property.\n */\n unset (object, path) {\n const parts = path.split('.')\n const last = parts.pop()\n\n while (path = parts.shift()) { // eslint-disable-line\n object = object[path]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n object[last] = undefined\n }\n}\n\n// Attempt to detect whether we are in the browser.\ntry {\n utils.isBrowser = !!window\n} catch (e) {\n utils.isBrowser = false\n}\n\nexport default utils\n","import utils from './utils'\n\nexport default function Component () {\n /**\n * Event listeners attached to this Component. Do not modify. Use\n * {@link Component#on} and {@link Component#off} instead.\n *\n * @name Component#_listeners\n * @instance\n * @type {Object}\n */\n Object.defineProperty(this, '_listeners', { value: {} })\n}\n\n/**\n * Create a subclass of this component.\n *\n * @name Component.extend\n * @method\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @return {Function} Subclass of this component.\n */\nComponent.extend = utils.extend\n\n/**\n * TODO\n *\n * @name Component#dbg\n * @method\n */\n/**\n * TODO\n *\n * @name Component#log\n * @method\n */\nutils.logify(Component.prototype)\n\n/**\n * Register a new event listener on this Component.\n *\n * @name Component#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n/**\n * Remove an event listener from this Component. If no listener is provided,\n * then all listeners for the specified event will be removed. If no event is\n * specified then all listeners for all events will be removed.\n *\n * @name Component#off\n * @method\n * @param {string} [event] Name of event to unsubsribe to.\n * @param {Function} [listener] Listener to remove.\n */\n/**\n * Trigger an event on this Component.\n *\n * @name Component#emit\n * @method\n * @param {string} event Name of event to emit.\n * @param {...*} [args] Arguments to pass to any listeners.\n */\nutils.eventify(\n Component.prototype,\n function () {\n return this._listeners\n },\n function (value) {\n this._listeners = value\n }\n)\n","import utils from './utils'\nimport Component from './Component'\n\nconst DOMAIN = 'Query'\nconst INDEX_ERR = 'Index inaccessible after first operation'\n\n// Reserved words used by JSData's Query Syntax\nconst reserved = {\n limit: '',\n offset: '',\n orderBy: '',\n skip: '',\n sort: '',\n where: ''\n}\n\n// Used by our JavaScript implementation of the LIKE operator\nconst escapeRegExp = /([.*+?^=!:${}()|[\\]\\/\\\\])/g\nconst percentRegExp = /%/g\nconst underscoreRegExp = /_/g\nconst escape = function (pattern) {\n return pattern.replace(escapeRegExp, '\\\\$1')\n}\n\n/**\n * A class used by the {@link Collection} class to build queries to be executed\n * against the collection's data. An instance of `Query` is returned by\n * {@link Collection#query}. Query instances are typically short-lived.\n *\n * ```javascript\n * import {Query} from 'js-data'\n * ```\n *\n * @class Query\n * @extends Component\n * @param {Collection} collection The collection on which this query operates.\n */\nexport default Component.extend({\n constructor: function Query (collection) {\n const self = this\n utils.classCallCheck(self, Query)\n\n /**\n * The {@link Collection} on which this query operates.\n *\n * @name Query#collection\n * @type {Collection}\n */\n self.collection = collection\n\n /**\n * The current data result of this query.\n *\n * @name Query#data\n * @type {Array}\n */\n self.data = null\n },\n\n /**\n * Find all entities between two boundaries.\n *\n * Get the users ages 18 to 30\n * ```js\n * const users = query.between(18, 30, { index: 'age' }).run()\n * ```\n * Same as above\n * ```js\n * const users = query.between([18], [30], { index: 'age' }).run()\n * ```\n *\n * @name Query#between\n * @method\n * @param {Array} leftKeys - Keys defining the left boundary.\n * @param {Array} rightKeys - Keys defining the right boundary.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.limit] - Limit the result to a certain number.\n * @param {boolean} [opts.offset] - The number of resulting entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n between (leftKeys, rightKeys, opts) {\n const self = this\n opts || (opts = {})\n if (self.data) {\n throw utils.err(`${DOMAIN}#between`)(500, 'Cannot access index')\n }\n self.data = self.collection.getIndex(opts.index).between(leftKeys, rightKeys, opts)\n return self\n },\n\n /**\n * The comparison function used by the Query class.\n *\n * @name Query#compare\n * @method\n * @param {Array} orderBy An orderBy clause used for sorting and sub-sorting.\n * @param {number} index The index of the current orderBy clause being used.\n * @param {*} a The first item in the comparison.\n * @param {*} b The second item in the comparison.\n * @return {number} -1 if `b` should preceed `a`. 0 if `a` and `b` are equal.\n * 1 if `a` should preceed `b`.\n */\n compare (orderBy, index, a, b) {\n const def = orderBy[index]\n let cA = utils.get(a, def[0])\n let cB = utils.get(b, def[0])\n if (cA && utils.isString(cA)) {\n cA = cA.toUpperCase()\n }\n if (cB && utils.isString(cB)) {\n cB = cB.toUpperCase()\n }\n if (a === undefined) {\n a = null\n }\n if (b === undefined) {\n b = null\n }\n if (def[1].toUpperCase() === 'DESC') {\n const temp = cB\n cB = cA\n cA = temp\n }\n if (cA < cB) {\n return -1\n } else if (cA > cB) {\n return 1\n } else {\n if (index < orderBy.length - 1) {\n return this.compare(orderBy, index + 1, a, b)\n } else {\n return 0\n }\n }\n },\n\n /**\n * Predicate evaluation function used by the Query class.\n *\n * @name Query#evaluate\n * @method\n * @param {*} value The value to evaluate.\n * @param {string} op The operator to use in this evaluation.\n * @param {*} predicate The predicate to use in this evaluation.\n * @return {boolean} Whether the value passed the evaluation or not.\n */\n evaluate (value, op, predicate) {\n const ops = this.constructor.ops\n if (ops[op]) {\n return ops[op](value, predicate)\n }\n if (op.indexOf('like') === 0) {\n return !utils.isNull(this.like(predicate, op.substr(4)).exec(value))\n } else if (op.indexOf('notLike') === 0) {\n return utils.isNull(this.like(predicate, op.substr(7)).exec(value))\n }\n },\n\n /**\n * Find the entity or entities that match the provided query or pass the\n * provided filter function.\n *\n * #### Example\n *\n * Get the draft posts created less than three months\n * ```js\n * const posts = query.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * }).run()\n * ```\n * Use a custom filter function\n * ```js\n * const posts = query.filter(function (post) {\n * return post.isReady()\n * }).run()\n * ```\n *\n * @name Query#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Function} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Query} A reference to itself for chaining.\n */\n filter (query, thisArg) {\n const self = this\n query || (query = {})\n self.getData()\n if (utils.isObject(query)) {\n let where = {}\n // Filter\n if (utils.isObject(query.where)) {\n where = query.where\n }\n utils.forOwn(query, function (value, key) {\n if (!(key in reserved) && !(key in where)) {\n where[key] = {\n '==': value\n }\n }\n })\n\n const fields = []\n const ops = []\n const predicates = []\n utils.forOwn(where, function (clause, field) {\n if (!utils.isObject(clause)) {\n clause = {\n '==': clause\n }\n }\n utils.forOwn(clause, function (expr, op) {\n fields.push(field)\n ops.push(op)\n predicates.push(expr)\n })\n })\n if (fields.length) {\n let i\n let len = fields.length\n self.data = self.data.filter(function (item) {\n let first = true\n let keep = true\n\n for (i = 0; i < len; i++) {\n let op = ops[i]\n const isOr = op.charAt(0) === '|'\n op = isOr ? op.substr(1) : op\n const expr = self.evaluate(utils.get(item, fields[i]), op, predicates[i])\n if (expr !== undefined) {\n keep = first ? expr : (isOr ? keep || expr : keep && expr)\n }\n first = false\n }\n return keep\n })\n }\n\n // Sort\n let orderBy = query.orderBy || query.sort\n\n if (utils.isString(orderBy)) {\n orderBy = [\n [orderBy, 'ASC']\n ]\n }\n if (!utils.isArray(orderBy)) {\n orderBy = null\n }\n\n // Apply 'orderBy'\n if (orderBy) {\n let index = 0\n orderBy.forEach(function (def, i) {\n if (utils.isString(def)) {\n orderBy[i] = [def, 'ASC']\n }\n })\n self.data.sort(function (a, b) {\n return self.compare(orderBy, index, a, b)\n })\n }\n\n // Skip\n if (utils.isNumber(query.skip)) {\n self.skip(query.skip)\n } else if (utils.isNumber(query.offset)) {\n self.skip(query.offset)\n }\n // Limit\n if (utils.isNumber(query.limit)) {\n self.limit(query.limit)\n }\n } else if (utils.isFunction(query)) {\n self.data = self.data.filter(query, thisArg)\n }\n return self\n },\n\n /**\n * Iterate over all entities.\n *\n * @name Query#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Query} A reference to itself for chaining.\n */\n forEach (forEachFn, thisArg) {\n this.getData().forEach(forEachFn, thisArg)\n return this\n },\n\n /**\n * Find the entity or entities that match the provided key.\n *\n * #### Example\n *\n * Get the entity whose primary key is 25\n * ```js\n * const entities = query.get(25).run()\n * ```\n * Same as above\n * ```js\n * const entities = query.get([25]).run()\n * ```\n * Get all users who are active and have the \"admin\" role\n * ```js\n * const activeAdmins = query.get(['active', 'admin'], {\n * index: 'activityAndRoles'\n * }).run()\n * ```\n * Get all entities that match a certain weather condition\n * ```js\n * const niceDays = query.get(['sunny', 'humid', 'calm'], {\n * index: 'weatherConditions'\n * }).run()\n * ```\n *\n * @name Query#get\n * @method\n * @param {Array} keyList - Key(s) defining the entity to retrieve. If\n * `keyList` is not an array (i.e. for a single-value key), it will be\n * wrapped in an array.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.string] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n get (keyList, opts) {\n const self = this\n keyList || (keyList = [])\n opts || (opts = {})\n if (self.data) {\n throw utils.err(`${DOMAIN}#get`)(500, INDEX_ERR)\n }\n if (keyList && !utils.isArray(keyList)) {\n keyList = [keyList]\n }\n if (!keyList.length) {\n self.getData()\n return self\n }\n self.data = self.collection.getIndex(opts.index).get(keyList)\n return self\n },\n\n /**\n * Find the entity or entities that match the provided keyLists.\n *\n * #### Example\n *\n * Get the posts where \"status\" is \"draft\" or \"inReview\"\n * ```js\n * const posts = query.getAll('draft', 'inReview', { index: 'status' }).run()\n * ```\n * Same as above\n * ```js\n * const posts = query.getAll(['draft'], ['inReview'], { index: 'status' }).run()\n * ```\n *\n * @name Query#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * entities matching each keyList will be retrieved. If no keyLists are\n * provided, all entities will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n getAll (...args) {\n const self = this\n let opts = {}\n if (self.data) {\n throw utils.err(`${DOMAIN}#getAll`)(500, INDEX_ERR)\n }\n if (!args.length || args.length === 1 && utils.isObject(args[0])) {\n self.getData()\n return self\n } else if (args.length && utils.isObject(args[args.length - 1])) {\n opts = args[args.length - 1]\n args.pop()\n }\n const collection = self.collection\n const index = collection.getIndex(opts.index)\n self.data = []\n args.forEach(function (keyList) {\n self.data = self.data.concat(index.get(keyList))\n })\n return self\n },\n\n /**\n * Return the current data result of this query.\n * @name Query#getData\n * @method\n * @return {Array} The data in this query.\n */\n getData () {\n const self = this\n if (!self.data) {\n self.data = self.collection.index.getAll()\n }\n return self.data\n },\n\n like (pattern, flags) {\n return new RegExp(`^${(escape(pattern).replace(percentRegExp, '.*').replace(underscoreRegExp, '.'))}$`, flags)\n },\n\n /**\n * Limit the result.\n *\n * #### Example\n *\n * Get only the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).limit(10).run()\n * ```\n *\n * @name Query#limit\n * @method\n * @param {number} num - The maximum number of entities to keep in the result.\n * @return {Query} A reference to itself for chaining.\n */\n limit (num) {\n if (!utils.isNumber(num)) {\n throw utils.err(`${DOMAIN}#limit`, 'num')(400, 'number', num)\n }\n const data = this.getData()\n this.data = data.slice(0, Math.min(data.length, num))\n return this\n },\n\n /**\n * Apply a mapping function to the result data.\n *\n * @name Query#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Query} A reference to itself for chaining.\n */\n map (mapFn, thisArg) {\n this.data = this.getData().map(mapFn, thisArg)\n return this\n },\n\n /**\n * Return the result of calling the specified function on each item in this\n * collection's main index.\n * @name Query#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Query} A reference to itself for chaining.\n */\n mapCall (funcName, ...args) {\n this.data = this.getData().map(function (item) {\n return item[funcName](...args)\n })\n return this\n },\n\n /**\n * Complete the execution of the query and return the resulting data.\n *\n * @name Query#run\n * @method\n * @return {Array} The result of executing this query.\n */\n run () {\n const data = this.data\n this.data = null\n return data\n },\n\n /**\n * Skip a number of results.\n *\n * #### Example\n *\n * Get all but the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).skip(10).run()\n * ```\n *\n * @name Query#skip\n * @method\n * @param {number} num - The number of entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n skip (num) {\n if (!utils.isNumber(num)) {\n throw utils.err(`${DOMAIN}#skip`, 'num')(400, 'number', num)\n }\n const data = this.getData()\n if (num < data.length) {\n this.data = data.slice(num)\n } else {\n this.data = []\n }\n return this\n }\n}, {\n /**\n * TODO\n *\n * @name Query.ops\n * @type {Object}\n */\n ops: {\n '==': function (value, predicate) {\n return value == predicate // eslint-disable-line\n },\n '===': function (value, predicate) {\n return value === predicate\n },\n '!=': function (value, predicate) {\n return value != predicate // eslint-disable-line\n },\n '!==': function (value, predicate) {\n return value !== predicate\n },\n '>': function (value, predicate) {\n return value > predicate\n },\n '>=': function (value, predicate) {\n return value >= predicate\n },\n '<': function (value, predicate) {\n return value < predicate\n },\n '<=': function (value, predicate) {\n return value <= predicate\n },\n 'isectEmpty': function (value, predicate) {\n return !utils.intersection((value || []), (predicate || [])).length\n },\n 'isectNotEmpty': function (value, predicate) {\n return utils.intersection((value || []), (predicate || [])).length\n },\n 'in': function (value, predicate) {\n return predicate.indexOf(value) !== -1\n },\n 'notIn': function (value, predicate) {\n return predicate.indexOf(value) === -1\n },\n 'contains': function (value, predicate) {\n return (value || []).indexOf(predicate) !== -1\n },\n 'notContains': function (value, predicate) {\n return (value || []).indexOf(predicate) === -1\n }\n }\n})\n","export function sort (a, b, hashCode) {\n // Short-curcuit comparison if a and b are strictly equal\n // This is absolutely necessary for indexed objects that\n // don't have the idAttribute field\n if (a === b) {\n return 0\n }\n if (hashCode) {\n a = hashCode(a)\n b = hashCode(b)\n }\n if (a === null && b === null) {\n return 0\n }\n\n if (a === null) {\n return -1\n }\n\n if (b === null) {\n return 1\n }\n\n if (a < b) {\n return -1\n }\n\n if (a > b) {\n return 1\n }\n\n return 0\n}\n\nexport function insertAt (array, index, value) {\n array.splice(index, 0, value)\n return array\n}\n\nexport function removeAt (array, index) {\n array.splice(index, 1)\n return array\n}\n\nexport function binarySearch (array, value, field) {\n let lo = 0\n let hi = array.length\n let compared\n let mid\n\n while (lo < hi) {\n mid = ((lo + hi) / 2) | 0\n compared = sort(value, array[mid], field)\n if (compared === 0) {\n return {\n found: true,\n index: mid\n }\n } else if (compared < 0) {\n hi = mid\n } else {\n lo = mid + 1\n }\n }\n\n return {\n found: false,\n index: hi\n }\n}\n","// Copyright (c) 2015, InternalFX.\n\n// Permission to use, copy, modify, and/or distribute this software for any purpose with or\n// without fee is hereby granted, provided that the above copyright notice and this permission\n// notice appear in all copies.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO\n// THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT\n// SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR\n// ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE\n// USE OR PERFORMANCE OF THIS SOFTWARE.\n\n// Modifications\n// Copyright 2015-2016 Jason Dobry\n//\n// Summary of modifications:\n// Converted to ES6 Class syntax\n// Reworked dependencies so as to re-use code already in js-data\nimport utils from '../../src/utils'\nimport {binarySearch, insertAt, removeAt} from './_utils'\n\nexport default function Index (fieldList, opts) {\n utils.classCallCheck(this, Index)\n fieldList || (fieldList = [])\n\n if (!utils.isArray(fieldList)) {\n throw new Error('fieldList must be an array.')\n }\n\n opts || (opts = {})\n this.fieldList = fieldList\n this.fieldGetter = opts.fieldGetter\n this.hashCode = opts.hashCode\n this.isIndex = true\n this.keys = []\n this.values = []\n}\n\nutils.addHiddenPropsToTarget(Index.prototype, {\n 'set' (keyList, value) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n let dataLocation = binarySearch(this.values[pos.index], value, this.hashCode)\n if (!dataLocation.found) {\n insertAt(this.values[pos.index], dataLocation.index, value)\n }\n } else {\n insertAt(this.keys, pos.index, key)\n insertAt(this.values, pos.index, [value])\n }\n } else {\n if (pos.found) {\n this.values[pos.index].set(keyList, value)\n } else {\n insertAt(this.keys, pos.index, key)\n let newIndex = new Index([], { hashCode: this.hashCode })\n newIndex.set(keyList, value)\n insertAt(this.values, pos.index, newIndex)\n }\n }\n },\n\n 'get' (keyList) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n if (this.values[pos.index].isIndex) {\n return this.values[pos.index].getAll()\n } else {\n return this.values[pos.index]\n }\n } else {\n return []\n }\n } else {\n if (pos.found) {\n return this.values[pos.index].get(keyList)\n } else {\n return []\n }\n }\n },\n\n getAll () {\n let results = []\n this.values.forEach(function (value) {\n if (value.isIndex) {\n results = results.concat(value.getAll())\n } else {\n results = results.concat(value)\n }\n })\n return results\n },\n\n visitAll (cb, thisArg) {\n this.values.forEach(function (value) {\n if (value.isIndex) {\n value.visitAll(cb, thisArg)\n } else {\n value.forEach(cb, thisArg)\n }\n })\n },\n\n between (leftKeys, rightKeys, opts) {\n opts || (opts = {})\n if (!utils.isArray(leftKeys)) {\n leftKeys = [leftKeys]\n }\n if (!utils.isArray(rightKeys)) {\n rightKeys = [rightKeys]\n }\n utils.fillIn(opts, {\n leftInclusive: true,\n rightInclusive: false,\n limit: undefined,\n offset: 0\n })\n\n let results = this._between(leftKeys, rightKeys, opts)\n\n if (opts.limit) {\n return results.slice(opts.offset, opts.limit + opts.offset)\n } else {\n return results.slice(opts.offset)\n }\n },\n\n _between (leftKeys, rightKeys, opts) {\n let results = []\n\n let leftKey = leftKeys.shift()\n let rightKey = rightKeys.shift()\n\n let pos\n\n if (leftKey !== undefined) {\n pos = binarySearch(this.keys, leftKey)\n } else {\n pos = {\n found: false,\n index: 0\n }\n }\n\n if (leftKeys.length === 0) {\n if (pos.found && opts.leftInclusive === false) {\n pos.index += 1\n }\n\n for (let i = pos.index; i < this.keys.length; i += 1) {\n if (rightKey !== undefined) {\n if (opts.rightInclusive) {\n if (this.keys[i] > rightKey) { break }\n } else {\n if (this.keys[i] >= rightKey) { break }\n }\n }\n\n if (this.values[i].isIndex) {\n results = results.concat(this.values[i].getAll())\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n } else {\n for (let i = pos.index; i < this.keys.length; i += 1) {\n let currKey = this.keys[i]\n if (currKey > rightKey) { break }\n\n if (this.values[i].isIndex) {\n if (currKey === leftKey) {\n results = results.concat(this.values[i]._between(utils.copy(leftKeys), rightKeys.map(function () { return undefined }), opts))\n } else if (currKey === rightKey) {\n results = results.concat(this.values[i]._between(leftKeys.map(function () { return undefined }), utils.copy(rightKeys), opts))\n } else {\n results = results.concat(this.values[i].getAll())\n }\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n }\n\n if (opts.limit) {\n return results.slice(0, opts.limit + opts.offset)\n } else {\n return results\n }\n },\n\n peek () {\n if (this.values.length) {\n if (this.values[0].isIndex) {\n return this.values[0].peek()\n } else {\n return this.values[0]\n }\n }\n return []\n },\n\n clear () {\n this.keys = []\n this.values = []\n },\n\n insertRecord (data) {\n let keyList = this.fieldList.map(function (field) {\n if (utils.isFunction(field)) {\n return field(data) || null\n } else {\n return data[field] || null\n }\n })\n this.set(keyList, data)\n },\n\n removeRecord (data) {\n let removed\n this.values.forEach((value, i) => {\n if (value.isIndex) {\n if (value.removeRecord(data)) {\n if (value.keys.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n } else {\n const dataLocation = binarySearch(value, data, this.hashCode)\n if (dataLocation.found) {\n removeAt(value, dataLocation.index)\n if (value.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n }\n })\n return removed ? data : undefined\n },\n\n updateRecord (data) {\n this.removeRecord(data)\n this.insertRecord(data)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Query from './Query'\nimport Index from '../lib/mindex/index'\n\nconst DOMAIN = 'Collection'\n\nconst COLLECTION_DEFAULTS = {\n /**\n * Field to be used as the unique identifier for records in this collection.\n * Defaults to `\"id\"` unless {@link Collection#mapper} is set, in which case\n * this will default to {@link Mapper#idAttribute}.\n *\n * @name Collection#idAttribute\n * @type {string}\n * @default \"id\"\n */\n idAttribute: 'id',\n\n /**\n * What to do when inserting a record into this Collection that shares a\n * primary key with a record already in this Collection.\n *\n * Possible values:\n * - merge\n * - replace\n *\n * Merge:\n *\n * Recursively shallow copy properties from the new record onto the existing\n * record.\n *\n * Replace:\n *\n * Shallow copy top-level properties from the new record onto the existing\n * record. Any top-level own properties of the existing record that are _not_\n * on the new record will be removed.\n *\n * @name Collection#onConflict\n * @type {string}\n * @default \"merge\"\n */\n onConflict: 'merge'\n}\n\n/**\n * ```javascript\n * import {Collection} from 'js-data'\n * ```\n *\n * An ordered set of {@link Record} instances.\n *\n * @example\n * import {Collection, Record} from 'js-data'\n * const user1 = new Record({ id: 1 })\n * const user2 = new Record({ id: 2 })\n * const UserCollection = new Collection([user1, user2])\n * UserCollection.get(1) === user1 // true\n *\n * @class Collection\n * @extends Component\n * @param {Array} [records] Initial set of records to insert into the\n * collection.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.idAttribute] See {@link Collection#idAttribute}.\n * @param {string} [opts.onConflict=\"merge\"] See {@link Collection#onConflict}.\n * @param {string} [opts.mapper] See {@link Collection#mapper}.\n */\nexport default Component.extend({\n constructor: function Collection (records, opts) {\n const self = this\n utils.classCallCheck(self, Collection)\n Collection.__super__.call(self)\n\n if (records && !utils.isArray(records)) {\n opts = records\n records = []\n }\n if (utils.isString(opts)) {\n opts = { idAttribute: opts }\n }\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n /**\n * Default Mapper for this collection. Optional. If a Mapper is provided, then\n * the collection will use the {@link Mapper#idAttribute} setting, and will\n * wrap records in {@link Mapper#recordClass}.\n *\n * @example\n * import {Collection, Mapper} from 'js-data'\n *\n * class MyMapperClass extends Mapper {\n * foo () { return 'bar' }\n * }\n * const myMapper = new MyMapperClass()\n * const collection = new Collection(null, { mapper: myMapper })\n *\n * @name Collection#mapper\n * @type {Mapper}\n * @default null\n */\n Object.defineProperty(self, 'mapper', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n utils.fillIn(self, utils.copy(COLLECTION_DEFAULTS))\n\n const idAttribute = self.recordId()\n\n Object.defineProperties(self, {\n /**\n * The main index, which uses @{link Collection#recordId} as the key.\n *\n * @name Collection#index\n * @type {Index}\n */\n index: {\n value: new Index([idAttribute], {\n hashCode (obj) {\n return utils.get(obj, idAttribute)\n }\n })\n },\n\n /**\n * Object that holds the secondary indexes of this collection.\n *\n * @name Collection#indexes\n * @type {Object.}\n */\n indexes: {\n value: {}\n }\n })\n\n // Insert initial data into the collection\n if (records) {\n self.add(records)\n }\n },\n\n /**\n * Used to bind to events emitted by records in this Collection.\n *\n * @name Collection#_onRecordEvent\n * @method\n * @private\n * @param {...*} [arg] Args passed to {@link Collection#emit}.\n */\n _onRecordEvent (...args) {\n this.emit(...args)\n },\n\n /**\n * Insert the provided record or records.\n *\n * If a record is already in the collection then the provided record will\n * either merge with or replace the existing record based on the value of the\n * `onConflict` option.\n *\n * The collection's secondary indexes will be updated as each record is\n * visited.\n *\n * @name Collection#add\n * @method\n * @param {(Object|Object[]|Record|Record[])} data The record or records to insert.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.onConflict] What to do when a record is already in\n * the collection. Possible values are `merge` or `replace`.\n * @return {(Object|Object[]|Record|Record[])} The added record or records.\n */\n add (records, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n\n // Fill in \"opts\" with the Collection's configuration\n utils._(opts, self)\n records = self.beforeAdd(records, opts) || records\n\n // Track whether just one record or an array of records is being inserted\n let singular = false\n const idAttribute = self.recordId()\n if (!utils.isArray(records)) {\n if (utils.isObject(records)) {\n records = [records]\n singular = true\n } else {\n throw utils.err(`${DOMAIN}#add`, 'records')(400, 'object or array', records)\n }\n }\n\n // Map the provided records to existing records.\n // New records will be inserted. If any records map to existing records,\n // they will be merged into the existing records according to the onConflict\n // option.\n records = records.map(function (record) {\n let id = self.recordId(record)\n if (!utils.isSorN(id)) {\n throw utils.err(`${DOMAIN}#add`, `record.${idAttribute}`)(400, 'string or number', id)\n }\n // Grab existing record if there is one\n const existing = self.get(id)\n // If the currently visited record is just a reference to an existing\n // record, then there is nothing to be done. Exit early.\n if (record === existing) {\n return existing\n }\n\n if (existing) {\n // Here, the currently visited record corresponds to a record already\n // in the collection, so we need to merge them\n const onConflict = opts.onConflict || self.onConflict\n if (onConflict === 'merge') {\n utils.deepMixIn(existing, record)\n } else if (onConflict === 'replace') {\n utils.forOwn(existing, (value, key) => {\n if (key !== idAttribute && !record.hasOwnProperty(key)) {\n delete existing[key]\n }\n })\n existing.set(record)\n } else {\n throw utils.err(`${DOMAIN}#add`, 'opts.onConflict')(400, 'one of (merge, replace)', onConflict, true)\n }\n record = existing\n // Update all indexes in the collection\n self.updateIndexes(record)\n } else {\n // Here, the currently visted record does not correspond to any record\n // in the collection, so (optionally) instantiate this record and insert\n // it into the collection\n record = self.mapper ? self.mapper.createRecord(record, opts) : record\n self.index.insertRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.insertRecord(record)\n })\n if (record && utils.isFunction(record.on)) {\n record.on('all', self._onRecordEvent, self)\n }\n }\n return record\n })\n // Finally, return the inserted data\n const result = singular ? records[0] : records\n // TODO: Make this more performant (batch events?)\n self.emit('add', result)\n return self.afterAdd(records, opts, result) || result\n },\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then {@link Collection#add} will return that same value.\n *\n * @name Collection#method\n * @method\n * @param {(Object|Object[]|Record|Record[])} result The record or records\n * that were added to this Collection by {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n afterAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}. If this method returns\n * a value then {@link Collection#remove} will return that same value.\n *\n * @name Collection#afterRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n * @param {Object} record The result that will be returned by {@link Collection#remove}.\n */\n afterRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}. If this method\n * returns a value then {@link Collection#removeAll} will return that same\n * value.\n *\n * @name Collection#afterRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n * @param {Object} records The result that will be returned by {@link Collection#removeAll}.\n */\n afterRemoveAll () {},\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then the `records` argument in {@link Collection#add} will be\n * re-assigned to the returned value.\n *\n * @name Collection#beforeAdd\n * @method\n * @param {(Object|Object[]|Record|Record[])} records The `records` argument passed to {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n beforeAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}.\n *\n * @name Collection#beforeRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n */\n beforeRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}.\n *\n * @name Collection#beforeRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n */\n beforeRemoveAll () {},\n\n /**\n * Find all records between two boundaries.\n *\n * Shortcut for `collection.query().between(18, 30, { index: 'age' }).run()`\n *\n * @example Get all users ages 18 to 30\n * const users = collection.between(18, 30, { index: 'age' })\n *\n * @example Same as above\n * const users = collection.between([18], [30], { index: 'age' })\n *\n * @name Collection#between\n * @method\n * @param {Array} leftKeys Keys defining the left boundary.\n * @param {Array} rightKeys Keys defining the right boundary.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.index] Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.limit] Limit the result to a certain number.\n * @param {boolean} [opts.offset] The number of resulting records to skip.\n * @return {Array} The result.\n */\n between (leftKeys, rightKeys, opts) {\n return this.query().between(leftKeys, rightKeys, opts).run()\n },\n\n /**\n * Create a new secondary index on the contents of the collection.\n *\n * @example Index users by age\n * collection.createIndex('age')\n *\n * @example Index users by status and role\n * collection.createIndex('statusAndRole', ['status', 'role'])\n *\n * @name Collection#createIndex\n * @method\n * @param {string} name - The name of the new secondary index.\n * @param {string[]} [fieldList] - Array of field names to use as the key or\n * compound key of the new secondary index. If no fieldList is provided, then\n * the name will also be the field that is used to index the collection.\n * @return {Collection} A reference to itself for chaining.\n */\n createIndex (name, fieldList, opts) {\n const self = this\n if (utils.isString(name) && fieldList === undefined) {\n fieldList = [name]\n }\n opts || (opts = {})\n opts.hashCode = opts.hashCode || function (obj) {\n return self.recordId(obj)\n }\n const index = self.indexes[name] = new Index(fieldList, opts)\n self.index.visitAll(index.insertRecord, index)\n return self\n },\n\n /**\n * Find the record or records that match the provided query or pass the\n * provided filter function.\n *\n * Shortcut for `collection.query().filter(queryOrFn[, thisArg]).run()`\n *\n * @example Get the draft posts created less than three months\n * const posts = collection.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * })\n *\n * @example Use a custom filter function\n * const posts = collection.filter(function (post) {\n * return post.isReady()\n * })\n *\n * @name Collection#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Object} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Array} The result.\n */\n filter (query, thisArg) {\n return this.query().filter(query, thisArg).run()\n },\n\n /**\n * Iterate over all records.\n *\n * @example\n * collection.forEach(function (record) {\n * // do something\n * })\n *\n * @name Collection#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Array} The result.\n */\n forEach (cb, thisArg) {\n this.index.visitAll(cb, thisArg)\n },\n\n /**\n * Get the record with the given id.\n *\n * @name Collection#get\n * @method\n * @param {(string|number)} id - The primary key of the record to get.\n * @return {(Object|Record)} The record with the given id.\n */\n get (id) {\n const instances = this.query().get(id).run()\n return instances.length ? instances[0] : undefined\n },\n\n /**\n * Find the record or records that match the provided keyLists.\n *\n * Shortcut for `collection.query().getAll(keyList1, keyList2, ...).run()`\n *\n * @example Get the posts where \"status\" is \"draft\" or \"inReview\"\n * const posts = collection.getAll('draft', 'inReview', { index: 'status' })\n *\n * @example Same as above\n * const posts = collection.getAll(['draft'], ['inReview'], { index: 'status' })\n *\n * @name Collection#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * records matching each keyList will be retrieved. If no keyLists are\n * provided, all records will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Array} The result.\n */\n getAll (...args) {\n return this.query().getAll(...args).run()\n },\n\n /**\n * Return the index with the given name. If no name is provided, return the\n * main index. Throws an error if the specified index does not exist.\n *\n * @name Collection#getIndex\n * @method\n * @param {string} [name] The name of the index to retrieve.\n */\n getIndex (name) {\n const index = name ? this.indexes[name] : this.index\n if (!index) {\n throw utils.err(`${DOMAIN}#getIndex`, name)(404, 'index')\n }\n return index\n },\n\n /**\n * Limit the result.\n *\n * Shortcut for `collection.query().limit(maximumNumber).run()`\n *\n * @example\n * const posts = collection.limit(10)\n *\n * @name Collection#limit\n * @method\n * @param {number} num - The maximum number of records to keep in the result.\n * @return {Array} The result.\n */\n limit (num) {\n return this.query().limit(num).run()\n },\n\n /**\n * Apply a mapping function to all records.\n *\n * @example\n * const names = collection.map(function (user) {\n * return user.name\n * })\n *\n * @name Collection#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Array} The result of the mapping.\n */\n map (cb, thisArg) {\n const data = []\n this.index.visitAll(function (value) {\n data.push(cb.call(thisArg, value))\n })\n return data\n },\n\n /**\n * Return the result of calling the specified function on each record in this\n * collection's main index.\n *\n * @name Collection#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Array} The result.\n */\n mapCall (funcName, ...args) {\n const data = []\n this.index.visitAll(function (record) {\n data.push(record[funcName](...args))\n })\n return data\n },\n\n /**\n * Return the primary key of the given, or if no record is provided, return the\n * name of the field that holds the primary key of records in this Collection.\n *\n * @name Collection#recordId\n * @method\n * @param {(Object|Record)} [record] The record whose primary key is to be\n * returned.\n * @return {(string|number)} Primary key or name of field that holds primary\n * key.\n */\n recordId (record) {\n const self = this\n if (record) {\n return utils.get(record, self.recordId())\n }\n return self.mapper ? self.mapper.idAttribute : self.idAttribute\n },\n\n /**\n * Create a new query to be executed against the contents of the collection.\n * The result will be all or a subset of the contents of the collection.\n *\n * @example Grab page 2 of users between ages 18 and 30\n * collection.query()\n * .between(18, 30, { index: 'age' }) // between ages 18 and 30\n * .skip(10) // second page\n * .limit(10) // page size\n * .run()\n *\n * @name Collection#query\n * @method\n * @return {Query} New query object.\n */\n query () {\n return new Query(this)\n },\n\n /**\n * Reduce the data in the collection to a single value and return the result.\n *\n * @example\n * const totalVotes = collection.reduce(function (prev, record) {\n * return prev + record.upVotes + record.downVotes\n * }, 0)\n *\n * @name Collection#reduce\n * @method\n * @param {Function} cb - Reduction callback.\n * @param {*} initialValue - Initial value of the reduction.\n * @return {*} The result.\n */\n reduce (cb, initialValue) {\n const data = this.getAll()\n return data.reduce(cb, initialValue)\n },\n\n /**\n * Remove the record with the given id from this Collection.\n *\n * @name Collection#remove\n * @method\n * @param {(string|number)} id - The primary key of the record to be removed.\n * @param {Object} [opts] - Configuration options.\n * @return {Object|Record} The removed record, if any.\n */\n remove (id, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemove(id, opts)\n const record = self.get(id)\n\n // The record is in the collection, remove it\n if (record) {\n self.index.removeRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.removeRecord(record)\n })\n if (record && utils.isFunction(record.off)) {\n record.off('all', self._onRecordEvent, self)\n self.emit('remove', record)\n }\n }\n return self.afterRemove(id, opts, record) || record\n },\n\n /**\n * Remove the record selected by \"query\" from this collection.\n *\n * @name Collection#removeAll\n * @method\n * @param {Object} [query={}] - Selection query.\n * @param {Object} [query.where] - Filtering criteria.\n * @param {number} [query.skip] - Number to skip.\n * @param {number} [query.limit] - Number to limit to.\n * @param {Array} [query.orderBy] - Sorting criteria.\n * @param {Object} [opts] - Configuration options.\n * @return {(Object[]|Record[])} The removed records, if any.\n */\n removeAll (query, opts) {\n const self = this\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemoveAll(query, opts)\n const records = self.filter(query)\n\n // Remove each selected record from the collection\n records.forEach(function (item) {\n self.remove(self.recordId(item), opts)\n })\n return self.afterRemoveAll(query, opts, records) || records\n },\n\n /**\n * Skip a number of results.\n *\n * Shortcut for `collection.query().skip(numberToSkip).run()`\n *\n * @example\n * const posts = collection.skip(10)\n *\n * @name Collection#skip\n * @method\n * @param {number} num - The number of records to skip.\n * @return {Array} The result.\n */\n skip (num) {\n return this.query().skip(num).run()\n },\n\n /**\n * Return the plain JSON representation of all items in this collection.\n * Assumes records in this collection have a toJSON method.\n *\n * @name Collection#toJSON\n * @method\n * @param {Object} [opts] - Configuration options.\n * @param {string[]} [opts.with] - Array of relation names or relation fields\n * to include in the representation.\n * @return {Array} The records.\n */\n toJSON (opts) {\n return this.mapCall('toJSON', opts)\n },\n\n /**\n * Update a record's position in a single index of this collection. See\n * {@link Collection#updateIndexes} to update a record's position in all\n * indexes at once.\n *\n * @name Collection#updateIndex\n * @method\n * @param {Object} record - The record to update.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] The index in which to update the record's\n * position. If you don't specify an index then the record will be updated\n * in the main index.\n */\n updateIndex (record, opts) {\n opts || (opts = {})\n this.getIndex(opts.index).updateRecord(record)\n },\n\n /**\n * TODO\n *\n * @name Collection#updateIndexes\n * @method\n * @param {Object} record - TODO\n * @param {Object} [opts] - Configuration options.\n */\n updateIndexes (record) {\n const self = this\n self.index.updateRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.updateRecord(record)\n })\n }\n})\n","import utils from './utils'\n\nexport const belongsToType = 'belongsTo'\nexport const hasManyType = 'hasMany'\nexport const hasOneType = 'hasOne'\n\nconst DOMAIN = 'Relation'\n\nfunction Relation (related, opts) {\n const self = this\n const DOMAIN_ERR = `new ${DOMAIN}`\n\n opts || (opts = {})\n\n const localField = opts.localField\n if (!localField) {\n throw utils.err(DOMAIN_ERR, 'opts.localField')(400, 'string', localField)\n }\n\n const foreignKey = opts.foreignKey = opts.foreignKey || opts.localKey\n if (!foreignKey && (opts.type === belongsToType || opts.type === hasOneType)) {\n throw utils.err(DOMAIN_ERR, 'opts.foreignKey')(400, 'string', foreignKey)\n }\n const localKeys = opts.localKeys\n const foreignKeys = opts.foreignKeys\n if (!foreignKey && !localKeys && !foreignKeys && opts.type === hasManyType) {\n throw utils.err(DOMAIN_ERR, 'opts.')(400, 'string', foreignKey)\n }\n\n if (utils.isString(related)) {\n opts.relation = related\n if (!utils.isFunction(opts.getRelation)) {\n throw utils.err(DOMAIN_ERR, 'opts.getRelation')(400, 'function', opts.getRelation)\n }\n } else if (related) {\n opts.relation = related.name\n Object.defineProperty(self, 'relatedMapper', {\n value: related\n })\n } else {\n throw utils.err(DOMAIN_ERR, 'related')(400, 'Mapper or string', related)\n }\n\n Object.defineProperty(self, 'inverse', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n}\n\nutils.addHiddenPropsToTarget(Relation.prototype, {\n getRelation () {\n return this.relatedMapper\n },\n getForeignKey (record) {\n if (this.type === belongsToType) {\n return utils.get(record, this.foreignKey)\n }\n return utils.get(record, this.mapper.idAttribute)\n },\n setForeignKey (record, relatedRecord) {\n const self = this\n if (!record || !relatedRecord) {\n return\n }\n if (self.type === belongsToType) {\n utils.set(record, self.foreignKey, utils.get(relatedRecord, self.getRelation().idAttribute))\n } else {\n const idAttribute = self.mapper.idAttribute\n if (utils.isArray(relatedRecord)) {\n relatedRecord.forEach(function (relatedRecordItem) {\n utils.set(relatedRecordItem, self.foreignKey, utils.get(record, idAttribute))\n })\n } else {\n utils.set(relatedRecord, self.foreignKey, utils.get(record, idAttribute))\n }\n }\n },\n getLocalField (record) {\n return utils.get(record, this.localField)\n },\n setLocalField (record, data) {\n return utils.set(record, this.localField, data)\n },\n getInverse (mapper) {\n const self = this\n if (self.inverse) {\n return self.inverse\n }\n self.getRelation().relationList.forEach(function (def) {\n if (def.getRelation() === mapper) {\n if (def.foreignKey && def.foreignKey !== self.foreignKey) {\n return\n }\n self.inverse = def\n return false\n }\n })\n return self.inverse\n }\n})\n\nconst relatedTo = function (mapper, related, opts) {\n opts.name = mapper.name\n const relation = new Relation(related, opts)\n Object.defineProperty(relation, 'mapper', {\n value: mapper\n })\n\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n mapper.relationFields || Object.defineProperty(mapper, 'relationFields', { value: [] })\n mapper.relationList.push(relation)\n mapper.relationFields.push(relation.localField)\n}\n\n/**\n * TODO\n *\n * @name module:js-data.belongsTo\n * @method\n * @param {Mapper} related The relation the target belongs to.\n * @param {Object} opts Configuration options.\n * @param {string} opts.foreignKey The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const belongsTo = function (related, opts) {\n opts || (opts = {})\n opts.type = belongsToType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasMany\n * @method\n * @param {Mapper} related The relation of which the target has many.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasMany = function (related, opts) {\n opts || (opts = {})\n opts.type = hasManyType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasOne\n * @method\n * @param {Mapper} related The relation of which the target has one.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasOne = function (related, opts) {\n opts || (opts = {})\n opts.type = hasOneType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n","import utils from './utils'\nimport Component from './Component'\n\nconst DOMAIN = 'Record'\n\nconst superMethod = function (mapper, name) {\n const store = mapper.datastore\n if (store && store[name]) {\n return function (...args) {\n return store[name](mapper.name, ...args)\n }\n }\n return mapper[name].bind(mapper)\n}\n\n/**\n * js-data's Record class.\n *\n * ```javascript\n * import {Record} from 'js-data'\n * ```\n *\n * @class Record\n * @extends Component\n * @param {Object} [props] The initial properties of the new Record instance.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation on the\n * initial properties.\n */\nconst Record = Component.extend({\n constructor: function Record (props, opts) {\n const self = this\n utils.classCallCheck(self, Record)\n\n props || (props = {})\n opts || (opts = {})\n const _props = {}\n Object.defineProperties(self, {\n _get: { value (key) { return utils.get(_props, key) } },\n _set: { value (key, value) { return utils.set(_props, key, value) } },\n _unset: { value (key) { return utils.unset(_props, key) } }\n })\n const _set = self._set\n // TODO: Optimize these strings\n _set('creating', true)\n if (opts.noValidate) {\n _set('noValidate', true)\n }\n utils.fillIn(self, props)\n _set('creating', false)\n _set('noValidate', false)\n _set('previous', utils.copy(props))\n },\n\n /**\n * TODO\n *\n * @name Record#_mapper\n * @method\n * @ignore\n */\n _mapper () {\n const self = this\n const mapper = self.constructor.mapper\n if (!mapper) {\n throw utils.err(`${DOMAIN}#_mapper`, '')(404, 'mapper')\n }\n return mapper\n },\n\n /**\n * TODO\n *\n * @name Record#afterLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n afterLoadRelations () {},\n\n /**\n * TODO\n *\n * @name Record#beforeLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n beforeLoadRelations () {},\n\n /**\n * Return changes to this record since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#changes\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n changes (opts) {\n const self = this\n opts || (opts = {})\n return utils.diffObjects(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#commit\n * @method\n */\n commit () {\n const self = this\n self._set('changed') // unset\n self._set('previous', utils.copy(self))\n return self\n },\n\n /**\n * Call {@link Mapper#destroy} using this record's primary key.\n *\n * @name Record#destroy\n * @method\n * @param {Object} [opts] Configuration options passed to {@link Mapper#destroy}.\n * @return {Promise} The result of calling {@link Mapper#destroy}.\n */\n destroy (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n return superMethod(mapper, 'destroy')(utils.get(self, mapper.idAttribute), opts)\n },\n\n /**\n * Return the value at the given path for this instance.\n *\n * @name Record#get\n * @method\n * @param {string} key - Path of value to retrieve.\n * @return {*} Value at path.\n */\n 'get' (key) {\n return utils.get(this, key)\n },\n\n /**\n * Return whether this record has changed since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#hasChanges\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n hasChanges (opts) {\n const self = this\n const quickHasChanges = !!(self._get('changed') || []).length\n return quickHasChanges || utils.areDifferent(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#hashCode\n * @method\n */\n hashCode () {\n const self = this\n return utils.get(self, self._mapper().idAttribute)\n },\n\n isValid (opts) {\n const self = this\n return !self._mapper().validate(self, opts)\n },\n\n /**\n * TODO\n *\n * @name Record#loadRelations\n * @method\n * @param {string[]} [relations] TODO\n * @param {Object} [opts] TODO\n */\n loadRelations (relations, opts) {\n let op\n const self = this\n const mapper = self._mapper()\n\n // Default values for arguments\n relations || (relations = [])\n if (utils.isString(relations)) {\n relations = [relations]\n }\n opts || (opts = {})\n opts.with = relations\n\n // Fill in \"opts\" with the Model's configuration\n utils._(opts, mapper)\n opts.adapter = mapper.getAdapterName(opts)\n\n // beforeLoadRelations lifecycle hook\n op = opts.op = 'beforeLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n // Now delegate to the adapter\n op = opts.op = 'loadRelations'\n mapper.dbg(op, self, relations, opts)\n let tasks = []\n let task\n utils.forEachRelation(mapper, opts, function (def, optsCopy) {\n const relatedMapper = def.getRelation()\n optsCopy.raw = false\n if (utils.isFunction(def.load)) {\n task = def.load(mapper, def, self, opts)\n } else if (def.type === 'hasMany' || def.type === 'hasOne') {\n if (def.foreignKey) {\n task = superMethod(relatedMapper, 'findAll')({\n [def.foreignKey]: utils.get(self, mapper.idAttribute)\n }, optsCopy).then(function (relatedData) {\n if (def.type === 'hasOne') {\n return relatedData.length ? relatedData[0] : undefined\n }\n return relatedData\n })\n } else if (def.localKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [relatedMapper.idAttribute]: {\n 'in': utils.get(self, def.localKeys)\n }\n }\n })\n } else if (def.foreignKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [def.foreignKeys]: {\n 'contains': utils.get(self, mapper.idAttribute)\n }\n }\n }, opts)\n }\n } else if (def.type === 'belongsTo') {\n const key = utils.get(self, def.foreignKey)\n if (utils.isSorN(key)) {\n task = superMethod(relatedMapper, 'find')(key, optsCopy)\n }\n }\n if (task) {\n task = task.then(function (relatedData) {\n def.setLocalField(self, relatedData)\n })\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterLoadRelations lifecycle hook\n op = opts.op = 'afterLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n return self\n })\n })\n },\n\n /**\n * TODO\n *\n * @name Record#previous\n * @method\n * @param {string} [key] TODO\n */\n previous (key) {\n const self = this\n if (key) {\n return self._get(`previous.${key}`)\n }\n return self._get('previous')\n },\n\n /**\n * TODO\n *\n * @name Record#revert\n * @method\n * @param {Object} [opts] Configuration options.\n */\n revert (opts) {\n const self = this\n const previous = self._get('previous')\n opts || (opts = {})\n opts.preserve || (opts.preserve = [])\n utils.forOwn(self, (value, key) => {\n if (key !== self._mapper().idAttribute && !previous.hasOwnProperty(key) && self.hasOwnProperty(key) && opts.preserve.indexOf(key) === -1) {\n delete self[key]\n }\n })\n utils.forOwn(previous, (value, key) => {\n if (opts.preserve.indexOf(key) === -1) {\n self[key] = value\n }\n })\n self.commit()\n return self\n },\n\n /**\n * Delegates to {@link Mapper#create} or {@link Mapper#update}.\n *\n * @name Record#save\n * @method\n * @param {Object} [opts] Configuration options. See {@link Mapper#create}.\n * @param [opts] Configuration options.\n * @param {boolean} [opts.changesOnly] Equality function. Default uses `===`.\n * @param {Function} [opts.equalsFn] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @param {Array} [opts.ignore] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @return {Promise} The result of calling {@link Mapper#create} or\n * {@link Mapper#update}.\n */\n save (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n const id = utils.get(self, mapper.idAttribute)\n let props = self\n if (utils.isUndefined(id)) {\n return superMethod(mapper, 'create')(props, opts)\n }\n if (opts.changesOnly) {\n const changes = self.changes(opts)\n props = {}\n utils.fillIn(props, changes.added)\n utils.fillIn(props, changes.changed)\n }\n return superMethod(mapper, 'update')(id, props, opts)\n },\n\n /**\n * Set the value for a given key, or the values for the given keys if \"key\" is\n * an object.\n *\n * @name Record#set\n * @method\n * @param {(string|Object)} key - Key to set or hash of key-value pairs to set.\n * @param {*} [value] - Value to set for the given key.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n 'set' (key, value, opts) {\n const self = this\n if (utils.isObject(key)) {\n opts = value\n }\n opts || (opts = {})\n if (opts.silent) {\n self._set('silent', true)\n }\n utils.set(self, key, value)\n if (!self._get('eventId')) {\n self._set('silent') // unset\n }\n },\n\n // TODO: move logic for single-item async operations onto the instance.\n\n /**\n * Return a plain object representation of this record. If the class from\n * which this record was created has a mapper, then {@link Mapper#toJSON} will\n * be called instead.\n *\n * @name Record#toJSON\n * @method\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation. Only available as an option if the class\n * from which this record was created has a mapper.\n * @return {Object} Plain object representation of this record.\n */\n toJSON (opts) {\n const mapper = this.constructor.mapper\n if (mapper) {\n return mapper.toJSON(this, opts)\n } else {\n const json = {}\n utils.forOwn(this, function (prop, key) {\n json[key] = utils.copy(prop)\n })\n return json\n }\n },\n\n /**\n * Unset the value for a given key.\n *\n * @name Record#unset\n * @method\n * @param {string} key - Key to unset.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n unset (key, opts) {\n this.set(key, undefined, opts)\n },\n\n validate (opts) {\n return this._mapper().validate(this, opts)\n }\n})\n\n/**\n * Allow records to emit events.\n *\n * An record's registered listeners are stored in the record's private data.\n */\nutils.eventify(\n Record.prototype,\n function () {\n return this._get('events')\n },\n function (value) {\n this._set('events', value)\n }\n)\n\nexport default Record\n","import utils from './utils'\nimport Component from './Component'\n\nconst DOMAIN = 'Schema'\n\n/**\n * TODO\n *\n * @name Schema.types\n * @type {Object}\n */\nconst types = {\n array: utils.isArray,\n boolean: utils.isBoolean,\n integer: utils.isInteger,\n 'null': utils.isNull,\n number: utils.isNumber,\n object: utils.isObject,\n string: utils.isString\n}\n\n/**\n * @ignore\n */\nconst segmentToString = function (segment, prev) {\n let str = ''\n if (segment) {\n if (utils.isNumber(segment)) {\n str += `[${segment}]`\n } else if (prev) {\n str += `.${segment}`\n } else {\n str += `${segment}`\n }\n }\n return str\n}\n\n/**\n * @ignore\n */\nconst makePath = function (opts) {\n opts || (opts = {})\n let path = ''\n const segments = opts.path || []\n segments.forEach(function (segment) {\n path += segmentToString(segment, path)\n })\n path += segmentToString(opts.prop, path)\n return path\n}\n\n/**\n * @ignore\n */\nconst makeError = function (actual, expected, opts) {\n return {\n expected,\n actual: '' + actual,\n path: makePath(opts)\n }\n}\n\n/**\n * @ignore\n */\nconst addError = function (actual, expected, opts, errors) {\n errors.push(makeError(actual, expected, opts))\n}\n\n/**\n * @ignore\n */\nconst maxLengthCommon = function (keyword, value, schema, opts) {\n const max = schema[keyword]\n if (value.length > max) {\n return makeError(value.length, `length no more than ${max}`, opts)\n }\n}\n\n/**\n * @ignore\n */\nconst minLengthCommon = function (keyword, value, schema, opts) {\n const min = schema[keyword]\n if (value.length < min) {\n return makeError(value.length, `length no less than ${min}`, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name Schema.validationKeywords\n * @type {Object}\n */\nconst validationKeywords = {\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor82\n *\n * @name Schema.validationKeywords.allOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n allOf (value, schema, opts) {\n let allErrors = []\n schema.allOf.forEach(function (_schema) {\n allErrors = allErrors.concat(validate(value, _schema, opts) || [])\n })\n return allErrors.length ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor85\n *\n * @name Schema.validationKeywords.anyOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n anyOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.anyOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor70\n *\n * @name Schema.validationKeywords.dependencies\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n dependencies (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor76\n *\n * @name Schema.validationKeywords.enum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n enum (value, schema, opts) {\n const possibleValues = schema['enum']\n if (possibleValues.indexOf(value) === -1) {\n return makeError(value, `one of (${possibleValues.join(', ')})`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor37\n *\n * @name Schema.validationKeywords.items\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n items (value, schema, opts) {\n opts || (opts = {})\n // TODO: additionalItems\n let items = schema.items\n let errors = []\n const checkingTuple = utils.isArray(items)\n const length = value.length\n for (var prop = 0; prop < length; prop++) {\n if (checkingTuple) {\n // Validating a tuple, instead of just checking each item against the\n // same schema\n items = schema.items[prop]\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], items, opts) || [])\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor17\n *\n * @name Schema.validationKeywords.maximum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maximum (value, schema, opts) {\n // Must be a number\n const maximum = schema.maximum\n // Must be a boolean\n // Depends on maximum\n // default: false\n const exclusiveMaximum = schema.exclusiveMaximum\n if (typeof value === typeof maximum && (exclusiveMaximum ? maximum < value : maximum <= value)) {\n // TODO: Account for value of exclusiveMaximum in messaging\n return makeError(value, `no more than ${maximum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.maxItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxItems (value, schema, opts) {\n return maxLengthCommon('maxItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor26\n *\n * @name Schema.validationKeywords.maxLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxLength (value, schema, opts) {\n return maxLengthCommon('maxLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor54\n *\n * @name Schema.validationKeywords.maxProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxProperties (value, schema, opts) {\n const maxProperties = schema.maxProperties\n const length = Object.keys(value).length\n if (length > maxProperties) {\n return makeError(length, `no more than ${maxProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor21\n *\n * @name Schema.validationKeywords.minimum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minimum (value, schema, opts) {\n // Must be a number\n const minimum = schema.minimum\n // Must be a boolean\n // Depends on minimum\n // default: false\n const exclusiveMinimum = schema.exclusiveMinimum\n if (typeof value === typeof minimum && (exclusiveMinimum ? minimum > value : minimum >= value)) {\n // TODO: Account for value of exclusiveMinimum in messaging\n return makeError(value, `no less than ${minimum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.minItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minItems (value, schema, opts) {\n return minLengthCommon('minItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor29\n *\n * @name Schema.validationKeywords.minLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minLength (value, schema, opts) {\n return minLengthCommon('minLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor57\n *\n * @name Schema.validationKeywords.minProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minProperties (value, schema, opts) {\n const minProperties = schema.minProperties\n const length = Object.keys(value).length\n if (length < minProperties) {\n return makeError(length, `no more than ${minProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor14\n *\n * @name Schema.validationKeywords.multipleOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n multipleOf (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor91\n *\n * @name Schema.validationKeywords.not\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n not (value, schema, opts) {\n if (!validate(value, schema.not, opts)) {\n // TODO: better messaging\n return makeError('succeeded', 'should have failed', opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor88\n *\n * @name Schema.validationKeywords.oneOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n oneOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.oneOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else if (validated) {\n allErrors = [makeError('valid against more than one', 'valid against only one', opts)]\n validated = false\n return false\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor33\n *\n * @name Schema.validationKeywords.pattern\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n pattern (value, schema, opts) {\n const pattern = schema.pattern\n if (utils.isString(value) && !value.match(pattern)) {\n return makeError(value, pattern, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor64\n *\n * @name Schema.validationKeywords.properties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n properties (value, schema, opts) {\n opts || (opts = {})\n // Can be a boolean or an object\n // Technically the default is an \"empty schema\", but here \"true\" is\n // functionally the same\n const additionalProperties = utils.isUndefined(schema.additionalProperties) ? true : schema.additionalProperties\n // \"s\": The property set of the instance to validate.\n const toValidate = {}\n // \"p\": The property set from \"properties\".\n // Default is an object\n const properties = schema.properties || {}\n // \"pp\": The property set from \"patternProperties\".\n // Default is an object\n const patternProperties = schema.patternProperties || {}\n let errors = []\n\n // Collect set \"s\"\n utils.forOwn(value, function (_value, prop) {\n toValidate[prop] = undefined\n })\n // Remove from \"s\" all elements of \"p\", if any.\n utils.forOwn(properties || {}, function (_schema, prop) {\n if (utils.isUndefined(value[prop]) && !utils.isUndefined(_schema['default'])) {\n value[prop] = utils.copy(_schema['default'])\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n })\n // For each regex in \"pp\", remove all elements of \"s\" which this regex\n // matches.\n utils.forOwn(patternProperties, function (_schema, pattern) {\n utils.forOwn(toValidate, function (undef, prop) {\n if (prop.match(pattern)) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n }\n })\n })\n const keys = Object.keys(toValidate)\n // If \"s\" is not empty, validation fails\n if (additionalProperties === false) {\n if (keys.length) {\n addError(`extra fields: ${keys.join(', ')}`, 'no extra fields', opts, errors)\n }\n } else if (utils.isObject(additionalProperties)) {\n // Otherwise, validate according to provided schema\n keys.forEach(function (prop) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], additionalProperties, opts) || [])\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor61\n *\n * @name Schema.validationKeywords.required\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n required (value, schema, opts) {\n const required = schema.required\n let errors = []\n if (!opts.existingOnly) {\n required.forEach(function (prop) {\n if (utils.isUndefined(utils.get(value, prop))) {\n const prevProp = opts.prop\n opts.prop = prop\n addError(undefined, 'a value', opts, errors)\n opts.prop = prevProp\n }\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor79\n *\n * @name Schema.validationKeywords.type\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n type (value, schema, opts) {\n let type = schema.type\n let validType\n // Can be one of several types\n if (utils.isString(type)) {\n type = [type]\n }\n // Try to match the value against an expected type\n type.forEach(function (_type) {\n // TODO: throw an error if type is not defined\n if (types[_type](value, schema, opts)) {\n // Matched a type\n validType = _type\n return false\n }\n })\n // Value did not match any expected type\n if (!validType) {\n return makeError(value ? typeof value : '' + value, `one of (${type.join(', ')})`, opts)\n }\n // Run keyword validators for matched type\n // http://json-schema.org/latest/json-schema-validation.html#anchor12\n const validator = typeGroupValidators[validType]\n if (validator) {\n return validator(value, schema, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor49\n *\n * @name Schema.validationKeywords.uniqueItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n uniqueItems (value, schema, opts) {\n if (value && value.length && schema.uniqueItems) {\n const length = value.length\n let item, i, j\n // Check n - 1 items\n for (i = length - 1; i > 0; i--) {\n item = value[i]\n // Only compare against unchecked items\n for (j = i - 1; j >= 0; j--) {\n // Found a duplicate\n if (item === value[j]) {\n return makeError(item, 'no duplicates', opts)\n }\n }\n }\n }\n }\n}\n\n/**\n * @ignore\n */\nconst validateKeyword = function (op, value, schema, opts) {\n return !utils.isUndefined(schema[op]) && validationKeywords[op](value, schema, opts)\n}\n\n/**\n * @ignore\n */\nconst runOps = function (ops, value, schema, opts) {\n let errors = []\n ops.forEach(function (op) {\n errors = errors.concat(validateKeyword(op, value, schema, opts) || [])\n })\n return errors.length ? errors : undefined\n}\n\nconst ANY_OPS = ['enum', 'type', 'allOf', 'anyOf', 'oneOf', 'not']\nconst ARRAY_OPS = ['items', 'maxItems', 'minItems', 'uniqueItems']\nconst NUMERIC_OPS = ['multipleOf', 'maximum', 'minimum']\nconst OBJECT_OPS = ['maxProperties', 'minProperties', 'required', 'properties', 'dependencies']\nconst STRING_OPS = ['maxLength', 'minLength', 'pattern']\n\n/**\n * http://json-schema.org/latest/json-schema-validation.html#anchor75\n * @ignore\n */\nconst validateAny = function (value, schema, opts) {\n return runOps(ANY_OPS, value, schema, opts)\n}\n\n/**\n * TODO\n *\n * @name Schema.validate\n * @method\n * @param {*} value TODO\n * @param {Object} [schema] TODO\n * @param {Object} [opts] Configuration options.\n */\nconst validate = function (value, schema, opts) {\n let errors = []\n opts || (opts = {})\n let shouldPop\n let prevProp = opts.prop\n if (utils.isUndefined(schema)) {\n return\n }\n if (!utils.isObject(schema)) {\n throw utils.err(`${DOMAIN}#validate`)(500, `Invalid schema at path: \"${opts.path}\"`)\n }\n if (utils.isUndefined(opts.path)) {\n opts.path = []\n }\n // Track our location as we recurse\n if (!utils.isUndefined(opts.prop)) {\n shouldPop = true\n opts.path.push(opts.prop)\n opts.prop = undefined\n }\n // Validate against parent schema\n if (schema['extends']) {\n // opts.path = path\n // opts.prop = prop\n if (utils.isFunction(schema['extends'].validate)) {\n errors = errors.concat(schema['extends'].validate(value, opts) || [])\n } else {\n errors = errors.concat(validate(value, schema['extends'], opts) || [])\n }\n }\n if (utils.isUndefined(value)) {\n // Check if property is required\n if (schema.required === true) {\n addError(value, 'a value', opts, errors)\n }\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n }\n errors = errors.concat(validateAny(value, schema, opts) || [])\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n}\n\n// These strings are cached for optimal performance of the change detection\n// boolean - Whether a Record is changing in the current execution frame\nconst changingPath = 'changing'\n// string[] - Properties that have changed in the current execution frame\nconst changedPath = 'changed'\n// boolean - Whether a Record is currently being instantiated\nconst creatingPath = 'creating'\n// number - The setTimeout change event id of a Record, if any\nconst eventIdPath = 'eventId'\n// boolean - Whether to skip validation for a Record's currently changing property\nconst noValidatePath = 'noValidate'\n// boolean - Whether to skip change notification for a Record's currently\n// changing property\nconst silentPath = 'silent'\nconst validationFailureMsg = 'validation failed'\n\n/**\n * Assemble a property descriptor which will be added to the prototype of\n * {@link Mapper#recordClass}. This method is called when\n * {@link Mapper#applySchema} is set to `true`.\n *\n * TODO: Make this more configurable, i.e. not so tied to the Record class.\n *\n * @ignore\n */\nconst makeDescriptor = function (prop, schema, opts) {\n const descriptor = {\n // These properties are enumerable by default, but regardless of their\n // enumerability, they won't be \"own\" properties of individual records\n enumerable: utils.isUndefined(schema.enumerable) ? true : !!schema.enumerable\n }\n // Cache a few strings for optimal performance\n const keyPath = `props.${prop}`\n const previousPath = `previous.${prop}`\n const getter = opts.getter\n const setter = opts.setter\n const unsetter = opts.unsetter\n\n descriptor.get = function () { return this._get(keyPath) }\n descriptor.set = function (value) {\n const self = this\n // These are accessed a lot\n const _get = self[getter]\n const _set = self[setter]\n const _unset = self[unsetter]\n\n // Optionally check that the new value passes validation\n if (!_get(noValidatePath)) {\n const errors = schema.validate(value)\n if (errors) {\n // Immediately throw an error, preventing the record from getting into\n // an invalid state\n const error = new Error(validationFailureMsg)\n error.errors = errors\n throw error\n }\n }\n // TODO: Make it so tracking can be turned on for all properties instead of\n // only per-property\n if (schema.track && !_get(creatingPath)) {\n const previous = _get(previousPath)\n const current = _get(keyPath)\n let changing = _get(changingPath)\n let changed = _get(changedPath)\n\n if (!changing) {\n // Track properties that are changing in the current event loop\n changed = []\n }\n\n // Add changing properties to this array once at most\n const index = changed.indexOf(prop)\n if (current !== value && index === -1) {\n changed.push(prop)\n }\n if (previous === value) {\n if (index >= 0) {\n changed.splice(index, 1)\n }\n }\n // No changes in current event loop\n if (!changed.length) {\n changing = false\n _unset(changingPath)\n _unset(changedPath)\n // Cancel pending change event\n if (_get(eventIdPath)) {\n clearTimeout(_get(eventIdPath))\n _unset(eventIdPath)\n }\n }\n // Changes detected in current event loop\n if (!changing && changed.length) {\n _set(changedPath, changed)\n _set(changingPath, true)\n // Saving the timeout id allows us to batch all changes in the same\n // event loop into a single \"change\"\n // TODO: Optimize\n _set(eventIdPath, setTimeout(() => {\n // Previous event loop where changes were gathered has ended, so\n // notify any listeners of those changes and prepare for any new\n // changes\n _unset(changedPath)\n _unset(eventIdPath)\n _unset(changingPath)\n // TODO: Optimize\n if (!_get(silentPath)) {\n let i\n for (i = 0; i < changed.length; i++) {\n self.emit('change:' + changed[i], self, utils.get(self, changed[i]))\n }\n self.emit('change', self, self.changes())\n }\n _unset(silentPath)\n }, 0))\n }\n }\n _set(keyPath, value)\n return value\n }\n\n return descriptor\n}\n\n/**\n * TODO\n *\n * @name Schema.typeGroupValidators\n * @type {Object}\n */\nconst typeGroupValidators = {\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.array\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n array: function (value, schema, opts) {\n return runOps(ARRAY_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.integer\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n integer: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.number\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n number: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor13.\n *\n * @name Schema.typeGroupValidators.numeric\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n numeric: function (value, schema, opts) {\n return runOps(NUMERIC_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor53.\n *\n * @name Schema.typeGroupValidators.object\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n object: function (value, schema, opts) {\n return runOps(OBJECT_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor25.\n *\n * @name Schema.typeGroupValidators.string\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n string: function (value, schema, opts) {\n return runOps(STRING_OPS, value, schema, opts)\n }\n}\n\n/**\n * js-data's Schema class.\n *\n * ```javascript\n * import {Schema} from 'js-data'\n * ```\n *\n * @class Schema\n * @extends Component\n * @param {Object} definition Schema definition according to json-schema.org\n */\nexport default Component.extend({\n constructor: function Schema (definition) {\n // const self = this\n definition || (definition = {})\n // TODO: schema validation\n utils.fillIn(this, definition)\n\n // TODO: rework this to make sure all possible keywords are converted\n if (definition.properties) {\n utils.forOwn(definition.properties, function (_definition, prop) {\n if (!(_definition instanceof Schema)) {\n definition.properties[prop] = new Schema(_definition)\n }\n })\n }\n },\n\n /**\n * This adds ES5 getters/setters to the target based on the \"properties\" in\n * this Schema, which makes possible change tracking and validation on\n * property assignment.\n *\n * @name Schema#validate\n * @method\n * @param {Object} target The prototype to which to apply this schema.\n */\n apply (target, opts) {\n opts || (opts = {})\n opts.getter = opts.getter || '_get'\n opts.setter = opts.setter || '_set'\n opts.unsetter = opts.unsetter || '_unset'\n const properties = this.properties || {}\n utils.forOwn(properties, function (schema, prop) {\n Object.defineProperty(\n target,\n prop,\n makeDescriptor(prop, schema, opts)\n )\n })\n },\n\n /**\n * Validate the provided value against this schema.\n *\n * @name Schema#validate\n * @method\n * @param {*} value Value to validate.\n * @param {Object} [opts] Configuration options.\n * @return {(array|undefined)} Array of errors or `undefined` if valid.\n */\n validate (value, opts) {\n return validate(value, this, opts)\n }\n}, {\n typeGroupValidators,\n types,\n validate,\n validationKeywords\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Record from './Record'\nimport Schema from './Schema'\nimport {\n belongsTo,\n belongsToType,\n hasMany,\n hasManyType,\n hasOne,\n hasOneType\n} from './decorators'\n\nconst DOMAIN = 'Mapper'\n\nconst makeNotify = function (num) {\n return function (...args) {\n const self = this\n const opts = args[args.length - num]\n self.dbg(opts.op, ...args)\n if (opts.notify || (opts.notify === undefined && self.notify)) {\n setTimeout(() => {\n self.emit(opts.op, ...args)\n })\n }\n }\n}\n\n// These are the default implementations of all of the lifecycle hooks\nconst notify = makeNotify(1)\nconst notify2 = makeNotify(2)\n\n// This object provides meta information used by Mapper#crud to actually\n// execute each lifecycle method\nconst LIFECYCLE_METHODS = {\n count: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroy: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroyAll: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n find: {\n defaults: [undefined, {}],\n types: []\n },\n findAll: {\n defaults: [{}, {}],\n types: []\n },\n sum: {\n defaults: [undefined, {}, {}],\n skip: true,\n types: []\n },\n update: {\n adapterArgs (mapper, id, props, opts) {\n return [id, mapper.toJSON(props, opts), opts]\n },\n beforeAssign: 1,\n defaults: [undefined, {}, {}],\n types: []\n },\n updateAll: {\n adapterArgs (mapper, props, query, opts) {\n return [mapper.toJSON(props, opts), query, opts]\n },\n beforeAssign: 0,\n defaults: [{}, {}, {}],\n types: []\n },\n updateMany: {\n adapterArgs (mapper, records, opts) {\n return [records.map(function (record) {\n return mapper.toJSON(record, opts)\n }), opts]\n },\n beforeAssign: 0,\n defaults: [[], {}],\n types: []\n }\n}\n\nconst MAPPER_DEFAULTS = {\n /**\n * Hash of registered adapters. Don't modify directly. Use {@link Mapper#registerAdapter}.\n *\n * @name Mapper#_adapters\n */\n _adapters: {},\n\n /**\n * Whether to augment {@link Mapper#recordClass} with getter/setter property\n * accessors according to the properties defined in {@link Mapper#schema}.\n * This makes possible validation and change tracking on individual properties\n * when using the dot (e.g. `user.name = \"Bob\"`) operator to modify a\n * property.\n *\n * @name Mapper#applySchema\n * @type {boolean}\n * @default true\n */\n applySchema: true,\n\n /**\n * Whether to enable debug-level logs.\n *\n * @name Mapper#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * The name of the registered adapter that this Mapper should used by default.\n *\n * @name Mapper#defaultAdapter\n * @type {string}\n * @default \"http\"\n */\n defaultAdapter: 'http',\n\n /**\n * The field used as the unique identifier on records handled by this Mapper.\n *\n * @name Mapper#idAttribute\n * @type {string}\n * @default id\n */\n idAttribute: 'id',\n\n /**\n * Whether this Mapper should emit operational events.\n *\n * Defaults to `true` in the browser and `false` in Node.js\n *\n * @name Mapper#notify\n * @type {boolean}\n */\n notify: utils.isBrowser,\n\n /**\n * Whether {@link Mapper#create}, {@link Mapper#createMany}, {@link Mapper#save},\n * {@link Mapper#update}, {@link Mapper#updateAll}, {@link Mapper#updateMany},\n * {@link Mapper#find}, {@link Mapper#findAll}, {@link Mapper#destroy}, and\n * {@link Mapper#destroyAll} should return a raw result object that contains\n * both the instance data returned by the adapter _and_ metadata about the\n * operation.\n *\n * The default is to NOT return the result object, and instead return just the\n * instance data.\n *\n * @name Mapper#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * ```javascript\n * import {Mapper} from 'js-data'\n * ```\n *\n * The core of JSData's [ORM/ODM][orm] implementation. Given a minimum amout of\n * meta information about a resource, a Mapper can perform generic CRUD\n * operations against that resource. Apart from its configuration, a Mapper is\n * stateless. The particulars of various persistence layers has been abstracted\n * into adapters, which a Mapper uses to perform its operations.\n *\n * The term \"Mapper\" comes from the [Data Mapper Pattern][pattern] described in\n * Martin Fowler's [Patterns of Enterprise Application Architecture][book]. A\n * Data Mapper moves data between [in-memory object instances][record] and a\n * relational or document-based database. JSData's Mapper can work with any\n * persistence layer you can write an adapter for.\n *\n * _(\"Model\" is a heavily overloaded term and is avoided in this documentation\n * to prevent confusion.)_\n *\n * [orm]: https://en.wikipedia.org/wiki/Object-relational_mapping\n * [pattern]: https://en.wikipedia.org/wiki/Data_mapper_pattern\n * [book]: http://martinfowler.com/books/eaa.html\n * [record]: Record.html\n *\n * @class Mapper\n * @extends Component\n * @param {Object} opts Configuration options.\n * @param {boolean} [opts.applySchema=true] Whether to apply this Mapper's\n * {@link Schema} to the prototype of this Mapper's Record class. The enables\n * features like active change detection, validation during use of the\n * assignment operator, etc.\n * @param {boolean} [opts.debug=false] Wether to log debugging information\n * during operation.\n * @param {string} [opts.defaultAdapter=http] The name of the adapter to use by\n * default.\n * @param {string} [opts.idAttribute=id] The field that uniquely identifies\n * Records that this Mapper will be dealing with. Typically called a primary\n * key.\n * @param {string} opts.name The name for this Mapper. This is the minimum\n * amount of meta information required for a Mapper to be able to execute CRUD\n * operations for a \"Resource\".\n * @param {boolean} [opts.notify] Whether to emit lifecycle events.\n * @param {boolean} [opts.raw=false] Whether lifecycle methods should return a\n * more detailed reponse object instead of just a Record instance or Record\n * instances.\n */\nexport default Component.extend({\n constructor: function Mapper (opts) {\n const self = this\n utils.classCallCheck(self, Mapper)\n Mapper.__super__.call(self)\n opts || (opts = {})\n\n // Prepare certain properties to be non-enumerable\n Object.defineProperties(self, {\n _adapters: {\n value: undefined,\n writable: true\n },\n\n /**\n * Set the `false` to force the Mapper to work with POJO objects only.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * const UserMapper = new Mapper({ recordClass: false })\n * UserMapper.recordClass // false\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * ```\n *\n * Set to a custom class to have records wrapped in your custom class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User {\n * constructor (props = {}) {\n * for (var key in props) {\n * if (props.hasOwnProperty(key)) {\n * this[key] = props[key]\n * }\n * }\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * user instanceof User // true\n * ```\n *\n * Extend the {@link Record} class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User extends Record {\n * constructor () {\n * super(props)\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // true\n * user instanceof User // true\n * ```\n *\n * @name Mapper#recordClass\n * @default {@link Record}\n */\n recordClass: {\n value: undefined,\n writable: true\n },\n\n lifecycleMethods: {\n value: LIFECYCLE_METHODS\n },\n\n schema: {\n value: undefined,\n writable: true\n }\n })\n\n // Apply user-provided configuration\n utils.fillIn(self, opts)\n // Fill in any missing options with the defaults\n utils.fillIn(self, utils.copy(MAPPER_DEFAULTS))\n\n /**\n * Minimum amount of meta information required for a Mapper to be able to\n * execute CRUD operations for a \"Resource\".\n *\n * @name Mapper#name\n * @type {string}\n */\n if (!self.name) {\n throw utils.err(`new ${DOMAIN}`, 'opts.name')(400, 'string', self.name)\n }\n\n // Setup schema, with an empty default schema if necessary\n if (!(self.schema instanceof Schema)) {\n self.schema = new Schema(self.schema || {})\n }\n\n // Create a subclass of Record that's tied to this Mapper\n if (utils.isUndefined(self.recordClass)) {\n const superClass = Record\n self.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n\n if (self.recordClass) {\n self.recordClass.mapper = self\n\n // We can only apply the schema to the prototype of self.recordClass if the\n // class extends Record\n if (utils.getSuper(self.recordClass, true) === Record && self.schema && self.schema.apply && self.applySchema) {\n self.schema.apply(self.recordClass.prototype)\n }\n }\n },\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n * @param {*} result The result, if any.\n */\n afterCount: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n * @param {*} result The result, if any.\n */\n afterCreate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n * @param {*} result The result, if any.\n */\n afterCreateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n * @param {*} result The result, if any.\n */\n afterDestroy: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroyAll\n * @method\n * @param {*} data The `data` returned by the adapter.\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n * @param {*} result The result, if any.\n */\n afterDestroyAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n * @param {*} result The result, if any.\n */\n afterFind: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n * @param {*} result The result, if any.\n */\n afterFindAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterSum\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n * @param {*} result The result, if any.\n */\n afterSum: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n * @param {*} result The result, if any.\n */\n afterUpdate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n * @param {*} result The result, if any.\n */\n afterUpdateAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n * @param {*} result The result, if any.\n */\n afterUpdateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n */\n beforeCreate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n */\n beforeCreateMany: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n */\n beforeCount: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n */\n beforeDestroy: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroyAll\n * @method\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n */\n beforeDestroyAll: notify,\n\n /**\n * Mappers lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n */\n beforeFind: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n */\n beforeFindAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeSum\n * @method\n * @param {string} field The `field` argument passed to {@link Mapper#sum}.\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n */\n beforeSum: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n */\n beforeUpdate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n */\n beforeUpdateAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n */\n beforeUpdateMany: notify,\n\n /**\n * This method is called at the end of most lifecycle methods. It does the\n * following:\n *\n * 1. If `opts.raw` is `true`, add this Mapper's configuration to the `opts`\n * argument as metadata for the operation.\n * 2. Wrap the result data appropriately using {@link Mapper#wrap}, which\n * calls {@link Mapper#createRecord}.\n *\n * @name Mapper#_end\n * @method\n * @private\n */\n _end (result, opts, skip) {\n const self = this\n if (opts.raw) {\n utils._(result, opts)\n }\n if (skip) {\n return result\n }\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(self.wrap)) {\n _data = self.wrap(_data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Define a belongsTo relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * Post.belongsTo(User, {\n * localKey: 'myUserId'\n * })\n *\n * Comment.belongsTo(User)\n * Comment.belongsTo(Post, {\n * localField: '_post'\n * })\n * ```\n *\n * @name Mapper#belongsTo\n * @method\n */\n belongsTo (relatedMapper, opts) {\n return belongsTo(relatedMapper, opts)(this)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeCount} will be called before calling the adapter.\n * {@link Mapper#afterCount} will be called after calling the adapter.\n *\n * @name Mapper#count\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n count (query, opts) {\n return this.crud('count', query, opts)\n },\n\n /**\n * Create and save a new the record using the provided `props`.\n *\n * {@link Mapper#beforeCreate} will be called before calling the adapter.\n * {@link Mapper#afterCreate} will be called after calling the adapter.\n *\n * @name Mapper#create\n * @method\n * @param {Object} props The properties for the new record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * created data. If `true` return a response object that includes the created\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `props` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#create}\n * or {@link Mapper#createMany} call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n create (props, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n props || (props = {})\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n const relatedMapper = def.getRelation()\n const relatedIdAttribute = relatedMapper.idAttribute\n optsCopy.raw = false\n if (!relationData) {\n return\n }\n if (def.type === belongsToType) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(relatedMapper.create(relationData, optsCopy).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n def.setForeignKey(props, data)\n }))\n } else if (def.type === hasManyType && def.localKeys) {\n // Create his hasMany relation first because it uses localKeys\n tasks.push(relatedMapper.createMany(relationData, optsCopy).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n utils.set(props, def.localKeys, data.map(function (record) {\n return utils.get(record, relatedIdAttribute)\n }))\n }))\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter for the main create\n op = opts.op = 'create'\n self.dbg(op, props, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, self.toJSON(props, { with: opts.pass || [] }), opts))\n }).then(function (data) {\n const createdRecord = opts.raw ? data.data : data\n // Deep post-create hasMany and hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n if (!relationData) {\n return\n }\n optsCopy.raw = false\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType && def.foreignKey) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, data)\n })\n } else if (def.type === hasOneType) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().create(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, data)\n })\n } else if (def.type === belongsToType && def.getLocalField(belongsToRelationData)) {\n def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData))\n } else if (def.type === hasManyType && def.localKeys && def.getLocalField(belongsToRelationData)) {\n def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData))\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](props, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n createInstance (props, opts) {\n return this.createRecord(props, opts)\n },\n\n /**\n * Given an array of records, batch create them via an adapter.\n *\n * {@link Mapper#beforeCreateMany} will be called before calling the adapter.\n * {@link Mapper#afterCreateMany} will be called after calling the adapter.\n *\n * @name Mapper#createMany\n * @method\n * @param {Array} records Array of records to be created in one batch.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `records` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#createMany}\n * call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n createMany (records, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (def.type === belongsToType && relationData.length === records.length) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedRecords = optsCopy.raw ? data.data : data\n def.setLocalField(belongsToRelationData, relatedRecords)\n records.forEach(function (record, i) {\n def.setForeignKey(record, relatedRecords[i])\n })\n }))\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter\n op = opts.op = 'createMany'\n const json = records.map(function (record) {\n return self.toJSON(record, { with: opts.pass || [] })\n })\n self.dbg(op, records, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, json, opts))\n }).then(function (data) {\n const createdRecords = opts.raw ? data.data : data\n\n // Deep post-create hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (relationData.length !== records.length) {\n return\n }\n const belongsToData = def.getLocalField(belongsToRelationData)\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType) {\n // Not supported\n self.log('warn', 'deep createMany of hasMany type not supported!')\n } else if (def.type === hasOneType) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setForeignKey(createdRecord, relationData[i])\n })\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedData = opts.raw ? data.data : data\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, relatedData[i])\n })\n })\n } else if (def.type === belongsToType && belongsToData && belongsToData.length === createdRecords.length) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, belongsToData[i])\n })\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](records, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Create an unsaved, uncached instance of this Mapper's\n * {@link Mapper#recordClass}.\n *\n * Returns `props` if `props` is already an instance of\n * {@link Mapper#recordClass}.\n *\n * @name Mapper#createRecord\n * @method\n * @param {Object|Array} props The properties for the Record instance or an\n * array of property objects for the Record instances.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation when\n * the Record instances are created.\n * @return {Object|Array} The Record instance or Record instances.\n */\n createRecord (props, opts) {\n props || (props = {})\n const self = this\n if (utils.isArray(props)) {\n return props.map(function (_props) {\n return self.createRecord(_props, opts)\n })\n }\n if (!utils.isObject(props)) {\n throw utils.err(`${DOMAIN}#createRecord`, 'props')(400, 'array or object', props)\n }\n const recordClass = self.recordClass\n const relationList = self.relationList || []\n relationList.forEach(function (def) {\n const relatedMapper = def.getRelation()\n const relationData = def.getLocalField(props)\n if (relationData && !relatedMapper.is(relationData)) {\n if (utils.isArray(relationData) && (!relationData.length || relatedMapper.is(relationData[0]))) {\n return\n }\n utils.set(props, def.localField, relatedMapper.createRecord(relationData, opts))\n }\n })\n // Check to make sure \"props\" is not already an instance of this Mapper.\n return recordClass ? (props instanceof recordClass ? props : new recordClass(props, opts)) : props // eslint-disable-line\n },\n\n /**\n * Lifecycle invocation method.\n *\n * @name Mapper#crud\n * @method\n * @param {string} method Name of the lifecycle method to invoke.\n * @param {...*} args Arguments to pass to the lifecycle method.\n * @return {Promise}\n */\n crud (method, ...args) {\n const self = this\n const config = self.lifecycleMethods[method]\n if (!config) {\n throw utils.err(`${DOMAIN}#crud`, method)(404, 'method')\n }\n\n const upper = `${method.charAt(0).toUpperCase()}${method.substr(1)}`\n const before = `before${upper}`\n const after = `after${upper}`\n\n let op, adapter\n\n // Default values for arguments\n config.defaults.forEach(function (value, i) {\n if (utils.isUndefined(args[i])) {\n args[i] = utils.copy(value)\n }\n })\n\n const opts = args[args.length - 1]\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // before lifecycle hook\n op = opts.op = before\n return utils.resolve(self[op](...args)).then(function (_value) {\n if (!utils.isUndefined(config.beforeAssign)) {\n // Allow for re-assignment from lifecycle hook\n args[config.beforeAssign] = utils.isUndefined(_value) ? args[config.beforeAssign] : _value\n }\n // Now delegate to the adapter\n op = opts.op = method\n args = config.adapterArgs ? config.adapterArgs(self, ...args) : args\n self.dbg(op, ...args)\n return utils.resolve(self.getAdapter(adapter)[op](self, ...args))\n }).then(function (result) {\n result = self._end(result, opts, !!config.skip)\n args.push(result)\n // after lifecycle hook\n op = opts.op = after\n return utils.resolve(self[op](...args)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Using an adapter, destroy the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeDestroy} will be called before destroying the record.\n * {@link Mapper#afterDestroy} will be called after destroying the record.\n *\n * @name Mapper#destroy\n * @method\n * @param {(string|number)} id The primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroy (id, opts) {\n return this.crud('destroy', id, opts)\n },\n\n /**\n * Using the `query` argument, destroy the selected records via an adapter.\n * If no `query` is provided then all records will be destroyed.\n *\n * {@link Mapper#beforeDestroyAll} will be called before destroying the records.\n * {@link Mapper#afterDestroyAll} will be called after destroying the records.\n *\n * @name Mapper#destroyAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroyAll (query, opts) {\n return this.crud('destroyAll', query, opts)\n },\n\n /**\n * Retrieve via an adapter the record with the given primary key.\n *\n * {@link Mapper#beforeFind} will be called before calling the adapter.\n * {@link Mapper#afterFind} will be called after calling the adapter.\n *\n * @name Mapper#find\n * @method\n * @param {(string|number)} id The primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n find (id, opts) {\n return this.crud('find', id, opts)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeFindAll} will be called before calling the adapter.\n * {@link Mapper#afterFindAll} will be called after calling the adapter.\n *\n * @name Mapper#findAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n findAll (query, opts) {\n return this.crud('findAll', query, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Mapper#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n self.dbg('getAdapter', 'name:', name)\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw utils.err(`${DOMAIN}#getAdapter`, 'name')(400, 'string', name)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Mapper#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || opts.defaultAdapter\n },\n\n /**\n * @name Mapper#getAdapters\n * @method\n * @return {Object} This Mapper's adapters\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Returns this Mapper's schema.\n *\n * @return {Schema} This Mapper's schema.\n */\n getSchema () {\n return this.schema\n },\n\n /**\n * Defines a hasMany relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasMany(Post, {\n * localField: 'my_posts'\n * })\n * ```\n *\n * @name Mapper#hasMany\n * @method\n */\n hasMany (relatedMapper, opts) {\n return hasMany(relatedMapper, opts)(this)\n },\n\n /**\n * Defines a hasOne relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasOne(Profile, {\n * localField: '_profile'\n * })\n * ```\n *\n * @name Mapper#hasOne\n * @method\n */\n hasOne (relatedMapper, opts) {\n return hasOne(relatedMapper, opts)(this)\n },\n\n /**\n * Return whether `record` is an instance of this Mapper's recordClass.\n *\n * @name Mapper#is\n * @method\n * @param {Object} record The record to check.\n * @return {boolean} Whether `record` is an instance of this Mapper's\n * {@link Mapper#recordClass}.\n */\n is (record) {\n const recordClass = this.recordClass\n return recordClass ? record instanceof recordClass : false\n },\n\n /**\n * Register an adapter on this mapper under the given name.\n *\n * @name Mapper#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for this Mapper.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.defaultAdapter = name\n }\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeSum} will be called before calling the adapter.\n * {@link Mapper#afterSum} will be called after calling the adapter.\n *\n * @name Mapper#sum\n * @method\n * @param {string} field The field to sum.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n sum (field, query, opts) {\n return this.crud('sum', field, query, opts)\n },\n\n /**\n * Return a plain object representation of the given record.\n *\n * @name Mapper#toJSON\n * @method\n * @param {Object} record Record from which to create a plain object\n * representation.\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation.\n * @return {Object} Plain object representation of the record.\n */\n toJSON (record, opts) {\n const self = this\n opts || (opts = {})\n const relationFields = (self ? self.relationFields : []) || []\n let json = {}\n let properties\n if (self && self.schema) {\n properties = self.schema.properties || {}\n // TODO: Make this work recursively\n utils.forOwn(properties, function (opts, prop) {\n json[prop] = utils.plainCopy(record[prop])\n })\n }\n properties || (properties = {})\n if (!opts.strict) {\n for (var key in record) {\n if (!properties[key] && relationFields.indexOf(key) === -1) {\n json[key] = utils.plainCopy(record[key])\n }\n }\n }\n // The user wants to include relations in the resulting plain object\n // representation\n if (self && opts.withAll) {\n opts.with = relationFields.slice()\n }\n if (self && opts.with) {\n if (utils.isString(opts.with)) {\n opts.with = [opts.with]\n }\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(record)\n if (relationData) {\n // The actual recursion\n if (utils.isArray(relationData)) {\n def.setLocalField(json, relationData.map(function (item) {\n return def.getRelation().toJSON(item, optsCopy)\n }))\n } else {\n def.setLocalField(json, def.getRelation().toJSON(relationData, optsCopy))\n }\n }\n })\n }\n return json\n },\n\n /**\n * Using an adapter, update the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeUpdate} will be called before updating the record.\n * {@link Mapper#afterUpdate} will be called after updating the record.\n *\n * @name Mapper#update\n * @method\n * @param {(string|number)} id The primary key of the record to update.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n update (id, props, opts) {\n return this.crud('update', id, props, opts)\n },\n\n /**\n * Using the `query` argument, perform the a single updated to the selected\n * records. Expects back from the adapter an array of the updated records.\n *\n * {@link Mapper#beforeUpdateAll} will be called before making the update.\n * {@link Mapper#afterUpdateAll} will be called after making the update.\n *\n * @name Mapper#updateAll\n * @method\n * @param {Object} props Update to apply to selected records.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n updateAll (props, query, opts) {\n return this.crud('updateAll', props, query, opts)\n },\n\n /**\n * Given an array of updates, perform each of the updates via an adapter. Each\n * \"update\" is a hash of properties with which to update an record. Each\n * update must contain the primary key to be updated.\n *\n * {@link Mapper#beforeUpdateMany} will be called before making the update.\n * {@link Mapper#afterUpdateMany} will be called after making the update.\n *\n * @name Mapper#updateMany\n * @method\n * @param {Array} records Array up record updates.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if each record update contains nested updates for relations. NOT\n * performed in a transaction.\n * @return {Promise}\n */\n updateMany (records, opts) {\n return this.crud('updateMany', records, opts)\n },\n\n /**\n * Validate the given record or records according to this Mapper's\n * {@link Schema}. No return value means no errors.\n *\n * @name Mapper#validate\n * @method\n * @param {Object|Array} record The record or records to validate.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Schema#validate}.\n * @return {Array} Array of errors or undefined if no errors.\n */\n validate (record, opts) {\n const self = this\n const schema = self.getSchema()\n if (utils.isArray(record)) {\n const errors = record.map(function (_record) {\n return schema.validate(_record, opts)\n })\n let hasErrors = false\n errors.forEach(function (err) {\n if (err) {\n hasErrors = true\n }\n })\n if (hasErrors) {\n return errors\n }\n return undefined\n }\n return schema.validate(record, opts)\n },\n\n /**\n * Method used to wrap data returned by an adapter with this Mapper's Record\n * class.\n *\n * @name Mapper#wrap\n * @method\n * @param {Object|Array} data The data to be wrapped.\n * @param {Object} [opts] Configuration options. Passed to {@link Mapper#createRecord}.\n * @return {Object|Array}\n */\n wrap (data, opts) {\n return this.createRecord(data, opts)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Mapper from './Mapper'\n\nconst DOMAIN = 'Container'\n\nconst toProxy = [\n /**\n * Proxy for {@link Mapper#count}.\n *\n * @name Container#count\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.count}.\n * @param {Object} [opts] - Passed to {@link Model.count}.\n * @return {Promise}\n */\n 'count',\n\n /**\n * Proxy for {@link Mapper#create}.\n *\n * @name Container#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n 'create',\n\n /**\n * Proxy for {@link Mapper#createMany}.\n *\n * @name Container#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n 'createMany',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#createRecord\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} props Passed to {@link Mapper#createRecord}.\n * @param {Object} [opts] Passed to {@link Mapper#createRecord}. See\n * {@link Mapper#createRecord} for configuration options.\n * @return {Promise}\n */\n 'createRecord',\n\n /**\n * Proxy for {@link Mapper#dbg}.\n *\n * @name Container#dbg\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#dbg}.\n */\n 'dbg',\n\n /**\n * Proxy for {@link Mapper#destroy}.\n *\n * @name Container#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n 'destroy',\n\n /**\n * Proxy for {@link Mapper#destroyAll}.\n *\n * @name Container#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n 'destroyAll',\n\n /**\n * Proxy for {@link Mapper#find}.\n *\n * @name Container#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n 'find',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n 'findAll',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#getSchema\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n */\n 'getSchema',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#is\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#is}.\n */\n 'is',\n\n /**\n * Proxy for {@link Mapper#log}.\n *\n * @name Container#log\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#log}.\n */\n 'log',\n\n /**\n * Proxy for {@link Mapper#sum}.\n *\n * @name Container#sum\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {string} field - Passed to {@link Model.sum}.\n * @param {Object} [query] - Passed to {@link Model.sum}.\n * @param {Object} [opts] - Passed to {@link Model.sum}.\n * @return {Promise}\n */\n 'sum',\n\n /**\n * Proxy for {@link Mapper#toJSON}.\n *\n * @name Container#toJSON\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#toJSON}.\n */\n 'toJSON',\n\n /**\n * Proxy for {@link Mapper#update}.\n *\n * @name Container#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n 'update',\n\n /**\n * Proxy for {@link Mapper#updateAll}.\n *\n * @name Container#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object?} query - Passed to {@link Model.updateAll}.\n * @param {Object} props - Passed to {@link Model.updateAll}.\n * @param {Object} [opts] - Passed to {@link Model.updateAll}. See\n * {@link Model.updateAll} for more configuration options.\n * @return {Promise}\n */\n 'updateAll',\n\n /**\n * Proxy for {@link Mapper#updateMany}.\n *\n * @name Container#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n 'updateMany'\n]\n\nconst props = {\n constructor: function Container (opts) {\n const self = this\n utils.classCallCheck(self, Container)\n Container.__super__.call(self)\n opts || (opts = {})\n\n // Apply options provided by the user\n utils.fillIn(self, opts)\n /**\n * Defaults options to pass to {@link Container#mapperClass} when creating a\n * new mapper.\n *\n * @name Container#mapperDefaults\n * @type {Object}\n */\n self.mapperDefaults = self.mapperDefaults || {}\n /**\n * Constructor function to use in {@link Container#defineMapper} to create a\n * new mapper.\n *\n * @name Container#mapperClass\n * @type {Function}\n */\n self.mapperClass = self.mapperClass || Mapper\n\n // Initilize private data\n\n // Holds the adapters, shared by all mappers in this container\n self._adapters = {}\n // The the mappers in this container\n self._mappers = {}\n },\n\n /**\n * Register a new event listener on this Container.\n *\n * Proxy for {@link Component#on}. If an event was emitted by a Mapper in the\n * Container, then the name of the Mapper will be prepended to the arugments\n * passed to the listener.\n *\n * @name Container#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by mappers in this container.\n *\n * @name Container#_onMapperEvent\n * @method\n * @private\n * @param {string} name Name of the mapper that emitted the event.\n * @param {...*} [args] Args passed to {@link Mapper#emit}.\n */\n _onMapperEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * Create a new mapper and register it in this container.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container({\n * mapperDefaults: { foo: 'bar' }\n * })\n * const userMapper = container.defineMapper('user')\n * userMapper.foo // \"bar\"\n *\n * @name Container#defineMapper\n * @method\n * @param {string} name Name under which to register the new {@link Mapper}.\n * {@link Mapper#name} will be set to this value.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Container#mapperClass} when creating the new {@link Mapper}.\n * @return {Mapper}\n */\n defineMapper (name, opts) {\n const self = this\n\n // For backwards compatibility with defineResource\n if (utils.isObject(name)) {\n opts = name\n name = opts.name\n }\n if (!utils.isString(name)) {\n throw utils.err(`${DOMAIN}#defineMapper`, 'name')(400, 'string', name)\n }\n\n // Default values for arguments\n opts || (opts = {})\n // Set Mapper#name\n opts.name = name\n opts.relations || (opts.relations = {})\n\n // Check if the user is overriding the datastore's default mapperClass\n const mapperClass = opts.mapperClass || self.mapperClass\n delete opts.mapperClass\n\n // Apply the datastore's defaults to the options going into the mapper\n utils.fillIn(opts, self.mapperDefaults)\n\n // Instantiate a mapper\n const mapper = self._mappers[name] = new mapperClass(opts) // eslint-disable-line\n mapper.relations || (mapper.relations = {})\n // Make sure the mapper's name is set\n mapper.name = name\n // All mappers in this datastore will share adapters\n mapper._adapters = self.getAdapters()\n\n mapper.datastore = self\n\n mapper.on('all', function (...args) {\n self._onMapperEvent(name, ...args)\n })\n\n // Setup the mapper's relations, including generating Mapper#relationList\n // and Mapper#relationFields\n utils.forOwn(mapper.relations, function (group, type) {\n utils.forOwn(group, function (relations, _name) {\n if (utils.isObject(relations)) {\n relations = [relations]\n }\n relations.forEach(function (def) {\n def.getRelation = function () {\n return self.getMapper(_name)\n }\n const relatedMapper = self._mappers[_name] || _name\n if (type === belongsToType) {\n mapper.belongsTo(relatedMapper, def)\n } else if (type === hasOneType) {\n mapper.hasOne(relatedMapper, def)\n } else if (type === hasManyType) {\n mapper.hasMany(relatedMapper, def)\n }\n })\n })\n })\n\n return mapper\n },\n\n defineResource (name, opts) {\n return this.defineMapper(name, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Container#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw utils.err(`${DOMAIN}#getAdapter`, 'name')(400, 'string', name)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Container#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || this.mapperDefaults.defaultAdapter\n },\n\n /**\n * Return the registered adapters of this container.\n *\n * @name Container#getAdapters\n * @method\n * @return {Adapter}\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Return the mapper registered under the specified name.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container()\n * const userMapper = container.defineMapper('user')\n * userMapper === container.getMapper('user') // true\n *\n * @name Container#getMapper\n * @method\n * @param {string} name {@link Mapper#name}.\n * @return {Mapper}\n */\n getMapper (name) {\n const mapper = this._mappers[name]\n if (!mapper) {\n throw utils.err(`${DOMAIN}#getMapper`, name)(404, 'mapper')\n }\n return mapper\n },\n\n /**\n * Register an adapter on this container under the given name. Adapters\n * registered on a container are shared by all mappers in the container.\n *\n * @example\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * container.registerAdapter('http', new HttpAdapter, { default: true })\n *\n * @name Container#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for all Mappers in this container.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.mapperDefaults.defaultAdapter = name\n utils.forOwn(self._mappers, function (mapper) {\n mapper.defaultAdapter = name\n })\n }\n }\n}\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getMapper(name)[method](...args)\n }\n})\n\n/**\n * ```javascript\n * import {Container} from 'js-data'\n * ```\n *\n * The `Container` class is a place to store {@link Mapper} instances.\n *\n * Without a container, you need to manage mappers yourself, including resolving\n * circular dependencies among relations. All mappers in a container share the\n * same adapters, so you don't have to add each adapter to all of your mappers.\n *\n * @example Without Container\n * import {Mapper} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const adapter = new HttpAdapter()\n * const userMapper = new Mapper({ name: 'user' })\n * userMapper.registerAdapter('http', adapter, { default: true })\n * const commentMapper = new Mapper({ name: 'comment' })\n * commentMapper.registerAdapter('http', adapter, { default: true })\n *\n * // This might be more difficult if the mappers were defined in different\n * // modules.\n * userMapper.hasMany(commentMapper, {\n * localField: 'comments',\n * foreignKey: 'userId'\n * })\n * commentMapper.belongsTo(userMapper, {\n * localField: 'user',\n * foreignKey: 'userId'\n * })\n *\n * @example With Container\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * // All mappers in container share adapters\n * container.registerAdapter('http', new HttpAdapter(), { default: true })\n *\n * // These could be defined in separate modules without a problem.\n * container.defineMapper('user', {\n * relations: {\n * hasMany: {\n * comment: {\n * localField: 'comments',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n * container.defineMapper('comment', {\n * relations: {\n * belongsTo: {\n * user: {\n * localField: 'user',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n *\n * @class Container\n * @extends Component\n * @param {Object} [opts] Configuration options.\n * @param {Function} [opts.mapperClass] Constructor function to use in\n * {@link Container#defineMapper} to create a new mapper.\n * @param {Object} [opts.mapperDefaults] Defaults options to pass to\n * {@link Container#mapperClass} when creating a new mapper.\n * @return {Container}\n */\nexport default Component.extend(props)\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Collection from './Collection'\n\nconst DOMAIN = 'LinkedCollection'\n\n/**\n * TODO\n *\n * ```javascript\n * import {LinkedCollection} from 'js-data'\n * ```\n *\n * @class LinkedCollection\n * @extends Collection\n * @param {Array} [records] Initial set of records to insert into the\n * collection. See {@link Collection}.\n * @param {Object} [opts] Configuration options. See {@link Collection}.\n * @return {Mapper}\n */\nexport default Collection.extend({\n constructor: function LinkedCollection (records, opts) {\n const self = this\n utils.classCallCheck(self, LinkedCollection)\n LinkedCollection.__super__.call(self, records, opts)\n\n // Make sure this collection has somewhere to store \"added\" timestamps\n Object.defineProperty(self, '_added', {\n value: {}\n })\n\n // Make sure this collection has a reference to a datastore\n if (!self.datastore) {\n throw utils.err(`new ${DOMAIN}`, 'opts.datastore')(400, 'DataStore', self.datastore)\n }\n return self\n },\n\n _onRecordEvent (...args) {\n const self = this\n utils.getSuper(self).prototype._onRecordEvent.apply(self, args)\n const event = args[0]\n // This is a very brute force method\n // Lots of room for optimization\n if (utils.isString(event) && event.indexOf('change') === 0) {\n self.updateIndexes(args[1])\n }\n },\n\n add (records, opts) {\n const self = this\n const datastore = self.datastore\n const mapper = self.mapper\n const relationList = mapper.relationList\n const timestamp = new Date().getTime()\n const usesRecordClass = !!mapper.recordClass\n const idAttribute = mapper.idAttribute\n let singular\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n\n records = utils.getSuper(self).prototype.add.call(self, records, opts)\n\n if (relationList.length && records.length) {\n // Check the currently visited record for relations that need to be\n // inserted into their respective collections.\n mapper.relationList.forEach(function (def) {\n const relationName = def.relation\n // A reference to the Mapper that this Mapper is related to\n const relatedMapper = datastore.getMapper(relationName)\n // The field used by the related Mapper as the primary key\n const relationIdAttribute = relatedMapper.idAttribute\n // Grab the foreign key in this relationship, if there is one\n const foreignKey = def.foreignKey\n // A lot of this is an optimization for being able to insert a lot of\n // data as quickly as possible\n const relatedCollection = datastore.getCollection(relationName)\n const type = def.type\n const isHasMany = type === hasManyType\n const shouldAdd = utils.isUndefined(def.add) ? true : !!def.add\n let relatedData\n\n records.forEach(function (record) {\n // Grab a reference to the related data attached or linked to the\n // currently visited record\n relatedData = def.getLocalField(record)\n const id = utils.get(record, idAttribute)\n\n if (utils.isFunction(def.add)) {\n relatedData = def.add(datastore, def, record)\n } else if (relatedData) {\n // Otherwise, if there is something to be added, add it\n if (isHasMany) {\n // Handle inserting hasMany relations\n relatedData = relatedData.map(function (toInsertItem) {\n // Check that this item isn't the same item that is already in the\n // store\n if (toInsertItem !== relatedCollection.get(relatedCollection.recordId(toInsertItem))) {\n // Make sure this item has its foreignKey\n if (foreignKey) {\n // TODO: slow, could be optimized? But user loses hook\n def.setForeignKey(record, toInsertItem)\n }\n // Finally add this related item\n if (shouldAdd) {\n toInsertItem = relatedCollection.add(toInsertItem)\n }\n }\n return toInsertItem\n })\n } else {\n const relatedDataId = utils.get(relatedData, relationIdAttribute)\n // Handle inserting belongsTo and hasOne relations\n if (relatedData !== relatedCollection.get(relatedDataId)) {\n // Make sure foreignKey field is set\n def.setForeignKey(record, relatedData)\n // Finally insert this related item\n if (shouldAdd) {\n relatedData = relatedCollection.add(relatedData)\n }\n }\n }\n }\n\n if (!relatedData || (utils.isArray(relatedData) && !relatedData.length)) {\n if (type === belongsToType) {\n const relatedId = utils.get(record, foreignKey)\n if (!utils.isUndefined(relatedId)) {\n relatedData = relatedCollection.get(relatedId)\n }\n } else if (type === hasOneType) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records[0] : undefined\n } else if (type === hasManyType) {\n if (foreignKey) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.localKeys && utils.get(record, def.localKeys)) {\n const _records = relatedCollection.filter({\n where: {\n [relationIdAttribute]: {\n 'in': utils.get(record, def.localKeys)\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.foreignKeys) {\n const _records = relatedCollection.filter({\n where: {\n [def.foreignKeys]: {\n 'contains': id\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n }\n }\n }\n if (relatedData) {\n def.setLocalField(record, relatedData)\n } else {\n }\n })\n })\n }\n\n records.forEach(function (record) {\n // Track when this record was added\n self._added[self.recordId(record)] = timestamp\n\n if (usesRecordClass) {\n record._set('$', timestamp)\n }\n })\n\n return singular ? records[0] : records\n },\n\n remove (id, opts) {\n const self = this\n const mapper = self.mapper\n const record = utils.getSuper(self).prototype.remove.call(self, id, opts)\n if (record) {\n delete self._added[id]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n }\n return record\n },\n\n removeAll (query, opts) {\n const self = this\n const mapper = self.mapper\n const records = utils.getSuper(self).prototype.removeAll.call(self, query, opts)\n records.forEach(function (record) {\n delete self._added[self.recordId(record)]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n })\n return records\n }\n})\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Container from './Container'\nimport LinkedCollection from './LinkedCollection'\n\nconst DOMAIN = 'DataStore'\nconst DATASTORE_DEFAULTS = {}\n\nconst safeSet = function (record, field, value) {\n if (record && record._set) {\n record._set(field, value)\n } else {\n utils.set(record, field, value)\n }\n}\n\nconst cachedFn = function (name, hashOrId, opts) {\n const self = this\n const cached = self._completedQueries[name][hashOrId]\n if (utils.isFunction(cached)) {\n return cached(name, hashOrId, opts)\n }\n return cached\n}\n\nconst props = {\n constructor: function DataStore (opts) {\n const self = this\n utils.classCallCheck(self, DataStore)\n DataStore.__super__.call(self, opts)\n\n self.collectionClass = self.collectionClass || LinkedCollection\n self._collections = {}\n utils.fillIn(self, DATASTORE_DEFAULTS)\n self._pendingQueries = {}\n self._completedQueries = {}\n return self\n },\n\n _callSuper (method, ...args) {\n return this.constructor.__super__.prototype[method].apply(this, args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#_end\n * @method\n * @private\n * @param {string} name Name of the {@link LinkedCollection} to which to\n * add the data.\n * @param {Object} data TODO.\n * @param {Object} [opts] Configuration options.\n * @return {(Object|Array)} Result.\n */\n _end (name, result, opts) {\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(this.addToCache)) {\n _data = this.addToCache(name, _data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Register a new event listener on this DataStore.\n *\n * Proxy for {@link Container#on}. If an event was emitted by a Mapper or\n * Collection in the DataStore, then the name of the Mapper or Collection will\n * be prepended to the arugments passed to the provided event handler.\n *\n * @name DataStore#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by collections in this store.\n *\n * @name DataStore#_onCollectionEvent\n * @method\n * @private\n * @param {string} name Name of the collection that emitted the event.\n * @param {...*} [args] Args passed to {@link Collection#emit}.\n */\n _onCollectionEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#addToCache\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {*} data - Data from which data should be selected for add.\n * @param {Object} [opts] - Configuration options.\n */\n addToCache (name, data, opts) {\n return this.getCollection(name).add(data, opts)\n },\n\n /**\n * Retrieve a cached `find` result, if any.\n *\n * @name DataStore#cachedFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cachedFind: cachedFn,\n\n /**\n * Retrieve a cached `findAll` result, if any.\n *\n * @name DataStore#cachedFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cachedFindAll: cachedFn,\n\n /**\n * Cache a `find` result. The default implementation does the following:\n *\n * ```\n * // Find and return the record from the data store\n * return this.get(name, id)\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {*} data The result to cache.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cacheFind (name, data, id, opts) {\n const self = this\n self._completedQueries[name][id] = function (name, id, opts) {\n return self.get(name, id)\n }\n },\n\n /**\n * Cache a `findAll` result. The default implementation does the following:\n *\n * ```\n * // Find and return the records from the data store\n * return this.filter(name, utils.fromJson(hash))\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {*} data The result to cache.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cacheFindAll (name, data, hash, opts) {\n const self = this\n self._completedQueries[name][hash] = function (name, hash, opts) {\n return self.filter(name, utils.fromJson(hash))\n }\n },\n\n /**\n * TODO\n *\n * @name DataStore#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n create (name, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('create', name, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n createMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('createMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n defineMapper (name, opts) {\n const self = this\n const mapper = utils.getSuper(self).prototype.defineMapper.call(self, name, opts)\n self._pendingQueries[name] = {}\n self._completedQueries[name] = {}\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n\n // The datastore uses a subclass of Collection that is \"datastore-aware\"\n const collection = self._collections[name] = new self.collectionClass(null, { // eslint-disable-line\n // Make sure the collection has somewhere to store \"added\" timestamps\n _added: {},\n // Give the collection a reference to this datastore\n datastore: self,\n // The mapper tied to the collection\n mapper\n })\n\n const schema = mapper.schema || {}\n const properties = schema.properties || {}\n // TODO: Make it possible index nested properties?\n utils.forOwn(properties, function (opts, prop) {\n if (opts.indexed) {\n collection.createIndex(prop)\n }\n })\n\n // Create a secondary index on the \"added\" timestamps of records in the\n // collection\n collection.createIndex('addedTimestamps', ['$'], {\n fieldGetter (obj) {\n return collection._added[collection.recordId(obj)]\n }\n })\n\n collection.on('all', function (...args) {\n self._onCollectionEvent(name, ...args)\n })\n\n const idAttribute = mapper.idAttribute\n\n mapper.relationList.forEach(function (def) {\n const relation = def.relation\n const localField = def.localField\n const path = `links.${localField}`\n const foreignKey = def.foreignKey\n const type = def.type\n const updateOpts = { index: foreignKey }\n let descriptor\n\n const getter = function () { return this._get(path) }\n\n if (type === belongsToType) {\n if (!collection.indexes[foreignKey]) {\n collection.createIndex(foreignKey)\n }\n\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const id = utils.get(_self, idAttribute)\n const inverseDef = def.getInverse(mapper)\n\n if (record) {\n const relatedIdAttribute = def.getRelation().idAttribute\n const relatedId = utils.get(record, relatedIdAttribute)\n\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n safeSet(_self, foreignKey, relatedId)\n collection.updateIndex(_self, updateOpts)\n\n // Update (set) inverse relation\n if (inverseDef.type === hasOneType) {\n utils.set(record, inverseDef.localField, _self)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(record, inverseDef.localField)\n utils.noDupeAdd(children, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n } else {\n // Unset locals\n _self._set(path, undefined)\n safeSet(_self, foreignKey, undefined)\n collection.updateIndex(_self, updateOpts)\n }\n if (current) {\n if (inverseDef.type === hasOneType) {\n utils.set(current, inverseDef.localField, undefined)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(current, inverseDef.localField)\n utils.remove(children, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n }\n return record\n }\n }\n\n if (mapper.recordClass.prototype.hasOwnProperty(foreignKey)) {\n const superClass = mapper.recordClass\n mapper.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n Object.defineProperty(mapper.recordClass.prototype, foreignKey, {\n enumerable: true,\n get () { return this._get(foreignKey) },\n set (value) {\n const _self = this\n if (utils.isUndefined(value)) {\n // Unset locals\n utils.set(_self, localField, undefined)\n } else {\n safeSet(_self, foreignKey, value)\n let storeRecord = self.get(relation, value)\n if (storeRecord) {\n utils.set(_self, localField, storeRecord)\n }\n }\n }\n })\n } else if (type === hasManyType) {\n const localKeys = def.localKeys\n const foreignKeys = def.foreignKeys\n\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n\n descriptor = {\n get () {\n const _self = this\n let current = getter.call(_self)\n if (!current) {\n _self._set(path, [])\n }\n return getter.call(_self)\n },\n set (records) {\n const _self = this\n records || (records = [])\n if (records && !utils.isArray(records)) {\n records = [records]\n }\n const id = utils.get(_self, idAttribute)\n const relatedIdAttribute = def.getRelation().idAttribute\n const inverseDef = def.getInverse(mapper)\n const inverseLocalField = inverseDef.localField\n let linked = _self._get(path)\n if (!linked) {\n linked = []\n }\n\n const current = linked\n linked = []\n const toLink = {}\n records.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId)) {\n // Prefer store record\n record = self.get(relation, relatedId) || record\n toLink[relatedId] = record\n }\n linked.push(record)\n })\n if (foreignKey) {\n records.forEach(function (record) {\n // Update (set) inverse relation\n safeSet(record, foreignKey, id)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n })\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update (unset) inverse relation\n safeSet(record, foreignKey, undefined)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (localKeys) {\n const _localKeys = []\n records.forEach(function (record) {\n // Update (set) inverse relation\n utils.set(record, inverseLocalField, _self)\n _localKeys.push(utils.get(record, relatedIdAttribute))\n })\n // Update locals\n utils.set(_self, localKeys, _localKeys)\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update inverse relation\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (foreignKeys) {\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.remove(_localKeys, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.remove(_localField, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n // Update (set) inverse relation\n records.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.noDupeAdd(_localKeys, id, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.noDupeAdd(_localField, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n }\n\n _self._set(path, linked)\n return linked\n }\n }\n } else if (type === hasOneType) {\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const relatedId = utils.get(record, def.getRelation().idAttribute)\n const inverseLocalField = def.getInverse(mapper).localField\n // Update (unset) inverse relation\n if (current) {\n safeSet(current, foreignKey, undefined)\n self.getCollection(relation).updateIndex(current, updateOpts)\n utils.set(current, inverseLocalField, undefined)\n }\n if (record) {\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n\n // Update (set) inverse relation\n safeSet(record, foreignKey, utils.get(_self, idAttribute))\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n } else {\n // Set locals\n _self._set(path, undefined)\n }\n return record\n }\n }\n }\n\n if (descriptor) {\n descriptor.enumerable = utils.isUndefined(def.enumerable) ? true : def.enumerable\n if (def.get) {\n let origGet = descriptor.get\n descriptor.get = function () {\n return def.get(def, this, (...args) => origGet.apply(this, args))\n }\n }\n if (def.set) {\n let origSet = descriptor.set\n descriptor.set = function (related) {\n return def.set(def, this, related, (value) => origSet.call(this, value === undefined ? related : value))\n }\n }\n Object.defineProperty(mapper.recordClass.prototype, localField, descriptor)\n }\n })\n\n return mapper\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n destroy (name, id, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroy', name, id, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).remove(id, opts)\n } else {\n data = self.getCollection(name).remove(id, opts)\n }\n delete self._pendingQueries[name][id]\n delete self._completedQueries[name][id]\n return data\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n destroyAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroyAll', name, query, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).removeAll(query, opts)\n } else {\n data = self.getCollection(name).removeAll(query, opts)\n }\n const hash = self.hashQuery(name, query, opts)\n delete self._pendingQueries[name][hash]\n delete self._completedQueries[name][hash]\n return data\n })\n },\n\n eject (id, opts) {\n return this.remove(id, opts)\n },\n\n ejectAll (query, opts) {\n return this.removeAll(query, opts)\n },\n\n /**\n * TODO\n *\n * @name DataStore#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n find (name, id, opts) {\n const self = this\n opts || (opts = {})\n const pendingQuery = self._pendingQueries[name][id]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n const item = self.cachedFind(name, id, opts)\n let promise\n\n if (opts.force || !item) {\n promise = self._pendingQueries[name][id] = self._callSuper('find', name, id, opts).then(function (data) {\n delete self._pendingQueries[name][id]\n const result = self._end(name, data, opts)\n self.cacheFind(name, result, id, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][id]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(item)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n findAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n const hash = self.hashQuery(name, query, opts)\n const pendingQuery = self._pendingQueries[name][hash]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n\n const items = self.cachedFindAll(name, hash, opts)\n let promise\n\n if (opts.force || !items) {\n promise = self._pendingQueries[name][hash] = self._callSuper('findAll', name, query, opts).then(function (data) {\n delete self._pendingQueries[name][hash]\n const result = self._end(name, data, opts)\n self.cacheFindAll(name, result, hash, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][hash]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(items)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#getCollection\n * @method\n * @param {string} name Name of the {@link LinkedCollection} to retrieve.\n * @return {LinkedCollection}\n */\n getCollection (name) {\n const collection = this._collections[name]\n if (!collection) {\n throw utils.err(`${DOMAIN}#getCollection`, name)(404, 'collection')\n }\n return collection\n },\n\n hashQuery (name, query, opts) {\n return utils.toJson(query)\n },\n\n inject (records, opts) {\n return this.add(records, opts)\n },\n\n remove (name, id, opts) {\n const self = this\n const record = self.getCollection(name).remove(id, opts)\n if (record) {\n self.removeRelated(name, [record], opts)\n }\n return record\n },\n\n removeAll (name, query, opts) {\n const self = this\n const records = self.getCollection(name).removeAll(query, opts)\n if (records.length) {\n self.removeRelated(name, records, opts)\n }\n return records\n },\n\n removeRelated (name, records, opts) {\n const self = this\n utils.forEachRelation(self.getMapper(name), opts, function (def, optsCopy) {\n records.forEach(function (record) {\n let relatedData\n let query\n if (def.foreignKey && (def.type === hasOneType || def.type === hasManyType)) {\n query = { [def.foreignKey]: def.getForeignKey(record) }\n } else if (def.type === hasManyType && def.localKeys) {\n query = {\n where: {\n [def.getRelation().idAttribute]: {\n 'in': utils.get(record, def.localKeys)\n }\n }\n }\n } else if (def.type === hasManyType && def.foreignKeys) {\n query = {\n where: {\n [def.foreignKeys]: {\n 'contains': def.getForeignKey(record)\n }\n }\n }\n } else if (def.type === belongsToType) {\n relatedData = self.remove(def.relation, def.getForeignKey(record), optsCopy)\n }\n if (query) {\n relatedData = self.removeAll(def.relation, query, optsCopy)\n }\n if (relatedData) {\n if (utils.isArray(relatedData) && !relatedData.length) {\n return\n }\n if (def.type === hasOneType) {\n relatedData = relatedData[0]\n }\n def.setLocalField(record, relatedData)\n }\n })\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n update (name, id, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('update', name, id, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} props - Passed to {@link Mapper#updateAll}.\n * @param {Object} [query] - Passed to {@link Mapper#updateAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#updateAll}. See\n * {@link Mapper#updateAll} for more configuration options.\n * @return {Promise}\n */\n updateAll (name, props, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateAll', name, query, props, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n updateMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n }\n}\n\nconst toProxy = [\n 'add',\n 'between',\n 'createIndex',\n 'filter',\n 'get',\n 'getAll',\n 'query',\n 'toJson'\n]\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getCollection(name)[method](...args)\n }\n})\n\n/**\n * The `DataStore` class is an extension of {@link Container}. Not only does\n * `DataStore` manage mappers, but also collections. `DataStore` implements the\n * asynchronous {@link Mapper} methods, such as {@link Mapper#find} and\n * {@link Mapper#create}. If you use the asynchronous `DataStore` methods\n * instead of calling them directly on the mappers, then the results of the\n * method calls will be inserted into the store's collections. You can think of\n * a `DataStore` as an [Identity Map](https://en.wikipedia.org/wiki/Identity_map_pattern)\n * for the [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)\n * (the Mappers).\n *\n * ```javascript\n * import {DataStore} from 'js-data'\n * ```\n *\n * @example\n * import {DataStore} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const store = new DataStore()\n * const UserMapper = store.defineMapper('user')\n *\n * // Call \"find\" on \"UserMapper\" (Stateless ORM)\n * UserMapper.find(1).then(function (user) {\n * // retrieved a \"user\" record via the http adapter, but that's it\n *\n * // Call \"find\" on \"store\" for the \"user\" mapper (Stateful DataStore)\n * return store.find('user', 1)\n * }).then(function (user) {\n * // not only was a \"user\" record retrieved, but it was added to the\n * // store's \"user\" collection\n * const cachedUser = store.getCollection('user').get(1)\n * user === cachedUser // true\n * })\n *\n * @class DataStore\n * @extends Container\n * @param {Object} [opts] Configuration options. See {@link Container}.\n * @return {DataStore}\n */\nexport default Container.extend(props)\n","/**\n * Registered as `js-data` in NPM and Bower.\n * #### Script tag\n * ```js\n * window.JSData\n * ```\n * #### CommonJS\n * ```js\n * var JSData = require('js-data')\n * ```\n * #### ES6 Modules\n * ```js\n * import JSData from 'js-data'\n * ```\n * #### AMD\n * ```js\n * define('myApp', ['js-data'], function (JSData) { ... })\n * ```\n *\n * @module js-data\n */\n\n/**\n * Details of the current version of the `js-data` module.\n *\n * @name version\n * @memberof module:js-data\n * @type {Object}\n * @property {string} full The full semver value.\n * @property {number} major The major version number.\n * @property {number} minor The minor version number.\n * @property {number} patch The patch version number.\n * @property {(string|boolean)} alpha The alpha version value, otherwise `false`\n * if the current version is not alpha.\n * @property {(string|boolean)} beta The beta version value, otherwise `false`\n * if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\nimport utils from './utils'\n\n/**\n * {@link Collection} class.\n * @name module:js-data.Collection\n */\nimport Collection from './Collection'\n\n/**\n * {@link Component} class.\n * @name module:js-data.Component\n */\nimport Component from './Component'\n\n/**\n * {@link Container} class.\n * @name module:js-data.Container\n */\nimport Container from './Container'\n\n/**\n * {@link DataStore} class.\n * @name module:js-data.DataStore\n */\nimport DataStore from './DataStore'\n\n/**\n * {@link Index} class.\n * @name module:js-data.Index\n */\nimport Index from '../lib/mindex/index'\n\n/**\n * {@link LinkedCollection} class.\n * @name module:js-data.LinkedCollection\n */\nimport LinkedCollection from './LinkedCollection'\n\n/**\n * {@link Mapper} class.\n * @name module:js-data.Mapper\n */\nimport Mapper from './Mapper'\n\n/**\n * {@link Query} class.\n * @name module:js-data.Query\n */\nimport Query from './Query'\n\n/**\n * {@link Record} class.\n * @name module:js-data.Record\n */\nimport Record from './Record'\n\n/**\n * {@link Schema} class.\n * @name module:js-data.Schema\n */\nimport Schema from './Schema'\n\nexport * from './decorators'\n\nexport {\n Collection,\n Component,\n Container,\n DataStore,\n Index,\n LinkedCollection,\n Mapper,\n Query,\n Record,\n Schema,\n utils\n}\n"],"names":["utils","DOMAIN","belongsTo","hasMany","hasOne","props","toProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAM,SAAS,OAAT;;AAEN,IAAM,WAAW,IAAI,CAAJ;AACjB,IAAM,cAAc,uBAAd;AACN,IAAM,WAAW,kBAAX;AACN,IAAM,WAAW,eAAX;AACN,IAAM,WAAW,mBAAX;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,aAAa,iBAAb;AACN,IAAM,cAAc,OAAO,SAAP,CAAiB,QAAjB;AACpB,IAAM,OAAO,cAAP;;AAEN,IAAM,SAAS;sBACJ;0BAAsB,UAAU,CAAV,mBAAwB,UAAU,CAAV,IAAe,UAAU,CAAV,CAAf,uBAAqC,UAAU,CAAV,EAArC,CAA5C,CAAF;GADI;sBAEJ;WAAY,UAAU,CAAV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AAoC,OAApC,EAA6C,IAA7C,EAAmD,IAAnD,CAAwD,UAAU,IAAV,EAAgB;aACtE,KAAK,IAAL,CAAU,IAAV,EAAgB,IAAhB,EAAsB,IAAtB,CAAP,CAD6E;KAAhB,CAA/D,CAH+B;GA7wBrB;CAAR;;AAsxBN,IAAMM,YAAU,CACd,KADc,EAEd,SAFc,EAGd,aAHc,EAId,QAJc,EAKd,KALc,EAMd,QANc,EAOd,OAPc,EAQd,QARc,CAAV;;AAWNA,UAAQ,OAAR,CAAgB,UAAU,MAAV,EAAkB;UAC1B,MAAN,IAAgB,UAAU,IAAV,EAAyB;;;uCAAN;;KAAM;;WAChC,uBAAK,aAAL,CAAmB,IAAnB,GAAyB,OAAzB,uBAAoC,IAApC,CAAP,CADuC;GAAzB,CADgB;CAAlB,CAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,gBAAe,UAAU,MAAV,CAAiBD,OAAjB,CAAf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACt0BA,AAAO,IAAM,UAAU,gBAAV,CAAb;;"} \ No newline at end of file diff --git a/dist/js-data.js b/dist/js-data.js index 652c50de..d1a359b2 100644 --- a/dist/js-data.js +++ b/dist/js-data.js @@ -1,6 +1,6 @@ /*! * js-data -* @version 3.0.0-alpha.29 - Homepage +* @version 3.0.0-beta.1 - Homepage * @author js-data project authors * @copyright (c) 2014-2016 js-data project authors * @license MIT @@ -75,13 +75,14 @@ * @property {Function} isSorN TODO * @property {Function} isString TODO * @property {Function} isUndefined TODO - * @property {Function} possibleConstructorReturn TODO * @property {Function} reject TODO * @property {Function} resolve TODO * @property {Function} set TODO * @property {Function} toJson TODO */ + var DOMAIN = 'utils'; + var INFINITY = 1 / 0; var MAX_INTEGER = 1.7976931348623157e+308; var BOOL_TAG = '[object Boolean]'; @@ -94,6 +95,15 @@ var objToString = Object.prototype.toString; var PATH = /^(.+)\.(.+)$/; + var ERRORS = { + '400': function _() { + return 'expected: ' + arguments[0] + ', found: ' + (arguments[2] ? arguments[1] : babelHelpers.typeof(arguments[1])); + }, + '404': function _() { + return arguments[0] + ' not found'; + } + }; + var toInteger = function toInteger(value) { if (!value) { return 0; @@ -256,7 +266,7 @@ */ classCallCheck: function classCallCheck(instance, ctor) { if (!(instance instanceof ctor)) { - throw new TypeError('Cannot call a class as a function'); + throw utils.err('' + ctor.name)(500, 'Cannot call a class as a function'); } }, @@ -289,7 +299,7 @@ } } else { if (from === to) { - throw new Error('Cannot copy! Source and destination are identical.'); + throw utils.err(DOMAIN + '.copy')(500, 'Cannot copy! Source and destination are identical.'); } stackFrom = stackFrom || []; @@ -433,14 +443,25 @@ /** * TODO - * - * @ignore */ equal: function equal(a, b) { return a == b; // eslint-disable-line }, + /** + * TODO + */ + err: function err(domain, target) { + return function (code) { + var prefix = '[' + domain + ':' + target + '] '; + var message = ERRORS[code].apply(null, Array.prototype.slice.call(arguments, 1)); + message = '' + prefix + message + '\nhttp://www.js-data.io/v3.0/docs/errors#' + code; + return new Error(message); + }; + }, + + /** * Add eventing capabilities into the target object. * @@ -451,7 +472,7 @@ * @param {Function} [setter] Custom setter for setting the object's event * listeners. */ - eventify: function eventify(target, getter, setter, enumerable) { + eventify: function eventify(target, getter, setter) { target = target || this; var _events = {}; if (!getter && !setter) { @@ -464,7 +485,6 @@ } Object.defineProperties(target, { emit: { - enumerable: !!enumerable, value: function value() { var events = getter.call(this) || {}; @@ -486,7 +506,6 @@ } }, off: { - enumerable: !!enumerable, value: function value(type, func) { var events = getter.call(this); var listeners = events[type]; @@ -505,7 +524,6 @@ } }, on: { - enumerable: !!enumerable, value: function value(type, func, ctx) { if (!getter.call(this)) { setter.call(this, {}); @@ -545,11 +563,11 @@ args[_key2] = arguments[_key2]; } - var _this = utils.possibleConstructorReturn(this, (_subClass.__super__ || Object.getPrototypeOf(_subClass)).apply(this, args)); - return _this; + superClass.apply(this, args); }; } + // Setup inheritance of instance members _subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { configurable: true, @@ -560,6 +578,7 @@ }); var obj = Object; + // Setup inheritance of static members if (obj.setPrototypeOf) { obj.setPrototypeOf(_subClass, superClass); } else if (classProps.strictEs6Class) { @@ -609,6 +628,9 @@ */ findIndex: function findIndex(array, fn) { var index = -1; + if (!array) { + return index; + } array.forEach(function (record, i) { if (fn(record)) { index = i; @@ -924,6 +946,9 @@ * @ignore */ noDupeAdd: function noDupeAdd(array, record, fn) { + if (!array) { + return; + } var index = this.findIndex(array, fn); if (index < 0) { array.push(record); @@ -958,20 +983,6 @@ }, - /** - * TODO - * - * @ignore - */ - possibleConstructorReturn: function possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called'); - } - - return call && ((typeof call === 'undefined' ? 'undefined' : babelHelpers.typeof(call)) === 'object' || typeof call === 'function') ? call : self; - }, - - /** * Proxy for `Promise.reject`. * @@ -990,6 +1001,9 @@ * @ignore */ remove: function remove(array, fn) { + if (!array || !array.length) { + return; + } var index = this.findIndex(array, fn); if (index >= 0) { array.splice(index, 1); @@ -1172,6 +1186,9 @@ this._listeners = value; }); + var DOMAIN$2 = 'Query'; + var INDEX_ERR = 'Index inaccessible after first operation'; + // Reserved words used by JSData's Query Syntax var reserved = { limit: '', @@ -1256,7 +1273,7 @@ var self = this; opts || (opts = {}); if (self.data) { - throw new Error('Cannot access index after first operation!'); + throw utils$1.err(DOMAIN$2 + '#between')(500, 'Cannot access index'); } self.data = self.collection.getIndex(opts.index).between(leftKeys, rightKeys, opts); return self; @@ -1523,7 +1540,7 @@ keyList || (keyList = []); opts || (opts = {}); if (self.data) { - throw new Error('Cannot access index after first operation!'); + throw utils$1.err(DOMAIN$2 + '#get')(500, INDEX_ERR); } if (keyList && !utils$1.isArray(keyList)) { keyList = [keyList]; @@ -1565,7 +1582,7 @@ var self = this; var opts = {}; if (self.data) { - throw new Error('Cannot access index after first operation!'); + throw utils$1.err(DOMAIN$2 + '#getAll')(500, INDEX_ERR); } for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { @@ -1624,7 +1641,7 @@ */ limit: function limit(num) { if (!utils$1.isNumber(num)) { - throw new TypeError('limit: Expected number but found ' + (typeof num === 'undefined' ? 'undefined' : babelHelpers.typeof(num)) + '!'); + throw utils$1.err(DOMAIN$2 + '#limit', 'num')(400, 'number', num); } var data = this.getData(); this.data = data.slice(0, Math.min(data.length, num)); @@ -1699,7 +1716,7 @@ */ skip: function skip(num) { if (!utils$1.isNumber(num)) { - throw new TypeError('skip: Expected number but found ' + (typeof num === 'undefined' ? 'undefined' : babelHelpers.typeof(num)) + '!'); + throw utils$1.err(DOMAIN$2 + '#skip', 'num')(400, 'number', num); } var data = this.getData(); if (num < data.length) { @@ -2092,6 +2109,8 @@ } }); + var DOMAIN$1 = 'Collection'; + var COLLECTION_DEFAULTS = { /** * Field to be used as the unique identifier for records in this collection. @@ -2159,7 +2178,7 @@ utils$1.classCallCheck(self, Collection); Collection.__super__.call(self); - if (utils$1.isObject(records) && !utils$1.isArray(records)) { + if (records && !utils$1.isArray(records)) { opts = records; records = []; } @@ -2225,16 +2244,10 @@ } }); - var mapper = self.mapper; - // Insert initial data into the collection - records.forEach(function (record) { - record = mapper ? mapper.createRecord(record, opts) : record; - self.index.insertRecord(record); - if (record && utils$1.isFunction(record.on)) { - record.on('all', self._onRecordEvent, self); - } - }); + if (records) { + self.add(records); + } }, /** @@ -2281,9 +2294,13 @@ // Track whether just one record or an array of records is being inserted var singular = false; var idAttribute = self.recordId(); - if (utils$1.isObject(records) && !utils$1.isArray(records)) { - records = [records]; - singular = true; + if (!utils$1.isArray(records)) { + if (utils$1.isObject(records)) { + records = [records]; + singular = true; + } else { + throw utils$1.err(DOMAIN$1 + '#add', 'records')(400, 'object or array', records); + } } // Map the provided records to existing records. @@ -2293,7 +2310,7 @@ records = records.map(function (record) { var id = self.recordId(record); if (!utils$1.isSorN(id)) { - throw new TypeError('Collection#add: Expected string or number for ' + idAttribute + ', found ' + (typeof id === 'undefined' ? 'undefined' : babelHelpers.typeof(id)) + '!'); + throw utils$1.err(DOMAIN$1 + '#add', 'record.' + idAttribute)(400, 'string or number', id); } // Grab existing record if there is one var existing = self.get(id); @@ -2316,6 +2333,8 @@ } }); existing.set(record); + } else { + throw utils$1.err(DOMAIN$1 + '#add', 'opts.onConflict')(400, 'one of (merge, replace)', onConflict, true); } record = existing; // Update all indexes in the collection @@ -2336,7 +2355,7 @@ return record; }); // Finally, return the inserted data - var result = singular ? records.length ? records[0] : undefined : records; + var result = singular ? records[0] : records; // TODO: Make this more performant (batch events?) self.emit('add', result); return self.afterAdd(records, opts, result) || result; @@ -2589,7 +2608,7 @@ getIndex: function getIndex(name) { var index = name ? this.indexes[name] : this.index; if (!index) { - throw new Error('Index ' + name + ' does not exist!'); + throw utils$1.err(DOMAIN$1 + '#getIndex', name)(404, 'index'); } return index; }, @@ -2675,7 +2694,7 @@ if (record) { return utils$1.get(record, self.recordId()); } - return self.mapper ? self.mapper.idAttribute : self.idAttribute || 'id'; + return self.mapper ? self.mapper.idAttribute : self.idAttribute; }, @@ -2853,30 +2872,33 @@ var hasManyType = 'hasMany'; var hasOneType = 'hasOne'; + var DOMAIN$4 = 'Relation'; + function Relation(related, opts) { var self = this; + var DOMAIN_ERR = 'new ' + DOMAIN$4; opts || (opts = {}); var localField = opts.localField; if (!localField) { - throw new Error('localField is required!'); + throw utils$1.err(DOMAIN_ERR, 'opts.localField')(400, 'string', localField); } var foreignKey = opts.foreignKey = opts.foreignKey || opts.localKey; if (!foreignKey && (opts.type === belongsToType || opts.type === hasOneType)) { - throw new Error('foreignKey is required!'); + throw utils$1.err(DOMAIN_ERR, 'opts.foreignKey')(400, 'string', foreignKey); } var localKeys = opts.localKeys; var foreignKeys = opts.foreignKeys; if (!foreignKey && !localKeys && !foreignKeys && opts.type === hasManyType) { - throw new Error('one of (foreignKey, localKeys, foreignKeys) is required!'); + throw utils$1.err(DOMAIN_ERR, 'opts.')(400, 'string', foreignKey); } if (utils$1.isString(related)) { opts.relation = related; if (!utils$1.isFunction(opts.getRelation)) { - throw new Error('you must provide a reference to the related mapper!'); + throw utils$1.err(DOMAIN_ERR, 'opts.getRelation')(400, 'function', opts.getRelation); } } else if (related) { opts.relation = related.name; @@ -2884,7 +2906,7 @@ value: related }); } else { - throw new Error('no relation provided!'); + throw utils$1.err(DOMAIN_ERR, 'related')(400, 'Mapper or string', related); } Object.defineProperty(self, 'inverse', { @@ -2899,7 +2921,6 @@ getRelation: function getRelation() { return this.relatedMapper; }, - getLocalKeys: function getLocalKeys(record) {}, getForeignKey: function getForeignKey(record) { if (this.type === belongsToType) { return utils$1.get(record, this.foreignKey); @@ -3029,6 +3050,8 @@ }; }; + var DOMAIN$6 = 'Record'; + var superMethod = function superMethod(mapper, name) { var store = mapper.datastore; if (store && store[name]) { @@ -3102,10 +3125,12 @@ * @ignore */ _mapper: function _mapper() { - if (!this.constructor.mapper) { - throw new Error('This recordClass has no Mapper!'); + var self = this; + var mapper = self.constructor.mapper; + if (!mapper) { + throw utils$1.err(DOMAIN$6 + '#_mapper', '')(404, 'mapper'); } - return this.constructor.mapper; + return mapper; }, @@ -3252,9 +3277,6 @@ // beforeLoadRelations lifecycle hook op = opts.op = 'beforeLoadRelations'; return utils$1.resolve(self[op](relations, opts)).then(function () { - if (utils$1.isString(relations)) { - relations = [relations]; - } // Now delegate to the adapter op = opts.op = 'loadRelations'; mapper.dbg(op, self, relations, opts); @@ -3265,9 +3287,14 @@ optsCopy.raw = false; if (utils$1.isFunction(def.load)) { task = def.load(mapper, def, self, opts); - } else if (def.type === 'hasMany') { + } else if (def.type === 'hasMany' || def.type === 'hasOne') { if (def.foreignKey) { - task = superMethod(relatedMapper, 'findAll')(babelHelpers.defineProperty({}, def.foreignKey, utils$1.get(self, mapper.idAttribute)), optsCopy); + task = superMethod(relatedMapper, 'findAll')(babelHelpers.defineProperty({}, def.foreignKey, utils$1.get(self, mapper.idAttribute)), optsCopy).then(function (relatedData) { + if (def.type === 'hasOne') { + return relatedData.length ? relatedData[0] : undefined; + } + return relatedData; + }); } else if (def.localKeys) { task = superMethod(relatedMapper, 'findAll')({ where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { @@ -3281,7 +3308,7 @@ }) }, opts); } - } else if (def.type === 'belongsTo' || def.type === 'hasOne') { + } else if (def.type === 'belongsTo') { var key = utils$1.get(self, def.foreignKey); if (utils$1.isSorN(key)) { task = superMethod(relatedMapper, 'find')(key, optsCopy); @@ -3474,6 +3501,8 @@ this._set('events', value); }); + var DOMAIN$7 = 'Schema'; + /** * TODO * @@ -4093,7 +4122,7 @@ return; } if (!utils$1.isObject(schema)) { - throw new Error('Invalid schema at path: "' + opts.path + '"'); + throw utils$1.err(DOMAIN$7 + '#validate')(500, 'Invalid schema at path: "' + opts.path + '"'); } if (utils$1.isUndefined(opts.path)) { opts.path = []; @@ -4423,6 +4452,8 @@ validationKeywords: validationKeywords }); + var DOMAIN$5 = 'Mapper'; + var makeNotify = function makeNotify(num) { return function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { @@ -4723,7 +4754,7 @@ * @type {string} */ if (!self.name) { - throw new Error('name is required!'); + throw utils$1.err('new ' + DOMAIN$5, 'opts.name')(400, 'string', self.name); } // Setup schema, with an empty default schema if necessary @@ -5190,12 +5221,12 @@ })); } else if (def.type === hasManyType && def.localKeys) { // Create his hasMany relation first because it uses localKeys - tasks.push(relatedMapper.createMany(relationData, optsCopy)).then(function (data) { + tasks.push(relatedMapper.createMany(relationData, optsCopy).then(function (data) { def.setLocalField(belongsToRelationData, data); utils$1.set(props, def.localKeys, data.map(function (record) { return utils$1.get(record, relatedIdAttribute); })); - }); + })); } }); return utils$1.Promise.all(tasks).then(function () { @@ -5212,21 +5243,24 @@ if (!relationData) { return; } + optsCopy.raw = false; var task = void 0; // Create hasMany and hasOne after the main create because we needed // a generated id to attach to these items if (def.type === hasManyType && def.foreignKey) { def.setForeignKey(createdRecord, relationData); task = def.getRelation().createMany(relationData, optsCopy).then(function (data) { - def.setLocalField(createdRecord, opts.raw ? data.data : data); + def.setLocalField(createdRecord, data); }); } else if (def.type === hasOneType) { def.setForeignKey(createdRecord, relationData); task = def.getRelation().create(relationData, optsCopy).then(function (data) { - def.setLocalField(createdRecord, opts.raw ? data.data : data); + def.setLocalField(createdRecord, data); }); } else if (def.type === belongsToType && def.getLocalField(belongsToRelationData)) { def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData)); + } else if (def.type === hasManyType && def.localKeys && def.getLocalField(belongsToRelationData)) { + def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData)); } if (task) { tasks.push(task); @@ -5406,7 +5440,7 @@ }); } if (!utils$1.isObject(props)) { - throw new Error('Cannot create a record from ' + props + '!'); + throw utils$1.err(DOMAIN$5 + '#createRecord', 'props')(400, 'array or object', props); } var recordClass = self.recordClass; var relationList = self.relationList || []; @@ -5442,7 +5476,7 @@ var self = this; var config = self.lifecycleMethods[method]; if (!config) { - throw new Error(method + ': No such CRUD method!'); + throw utils$1.err(DOMAIN$5 + '#crud', method)(404, 'method'); } var upper = '' + method.charAt(0).toUpperCase() + method.substr(1); @@ -5619,7 +5653,7 @@ self.dbg('getAdapter', 'name:', name); var adapter = self.getAdapterName(name); if (!adapter) { - throw new ReferenceError(adapter + ' not found!'); + throw utils$1.err(DOMAIN$5 + '#getAdapter', 'name')(400, 'string', name); } return self.getAdapters()[adapter]; }, @@ -5931,18 +5965,22 @@ validate: function validate(record, opts) { var self = this; var schema = self.getSchema(); - if (!schema) { - throw new Error(self.name + ' mapper has no schema!'); - } if (utils$1.isArray(record)) { - return record.map(function (_record) { + var errors = record.map(function (_record) { return schema.validate(_record, opts); }); - } else if (utils$1.isObject(record)) { - return schema.validate(record, opts); - } else { - throw new Error('not a record!'); + var hasErrors = false; + errors.forEach(function (err) { + if (err) { + hasErrors = true; + } + }); + if (hasErrors) { + return errors; + } + return undefined; } + return schema.validate(record, opts); }, @@ -5961,6 +5999,8 @@ } }); + var DOMAIN$3 = 'Container'; + var toProxy = [ /** * Proxy for {@link Mapper#count}. @@ -6258,12 +6298,10 @@ // For backwards compatibility with defineResource if (utils$1.isObject(name)) { opts = name; - if (!opts.name) { - throw new Error('name is required!'); - } name = opts.name; - } else if (!utils$1.isString(name)) { - throw new Error('name is required!'); + } + if (!utils$1.isString(name)) { + throw utils$1.err(DOMAIN$3 + '#defineMapper', 'name')(400, 'string', name); } // Default values for arguments @@ -6281,6 +6319,7 @@ // Instantiate a mapper var mapper = self._mappers[name] = new mapperClass(opts); // eslint-disable-line + mapper.relations || (mapper.relations = {}); // Make sure the mapper's name is set mapper.name = name; // All mappers in this datastore will share adapters @@ -6339,7 +6378,7 @@ var self = this; var adapter = self.getAdapterName(name); if (!adapter) { - throw new ReferenceError(adapter + ' not found!'); + throw utils$1.err(DOMAIN$3 + '#getAdapter', 'name')(400, 'string', name); } return self.getAdapters()[adapter]; }, @@ -6392,7 +6431,7 @@ getMapper: function getMapper(name) { var mapper = this._mappers[name]; if (!mapper) { - throw new ReferenceError(name + ' is not a registered mapper!'); + throw utils$1.err(DOMAIN$3 + '#getMapper', name)(404, 'mapper'); } return mapper; }, @@ -6513,6 +6552,8 @@ */ var Container = Component.extend(props); + var DOMAIN$9 = 'LinkedCollection'; + /** * TODO * @@ -6534,11 +6575,13 @@ LinkedCollection.__super__.call(self, records, opts); // Make sure this collection has somewhere to store "added" timestamps - self._added = {}; + Object.defineProperty(self, '_added', { + value: {} + }); - // Make sure this collection a reference to a datastore + // Make sure this collection has a reference to a datastore if (!self.datastore) { - throw new Error('This collection must have a datastore!'); + throw utils$1.err('new ' + DOMAIN$9, 'opts.datastore')(400, 'DataStore', self.datastore); } return self; }, @@ -6562,7 +6605,7 @@ var self = this; var datastore = self.datastore; var mapper = self.mapper; - var relationList = mapper.relationList || []; + var relationList = mapper.relationList; var timestamp = new Date().getTime(); var usesRecordClass = !!mapper.recordClass; var idAttribute = mapper.idAttribute; @@ -6622,12 +6665,6 @@ } return toInsertItem; }); - // If it's the parent that has the localKeys - if (def.localKeys && !utils$1.get(record, def.localKeys)) { - utils$1.set(record, def.localKeys, relatedData.map(function (inserted) { - return utils$1.get(inserted, relationIdAttribute); - })); - } } else { var relatedDataId = utils$1.get(relatedData, relationIdAttribute); // Handle inserting belongsTo and hasOne relations @@ -6655,10 +6692,10 @@ if (foreignKey) { var _records2 = relatedCollection.filter(babelHelpers.defineProperty({}, foreignKey, id)); relatedData = _records2.length ? _records2 : undefined; - } else if (def.localKeys) { + } else if (def.localKeys && utils$1.get(record, def.localKeys)) { var _records3 = relatedCollection.filter({ where: babelHelpers.defineProperty({}, relationIdAttribute, { - 'in': utils$1.get(record, def.localKeys || []) + 'in': utils$1.get(record, def.localKeys) }) }); relatedData = _records3.length ? _records3 : undefined; @@ -6674,7 +6711,7 @@ } if (relatedData) { def.setLocalField(record, relatedData); - } + } else {} }); }); } @@ -6716,6 +6753,7 @@ } }); + var DOMAIN$8 = 'DataStore'; var DATASTORE_DEFAULTS = {}; var safeSet = function safeSet(record, field, value) { @@ -7438,7 +7476,7 @@ getCollection: function getCollection(name) { var collection = this._collections[name]; if (!collection) { - throw new ReferenceError(name + ' is not a registered collection!'); + throw utils$1.err(DOMAIN$8 + '#getCollection', name)(404, 'collection'); } return collection; }, @@ -7659,19 +7697,19 @@ * if the current version is not beta. */ var version = { - alpha: '29', - beta: 'false', - full: '3.0.0-alpha.29', - major: parseInt('3', 10), - minor: parseInt('0', 10), - patch: parseInt('0', 10) - }; + beta: 1, + full: '3.0.0-beta.1', + major: 3, + minor: 0, + patch: 0 +}; exports.version = version; exports.Collection = Collection; exports.Component = Component; exports.Container = Container; exports.DataStore = DataStore; + exports.Index = Index; exports.LinkedCollection = LinkedCollection; exports.Mapper = Mapper; exports.Query = Query; diff --git a/dist/js-data.js.map b/dist/js-data.js.map index 2ace7f07..5c239595 100644 --- a/dist/js-data.js.map +++ b/dist/js-data.js.map @@ -1 +1 @@ -{"version":3,"file":"js-data.js","sources":["../src/utils.js","../src/Component.js","../src/Query.js","../lib/mindex/utils.js","../lib/mindex/index.js","../src/Collection.js","../src/decorators.js","../src/Record.js","../src/Schema.js","../src/Mapper.js","../src/Container.js","../src/LinkedCollection.js","../src/DataStore.js","../src/index.js"],"sourcesContent":["/**\n * @name utils\n * @memberof module:js-data\n * @type {Object}\n * @property {Function} addHiddenPropsToTarget TODO\n * @property {Function} classCallCheck TODO\n * @property {Function} copy TODO\n * @property {Function} deepMixIn TODO\n * @property {Function} eventify TODO\n * @property {Function} extend TODO\n * @property {Function} fillIn TODO\n * @property {Function} fromJson TODO\n * @property {Function} get TODO\n * @property {Function} getSuper TODO\n * @property {Function} intersection TODO\n * @property {Function} isArray TODO\n * @property {Function} isBlacklisted TODO\n * @property {boolean} isBrowser TODO\n * @property {Function} isBoolean TODO\n * @property {Function} isFunction TODO\n * @property {Function} isInteger TODO\n * @property {Function} isNull TODO\n * @property {Function} isNumber TODO\n * @property {Function} isObject TODO\n * @property {Function} isRegExp TODO\n * @property {Function} isSorN TODO\n * @property {Function} isString TODO\n * @property {Function} isUndefined TODO\n * @property {Function} possibleConstructorReturn TODO\n * @property {Function} reject TODO\n * @property {Function} resolve TODO\n * @property {Function} set TODO\n * @property {Function} toJson TODO\n */\n\nconst INFINITY = 1 / 0\nconst MAX_INTEGER = 1.7976931348623157e+308\nconst BOOL_TAG = '[object Boolean]'\nconst DATE_TAG = '[object Date]'\nconst FUNC_TAG = '[object Function]'\nconst NUMBER_TAG = '[object Number]'\nconst OBJECT_TAG = '[object Object]'\nconst REGEXP_TAG = '[object RegExp]'\nconst STRING_TAG = '[object String]'\nconst objToString = Object.prototype.toString\nconst PATH = /^(.+)\\.(.+)$/\n\nconst toInteger = function (value) {\n if (!value) {\n return 0\n }\n // Coerce to number\n value = +value\n if (value === INFINITY || value === -INFINITY) {\n const sign = (value < 0 ? -1 : 1)\n return sign * MAX_INTEGER\n }\n const remainder = value % 1\n return value === value ? (remainder ? value - remainder : value) : 0 // eslint-disable-line\n}\n\nconst toStr = function (value) {\n return objToString.call(value)\n}\n\nconst isPlainObject = function (value) {\n return (!!value && typeof value === 'object' && value.constructor === Object)\n}\n\nconst mkdirP = function (object, path) {\n if (!path) {\n return object\n }\n const parts = path.split('.')\n parts.forEach(function (key) {\n if (!object[key]) {\n object[key] = {}\n }\n object = object[key]\n })\n return object\n}\n\nconst utils = {\n /**\n * TODO\n *\n * @ignore\n */\n Promise: Promise,\n\n /**\n * Shallow copy properties from src to dest that meet the following criteria:\n * - own enumerable\n * - not a function\n * - does not start with \"_\"\n *\n * @ignore\n * @param {Object} dest Destination object.\n * @param {Object} src Source object.\n */\n _ (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (key && utils.isUndefined(dest[key]) && !utils.isFunction(value) && key.indexOf('_') !== 0) {\n dest[key] = value\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _forRelation (opts, def, fn, ctx) {\n const relationName = def.relation\n let containedName = null\n let index\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n if ((index = utils._getIndex(opts.with, relationName)) >= 0) {\n containedName = relationName\n } else if ((index = utils._getIndex(opts.with, def.localField)) >= 0) {\n containedName = def.localField\n }\n\n if (opts.withAll) {\n fn.call(ctx, def, {})\n return\n } else if (!containedName) {\n return\n }\n let optsCopy = {}\n utils.fillIn(optsCopy, def.getRelation())\n utils.fillIn(optsCopy, opts)\n optsCopy.with = opts.with.slice()\n optsCopy._activeWith = optsCopy.with.splice(index, 1)[0]\n optsCopy.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n optsCopy.with[i] = relation.substr(containedName.length + 1)\n } else {\n optsCopy.with[i] = ''\n }\n })\n fn.call(ctx, def, optsCopy)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _getIndex (list, relation) {\n let index = -1\n list.forEach(function (_relation, i) {\n if (_relation === relation) {\n index = i\n return false\n } else if (utils.isObject(_relation)) {\n if (_relation.relation === relation) {\n index = i\n return false\n }\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n addHiddenPropsToTarget (target, props) {\n const map = {}\n utils.forOwn(props, function (value, key) {\n map[key] = {\n writable: true,\n value\n }\n })\n Object.defineProperties(target, map)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n areDifferent (a, b, opts) {\n opts || (opts = {})\n const diff = utils.diffObjects(a, b, opts)\n const diffCount = Object.keys(diff.added).length +\n Object.keys(diff.removed).length +\n Object.keys(diff.changed).length\n return diffCount > 0\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n classCallCheck (instance, ctor) {\n if (!(instance instanceof ctor)) {\n throw new TypeError('Cannot call a class as a function')\n }\n },\n\n /**\n * Deep copy a value.\n *\n * @ignore\n * @param {*} from Value to deep copy.\n * @return {*} Deep copy of `from`.\n */\n copy (from, to, stackFrom, stackTo, blacklist, plain) {\n if (!to) {\n to = from\n if (from) {\n if (utils.isArray(from)) {\n to = utils.copy(from, [], stackFrom, stackTo, blacklist, plain)\n } else if (utils.isDate(from)) {\n to = new Date(from.getTime())\n } else if (utils.isRegExp(from)) {\n to = new RegExp(from.source, from.toString().match(/[^\\/]*$/)[0])\n to.lastIndex = from.lastIndex\n } else if (utils.isObject(from)) {\n if (plain) {\n to = utils.copy(from, {}, stackFrom, stackTo, blacklist, plain)\n } else {\n to = utils.copy(from, Object.create(Object.getPrototypeOf(from)), stackFrom, stackTo, blacklist, plain)\n }\n }\n }\n } else {\n if (from === to) {\n throw new Error('Cannot copy! Source and destination are identical.')\n }\n\n stackFrom = stackFrom || []\n stackTo = stackTo || []\n\n if (utils.isObject(from)) {\n let index = stackFrom.indexOf(from)\n if (index !== -1) {\n return stackTo[index]\n }\n\n stackFrom.push(from)\n stackTo.push(to)\n }\n\n let result\n if (utils.isArray(from)) {\n let i\n to.length = 0\n for (i = 0; i < from.length; i++) {\n result = utils.copy(from[i], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[i])) {\n stackFrom.push(from[i])\n stackTo.push(result)\n }\n to.push(result)\n }\n } else {\n if (utils.isArray(to)) {\n to.length = 0\n } else {\n utils.forOwn(to, function (value, key) {\n delete to[key]\n })\n }\n for (var key in from) {\n if (from.hasOwnProperty(key)) {\n if (utils.isBlacklisted(key, blacklist)) {\n continue\n }\n result = utils.copy(from[key], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[key])) {\n stackFrom.push(from[key])\n stackTo.push(result)\n }\n to[key] = result\n }\n }\n }\n }\n return to\n },\n\n /**\n * Recursively shallow fill in own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepFillIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepFillIn(existing, value)\n } else if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * Recursively shallow copy own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepMixIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepMixIn(existing, value)\n } else {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * @param {Object} a Base object.\n * @param {Object} b Comparison object.\n * @return {Object} Diff.\n */\n diffObjects (a, b, opts) {\n opts || (opts = {})\n let equalsFn = opts.equalsFn\n let bl = opts.ignore\n const diff = {\n added: {},\n changed: {},\n removed: {}\n }\n if (!utils.isFunction(equalsFn)) {\n equalsFn = utils.strictEqual\n }\n\n utils.forOwn(b, function (oldValue, key) {\n const newValue = a[key]\n\n if (utils.isBlacklisted(key, bl) || equalsFn(newValue, oldValue)) {\n return\n }\n\n if (utils.isUndefined(newValue)) {\n diff.removed[key] = undefined\n } else if (!equalsFn(newValue, oldValue)) {\n diff.changed[key] = newValue\n }\n })\n\n utils.forOwn(a, function (newValue, key) {\n if (!utils.isUndefined(b[key]) || utils.isBlacklisted(key, bl)) {\n return\n }\n diff.added[key] = newValue\n })\n\n return diff\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n equal (a, b) {\n return a == b // eslint-disable-line\n },\n\n /**\n * Add eventing capabilities into the target object.\n *\n * @ignore\n * @param {Object} target Target object.\n * @param {Function} [getter] Custom getter for retrieving the object's event\n * listeners.\n * @param {Function} [setter] Custom setter for setting the object's event\n * listeners.\n */\n eventify (target, getter, setter, enumerable) {\n target = target || this\n let _events = {}\n if (!getter && !setter) {\n getter = function () {\n return _events\n }\n setter = function (value) {\n _events = value\n }\n }\n Object.defineProperties(target, {\n emit: {\n enumerable: !!enumerable,\n value (...args) {\n const events = getter.call(this) || {}\n const type = args.shift()\n let listeners = events[type] || []\n let i\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n listeners = events.all || []\n args.unshift(type)\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n }\n },\n off: {\n enumerable: !!enumerable,\n value (type, func) {\n const events = getter.call(this)\n const listeners = events[type]\n if (!listeners) {\n setter.call(this, {})\n } else if (func) {\n for (let i = 0; i < listeners.length; i++) {\n if (listeners[i].f === func) {\n listeners.splice(i, 1)\n break\n }\n }\n } else {\n listeners.splice(0, listeners.length)\n }\n }\n },\n on: {\n enumerable: !!enumerable,\n value (type, func, ctx) {\n if (!getter.call(this)) {\n setter.call(this, {})\n }\n const events = getter.call(this)\n events[type] = events[type] || []\n events[type].push({\n c: ctx,\n f: func\n })\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n extend (props, classProps) {\n const superClass = this\n let subClass\n\n props || (props = {})\n classProps || (classProps = {})\n\n if (props.hasOwnProperty('constructor')) {\n subClass = props.constructor\n delete props.constructor\n } else {\n subClass = function (...args) {\n utils.classCallCheck(this, subClass)\n const _this = utils.possibleConstructorReturn(this, (subClass.__super__ || Object.getPrototypeOf(subClass)).apply(this, args))\n return _this\n }\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n configurable: true,\n enumerable: false,\n value: subClass,\n writable: true\n }\n })\n\n const obj = Object\n if (obj.setPrototypeOf) {\n obj.setPrototypeOf(subClass, superClass)\n } else if (classProps.strictEs6Class) {\n subClass.__proto__ = superClass // eslint-disable-line\n } else {\n utils.forOwn(superClass, function (value, key) {\n subClass[key] = value\n })\n }\n Object.defineProperty(subClass, '__super__', {\n configurable: true,\n value: superClass\n })\n\n utils.addHiddenPropsToTarget(subClass.prototype, props)\n utils.fillIn(subClass, classProps)\n\n return subClass\n },\n\n /**\n * Shallow copy own enumerable properties from `src` to `dest` that are on `src`\n * but are missing from `dest.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n fillIn (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n return dest\n },\n\n /**\n * Find the index of something according to the given checker function.\n *\n * @ignore\n * @param {Array} array The array to search.\n * @param {Function} fn Checker function.\n * @param {number} Index if found or -1 if not found.\n */\n findIndex (array, fn) {\n let index = -1\n array.forEach(function (record, i) {\n if (fn(record)) {\n index = i\n return false\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n forEachRelation (mapper, opts, fn, ctx) {\n const relationList = mapper.relationList || []\n if (!relationList.length) {\n return\n }\n relationList.forEach(function (def) {\n utils._forRelation(opts, def, fn, ctx)\n })\n },\n\n /**\n * Iterate over an object's own enumerable properties.\n *\n * @ignore\n * @param {Object} object The object whose properties are to be enumerated.\n * @param {Function} fn Iteration function.\n * @param {Object} [thisArg] Content to which to bind `fn`.\n */\n forOwn (obj, fn, thisArg) {\n const keys = Object.keys(obj)\n const len = keys.length\n let i\n for (i = 0; i < len; i++) {\n fn.call(thisArg, obj[keys[i]], keys[i], obj)\n }\n },\n\n /**\n * Proxy for `JSON.parse`.\n *\n * @ignore\n * @param {string} json JSON to parse.\n * @return {Object} Parsed object.\n */\n fromJson (json) {\n return utils.isString(json) ? JSON.parse(json) : json\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n 'get': function (object, prop) {\n if (!prop) {\n return\n }\n const parts = prop.split('.')\n const last = parts.pop()\n\n while (prop = parts.shift()) { // eslint-disable-line\n object = object[prop]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n return object[last]\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n getSuper (instance, isCtor) {\n const ctor = isCtor ? instance : instance.constructor\n return (ctor.__super__ || Object.getPrototypeOf(ctor) || ctor.__proto__) // eslint-disable-line\n },\n\n /**\n * Return the intersection of two arrays.\n *\n * @ignore\n * @param {Array} array1 First array.\n * @param {Array} array2 Second array.\n * @return {Array} Array of elements common to both arrays.\n */\n intersection (array1, array2) {\n if (!array1 || !array2) {\n return []\n }\n const result = []\n let item\n let i\n const len = array1.length\n for (i = 0; i < len; i++) {\n item = array1[i]\n if (result.indexOf(item) !== -1) {\n continue\n }\n if (array2.indexOf(item) !== -1) {\n result.push(item)\n }\n }\n return result\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isArray: Array.isArray,\n\n /**\n * Return whether `prop` is matched by any string or regular expression in `bl`.\n *\n * @ignore\n * @param {string} prop The name of a property.\n * @param {Array} bl Array of strings and regular expressions.\n * @return {boolean} Whether `prop` was matched.\n */\n isBlacklisted (prop, bl) {\n if (!bl || !bl.length) {\n return false\n }\n let matches\n for (var i = 0; i < bl.length; i++) {\n if ((toStr(bl[i]) === REGEXP_TAG && bl[i].test(prop)) || bl[i] === prop) {\n matches = prop\n return matches\n }\n }\n return !!matches\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBoolean (value) {\n return toStr(value) === BOOL_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBrowser: false,\n\n /**\n * TODO\n *\n * @ignore\n */\n isDate (value) {\n return (value && typeof value === 'object' && toStr(value) === DATE_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isFunction (value) {\n return typeof value === 'function' || (value && toStr(value) === FUNC_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isInteger (value) {\n return toStr(value) === NUMBER_TAG && value == toInteger(value) // eslint-disable-line\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNull (value) {\n return value === null\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNumber (value) {\n const type = typeof value\n return type === 'number' || (value && type === 'object' && toStr(value) === NUMBER_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isObject (value) {\n return toStr(value) === OBJECT_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isRegExp (value) {\n return toStr(value) === REGEXP_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isSorN (value) {\n return utils.isString(value) || utils.isNumber(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isString (value) {\n return typeof value === 'string' || (value && typeof value === 'object' && toStr(value) === STRING_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isUndefined (value) {\n return value === undefined\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n logify (target) {\n utils.addHiddenPropsToTarget(target, {\n dbg (...args) {\n this.log('debug', ...args)\n },\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (${this.name || this.constructor.name})`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n noDupeAdd (array, record, fn) {\n const index = this.findIndex(array, fn)\n if (index < 0) {\n array.push(record)\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n omit (props, keys) {\n // Remove relations\n const _props = {}\n utils.forOwn(props, function (value, key) {\n if (keys.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n return _props\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n plainCopy (from) {\n return utils.copy(from, undefined, undefined, undefined, undefined, true)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n possibleConstructorReturn (self, call) {\n if (!self) {\n throw new ReferenceError('this hasn\\'t been initialised - super() hasn\\'t been called')\n }\n\n return call && (typeof call === 'object' || typeof call === 'function') ? call : self\n },\n\n /**\n * Proxy for `Promise.reject`.\n *\n * @ignore\n * @param {*} [value] Value with which to reject the Promise.\n * @return {Promise} Promise reject with `value`.\n */\n reject (value) {\n return utils.Promise.reject(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n remove (array, fn) {\n const index = this.findIndex(array, fn)\n if (index >= 0) {\n array.splice(index, 1)\n }\n },\n\n /**\n * Proxy for `Promise.resolve`.\n *\n * @ignore\n * @param {*} [value] Value with which to resolve the Promise.\n * @return {Promise} Promise resolved with `value`.\n */\n resolve (value) {\n return utils.Promise.resolve(value)\n },\n\n /**\n * Set the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object on which to set a property.\n * @param {(string|Object)} path The key or path to the property. Can also\n * pass in an object of path/value pairs, which will all be set on the target\n * object.\n * @param {*} [value] The value to set.\n */\n set: function (object, path, value) {\n if (utils.isObject(path)) {\n utils.forOwn(path, function (value, _path) {\n utils.set(object, _path, value)\n })\n } else {\n const parts = PATH.exec(path)\n if (parts) {\n mkdirP(object, parts[1])[parts[2]] = value\n } else {\n object[path] = value\n }\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n strictEqual (a, b) {\n let _equal = a === b\n if (!_equal) {\n if (utils.isObject(a) && utils.isObject(b)) {\n utils.forOwn(a, function (value, key) {\n _equal = _equal && utils.strictEqual(value, b[key])\n })\n utils.forOwn(b, function (value, key) {\n _equal = _equal && utils.strictEqual(value, a[key])\n })\n } else if (utils.isArray(a) && utils.isArray(b)) {\n a.forEach(function (value, i) {\n _equal = _equal && utils.strictEqual(value, b[i])\n })\n }\n }\n return _equal\n },\n\n /**\n * Proxy for `JSON.stringify`.\n *\n * @ignore\n * @param {*} value Value to serialize to JSON.\n * @return {string} JSON string.\n */\n toJson: JSON.stringify,\n\n /**\n * Unset the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object from which to delete the property.\n * @param {string} path The key or path to the property.\n */\n unset (object, path) {\n const parts = path.split('.')\n const last = parts.pop()\n\n while (path = parts.shift()) { // eslint-disable-line\n object = object[path]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n object[last] = undefined\n }\n}\n\n// Attempt to detect whether we are in the browser.\ntry {\n utils.isBrowser = !!window\n} catch (e) {\n utils.isBrowser = false\n}\n\nexport default utils\n","import utils from './utils'\n\nexport default function Component () {\n /**\n * Event listeners attached to this Component. Do not modify. Use\n * {@link Component#on} and {@link Component#off} instead.\n *\n * @name Component#_listeners\n * @instance\n * @type {Object}\n */\n Object.defineProperty(this, '_listeners', { value: {} })\n}\n\n/**\n * Create a subclass of this component.\n *\n * @name Component.extend\n * @method\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @return {Function} Subclass of this component.\n */\nComponent.extend = utils.extend\n\n/**\n * TODO\n *\n * @name Component#dbg\n * @method\n */\n/**\n * TODO\n *\n * @name Component#log\n * @method\n */\nutils.logify(Component.prototype)\n\n/**\n * Register a new event listener on this Component.\n *\n * @name Component#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n/**\n * Remove an event listener from this Component. If no listener is provided,\n * then all listeners for the specified event will be removed. If no event is\n * specified then all listeners for all events will be removed.\n *\n * @name Component#off\n * @method\n * @param {string} [event] Name of event to unsubsribe to.\n * @param {Function} [listener] Listener to remove.\n */\n/**\n * Trigger an event on this Component.\n *\n * @name Component#emit\n * @method\n * @param {string} event Name of event to emit.\n * @param {...*} [args] Arguments to pass to any listeners.\n */\nutils.eventify(\n Component.prototype,\n function () {\n return this._listeners\n },\n function (value) {\n this._listeners = value\n }\n)\n","import utils from './utils'\nimport Component from './Component'\n\n// Reserved words used by JSData's Query Syntax\nconst reserved = {\n limit: '',\n offset: '',\n orderBy: '',\n skip: '',\n sort: '',\n where: ''\n}\n\n// Used by our JavaScript implementation of the LIKE operator\nconst escapeRegExp = /([.*+?^=!:${}()|[\\]\\/\\\\])/g\nconst percentRegExp = /%/g\nconst underscoreRegExp = /_/g\nconst escape = function (pattern) {\n return pattern.replace(escapeRegExp, '\\\\$1')\n}\n\n/**\n * A class used by the {@link Collection} class to build queries to be executed\n * against the collection's data. An instance of `Query` is returned by\n * {@link Collection#query}. Query instances are typically short-lived.\n *\n * ```javascript\n * import {Query} from 'js-data'\n * ```\n *\n * @class Query\n * @extends Component\n * @param {Collection} collection The collection on which this query operates.\n */\nexport default Component.extend({\n constructor: function Query (collection) {\n const self = this\n utils.classCallCheck(self, Query)\n\n /**\n * The {@link Collection} on which this query operates.\n *\n * @name Query#collection\n * @type {Collection}\n */\n self.collection = collection\n\n /**\n * The current data result of this query.\n *\n * @name Query#data\n * @type {Array}\n */\n self.data = null\n },\n\n /**\n * Find all entities between two boundaries.\n *\n * Get the users ages 18 to 30\n * ```js\n * const users = query.between(18, 30, { index: 'age' }).run()\n * ```\n * Same as above\n * ```js\n * const users = query.between([18], [30], { index: 'age' }).run()\n * ```\n *\n * @name Query#between\n * @method\n * @param {Array} leftKeys - Keys defining the left boundary.\n * @param {Array} rightKeys - Keys defining the right boundary.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.limit] - Limit the result to a certain number.\n * @param {boolean} [opts.offset] - The number of resulting entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n between (leftKeys, rightKeys, opts) {\n const self = this\n opts || (opts = {})\n if (self.data) {\n throw new Error('Cannot access index after first operation!')\n }\n self.data = self.collection.getIndex(opts.index).between(leftKeys, rightKeys, opts)\n return self\n },\n\n /**\n * The comparison function used by the Query class.\n *\n * @name Query#compare\n * @method\n * @param {Array} orderBy An orderBy clause used for sorting and sub-sorting.\n * @param {number} index The index of the current orderBy clause being used.\n * @param {*} a The first item in the comparison.\n * @param {*} b The second item in the comparison.\n * @return {number} -1 if `b` should preceed `a`. 0 if `a` and `b` are equal.\n * 1 if `a` should preceed `b`.\n */\n compare (orderBy, index, a, b) {\n const def = orderBy[index]\n let cA = utils.get(a, def[0])\n let cB = utils.get(b, def[0])\n if (cA && utils.isString(cA)) {\n cA = cA.toUpperCase()\n }\n if (cB && utils.isString(cB)) {\n cB = cB.toUpperCase()\n }\n if (a === undefined) {\n a = null\n }\n if (b === undefined) {\n b = null\n }\n if (def[1].toUpperCase() === 'DESC') {\n const temp = cB\n cB = cA\n cA = temp\n }\n if (cA < cB) {\n return -1\n } else if (cA > cB) {\n return 1\n } else {\n if (index < orderBy.length - 1) {\n return this.compare(orderBy, index + 1, a, b)\n } else {\n return 0\n }\n }\n },\n\n /**\n * Predicate evaluation function used by the Query class.\n *\n * @name Query#evaluate\n * @method\n * @param {*} value The value to evaluate.\n * @param {string} op The operator to use in this evaluation.\n * @param {*} predicate The predicate to use in this evaluation.\n * @return {boolean} Whether the value passed the evaluation or not.\n */\n evaluate (value, op, predicate) {\n const ops = this.constructor.ops\n if (ops[op]) {\n return ops[op](value, predicate)\n }\n if (op.indexOf('like') === 0) {\n return !utils.isNull(this.like(predicate, op.substr(4)).exec(value))\n } else if (op.indexOf('notLike') === 0) {\n return utils.isNull(this.like(predicate, op.substr(7)).exec(value))\n }\n },\n\n /**\n * Find the entity or entities that match the provided query or pass the\n * provided filter function.\n *\n * #### Example\n *\n * Get the draft posts created less than three months\n * ```js\n * const posts = query.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * }).run()\n * ```\n * Use a custom filter function\n * ```js\n * const posts = query.filter(function (post) {\n * return post.isReady()\n * }).run()\n * ```\n *\n * @name Query#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Function} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Query} A reference to itself for chaining.\n */\n filter (query, thisArg) {\n const self = this\n query || (query = {})\n self.getData()\n if (utils.isObject(query)) {\n let where = {}\n // Filter\n if (utils.isObject(query.where)) {\n where = query.where\n }\n utils.forOwn(query, function (value, key) {\n if (!(key in reserved) && !(key in where)) {\n where[key] = {\n '==': value\n }\n }\n })\n\n const fields = []\n const ops = []\n const predicates = []\n utils.forOwn(where, function (clause, field) {\n if (!utils.isObject(clause)) {\n clause = {\n '==': clause\n }\n }\n utils.forOwn(clause, function (expr, op) {\n fields.push(field)\n ops.push(op)\n predicates.push(expr)\n })\n })\n if (fields.length) {\n let i\n let len = fields.length\n self.data = self.data.filter(function (item) {\n let first = true\n let keep = true\n\n for (i = 0; i < len; i++) {\n let op = ops[i]\n const isOr = op.charAt(0) === '|'\n op = isOr ? op.substr(1) : op\n const expr = self.evaluate(utils.get(item, fields[i]), op, predicates[i])\n if (expr !== undefined) {\n keep = first ? expr : (isOr ? keep || expr : keep && expr)\n }\n first = false\n }\n return keep\n })\n }\n\n // Sort\n let orderBy = query.orderBy || query.sort\n\n if (utils.isString(orderBy)) {\n orderBy = [\n [orderBy, 'ASC']\n ]\n }\n if (!utils.isArray(orderBy)) {\n orderBy = null\n }\n\n // Apply 'orderBy'\n if (orderBy) {\n let index = 0\n orderBy.forEach(function (def, i) {\n if (utils.isString(def)) {\n orderBy[i] = [def, 'ASC']\n }\n })\n self.data.sort(function (a, b) {\n return self.compare(orderBy, index, a, b)\n })\n }\n\n // Skip\n if (utils.isNumber(query.skip)) {\n self.skip(query.skip)\n } else if (utils.isNumber(query.offset)) {\n self.skip(query.offset)\n }\n // Limit\n if (utils.isNumber(query.limit)) {\n self.limit(query.limit)\n }\n } else if (utils.isFunction(query)) {\n self.data = self.data.filter(query, thisArg)\n }\n return self\n },\n\n /**\n * Iterate over all entities.\n *\n * @name Query#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Query} A reference to itself for chaining.\n */\n forEach (forEachFn, thisArg) {\n this.getData().forEach(forEachFn, thisArg)\n return this\n },\n\n /**\n * Find the entity or entities that match the provided key.\n *\n * #### Example\n *\n * Get the entity whose primary key is 25\n * ```js\n * const entities = query.get(25).run()\n * ```\n * Same as above\n * ```js\n * const entities = query.get([25]).run()\n * ```\n * Get all users who are active and have the \"admin\" role\n * ```js\n * const activeAdmins = query.get(['active', 'admin'], {\n * index: 'activityAndRoles'\n * }).run()\n * ```\n * Get all entities that match a certain weather condition\n * ```js\n * const niceDays = query.get(['sunny', 'humid', 'calm'], {\n * index: 'weatherConditions'\n * }).run()\n * ```\n *\n * @name Query#get\n * @method\n * @param {Array} keyList - Key(s) defining the entity to retrieve. If\n * `keyList` is not an array (i.e. for a single-value key), it will be\n * wrapped in an array.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.string] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n get (keyList, opts) {\n const self = this\n keyList || (keyList = [])\n opts || (opts = {})\n if (self.data) {\n throw new Error('Cannot access index after first operation!')\n }\n if (keyList && !utils.isArray(keyList)) {\n keyList = [keyList]\n }\n if (!keyList.length) {\n self.getData()\n return self\n }\n self.data = self.collection.getIndex(opts.index).get(keyList)\n return self\n },\n\n /**\n * Find the entity or entities that match the provided keyLists.\n *\n * #### Example\n *\n * Get the posts where \"status\" is \"draft\" or \"inReview\"\n * ```js\n * const posts = query.getAll('draft', 'inReview', { index: 'status' }).run()\n * ```\n * Same as above\n * ```js\n * const posts = query.getAll(['draft'], ['inReview'], { index: 'status' }).run()\n * ```\n *\n * @name Query#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * entities matching each keyList will be retrieved. If no keyLists are\n * provided, all entities will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n getAll (...args) {\n const self = this\n let opts = {}\n if (self.data) {\n throw new Error('Cannot access index after first operation!')\n }\n if (!args.length || args.length === 1 && utils.isObject(args[0])) {\n self.getData()\n return self\n } else if (args.length && utils.isObject(args[args.length - 1])) {\n opts = args[args.length - 1]\n args.pop()\n }\n const collection = self.collection\n const index = collection.getIndex(opts.index)\n self.data = []\n args.forEach(function (keyList) {\n self.data = self.data.concat(index.get(keyList))\n })\n return self\n },\n\n /**\n * Return the current data result of this query.\n * @name Query#getData\n * @method\n * @return {Array} The data in this query.\n */\n getData () {\n const self = this\n if (!self.data) {\n self.data = self.collection.index.getAll()\n }\n return self.data\n },\n\n like (pattern, flags) {\n return new RegExp(`^${(escape(pattern).replace(percentRegExp, '.*').replace(underscoreRegExp, '.'))}$`, flags)\n },\n\n /**\n * Limit the result.\n *\n * #### Example\n *\n * Get only the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).limit(10).run()\n * ```\n *\n * @name Query#limit\n * @method\n * @param {number} num - The maximum number of entities to keep in the result.\n * @return {Query} A reference to itself for chaining.\n */\n limit (num) {\n if (!utils.isNumber(num)) {\n throw new TypeError(`limit: Expected number but found ${typeof num}!`)\n }\n const data = this.getData()\n this.data = data.slice(0, Math.min(data.length, num))\n return this\n },\n\n /**\n * Apply a mapping function to the result data.\n *\n * @name Query#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Query} A reference to itself for chaining.\n */\n map (mapFn, thisArg) {\n this.data = this.getData().map(mapFn, thisArg)\n return this\n },\n\n /**\n * Return the result of calling the specified function on each item in this\n * collection's main index.\n * @name Query#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Query} A reference to itself for chaining.\n */\n mapCall (funcName, ...args) {\n this.data = this.getData().map(function (item) {\n return item[funcName](...args)\n })\n return this\n },\n\n /**\n * Complete the execution of the query and return the resulting data.\n *\n * @name Query#run\n * @method\n * @return {Array} The result of executing this query.\n */\n run () {\n const data = this.data\n this.data = null\n return data\n },\n\n /**\n * Skip a number of results.\n *\n * #### Example\n *\n * Get all but the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).skip(10).run()\n * ```\n *\n * @name Query#skip\n * @method\n * @param {number} num - The number of entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n skip (num) {\n if (!utils.isNumber(num)) {\n throw new TypeError(`skip: Expected number but found ${typeof num}!`)\n }\n const data = this.getData()\n if (num < data.length) {\n this.data = data.slice(num)\n } else {\n this.data = []\n }\n return this\n }\n}, {\n /**\n * TODO\n *\n * @name Query.ops\n * @type {Object}\n */\n ops: {\n '==': function (value, predicate) {\n return value == predicate // eslint-disable-line\n },\n '===': function (value, predicate) {\n return value === predicate\n },\n '!=': function (value, predicate) {\n return value != predicate // eslint-disable-line\n },\n '!==': function (value, predicate) {\n return value !== predicate\n },\n '>': function (value, predicate) {\n return value > predicate\n },\n '>=': function (value, predicate) {\n return value >= predicate\n },\n '<': function (value, predicate) {\n return value < predicate\n },\n '<=': function (value, predicate) {\n return value <= predicate\n },\n 'isectEmpty': function (value, predicate) {\n return !utils.intersection((value || []), (predicate || [])).length\n },\n 'isectNotEmpty': function (value, predicate) {\n return utils.intersection((value || []), (predicate || [])).length\n },\n 'in': function (value, predicate) {\n return predicate.indexOf(value) !== -1\n },\n 'notIn': function (value, predicate) {\n return predicate.indexOf(value) === -1\n },\n 'contains': function (value, predicate) {\n return (value || []).indexOf(predicate) !== -1\n },\n 'notContains': function (value, predicate) {\n return (value || []).indexOf(predicate) === -1\n }\n }\n})\n","export function sort (a, b, hashCode) {\n // Short-curcuit comparison if a and b are strictly equal\n // This is absolutely necessary for indexed objects that\n // don't have the idAttribute field\n if (a === b) {\n return 0\n }\n if (hashCode) {\n a = hashCode(a)\n b = hashCode(b)\n }\n if (a === null && b === null) {\n return 0\n }\n\n if (a === null) {\n return -1\n }\n\n if (b === null) {\n return 1\n }\n\n if (a < b) {\n return -1\n }\n\n if (a > b) {\n return 1\n }\n\n return 0\n}\n\nexport function insertAt (array, index, value) {\n array.splice(index, 0, value)\n return array\n}\n\nexport function removeAt (array, index) {\n array.splice(index, 1)\n return array\n}\n\nexport function binarySearch (array, value, field) {\n let lo = 0\n let hi = array.length\n let compared\n let mid\n\n while (lo < hi) {\n mid = ((lo + hi) / 2) | 0\n compared = sort(value, array[mid], field)\n if (compared === 0) {\n return {\n found: true,\n index: mid\n }\n } else if (compared < 0) {\n hi = mid\n } else {\n lo = mid + 1\n }\n }\n\n return {\n found: false,\n index: hi\n }\n}\n","// Copyright (c) 2015, InternalFX.\n\n// Permission to use, copy, modify, and/or distribute this software for any purpose with or\n// without fee is hereby granted, provided that the above copyright notice and this permission\n// notice appear in all copies.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO\n// THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT\n// SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR\n// ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE\n// USE OR PERFORMANCE OF THIS SOFTWARE.\n\n// Modifications\n// Copyright 2015-2016 Jason Dobry\n//\n// Summary of modifications:\n// Converted to ES6 Class syntax\n// Reworked dependencies so as to re-use code already in js-data\nimport utils from '../../src/utils'\nimport {binarySearch, insertAt, removeAt} from './utils'\n\nexport default function Index (fieldList, opts) {\n utils.classCallCheck(this, Index)\n fieldList || (fieldList = [])\n\n if (!utils.isArray(fieldList)) {\n throw new Error('fieldList must be an array.')\n }\n\n opts || (opts = {})\n this.fieldList = fieldList\n this.fieldGetter = opts.fieldGetter\n this.hashCode = opts.hashCode\n this.isIndex = true\n this.keys = []\n this.values = []\n}\n\nutils.addHiddenPropsToTarget(Index.prototype, {\n 'set' (keyList, value) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n let dataLocation = binarySearch(this.values[pos.index], value, this.hashCode)\n if (!dataLocation.found) {\n insertAt(this.values[pos.index], dataLocation.index, value)\n }\n } else {\n insertAt(this.keys, pos.index, key)\n insertAt(this.values, pos.index, [value])\n }\n } else {\n if (pos.found) {\n this.values[pos.index].set(keyList, value)\n } else {\n insertAt(this.keys, pos.index, key)\n let newIndex = new Index([], { hashCode: this.hashCode })\n newIndex.set(keyList, value)\n insertAt(this.values, pos.index, newIndex)\n }\n }\n },\n\n 'get' (keyList) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n if (this.values[pos.index].isIndex) {\n return this.values[pos.index].getAll()\n } else {\n return this.values[pos.index]\n }\n } else {\n return []\n }\n } else {\n if (pos.found) {\n return this.values[pos.index].get(keyList)\n } else {\n return []\n }\n }\n },\n\n getAll () {\n let results = []\n this.values.forEach(function (value) {\n if (value.isIndex) {\n results = results.concat(value.getAll())\n } else {\n results = results.concat(value)\n }\n })\n return results\n },\n\n visitAll (cb, thisArg) {\n this.values.forEach(function (value) {\n if (value.isIndex) {\n value.visitAll(cb, thisArg)\n } else {\n value.forEach(cb, thisArg)\n }\n })\n },\n\n between (leftKeys, rightKeys, opts) {\n opts || (opts = {})\n if (!utils.isArray(leftKeys)) {\n leftKeys = [leftKeys]\n }\n if (!utils.isArray(rightKeys)) {\n rightKeys = [rightKeys]\n }\n utils.fillIn(opts, {\n leftInclusive: true,\n rightInclusive: false,\n limit: undefined,\n offset: 0\n })\n\n let results = this._between(leftKeys, rightKeys, opts)\n\n if (opts.limit) {\n return results.slice(opts.offset, opts.limit + opts.offset)\n } else {\n return results.slice(opts.offset)\n }\n },\n\n _between (leftKeys, rightKeys, opts) {\n let results = []\n\n let leftKey = leftKeys.shift()\n let rightKey = rightKeys.shift()\n\n let pos\n\n if (leftKey !== undefined) {\n pos = binarySearch(this.keys, leftKey)\n } else {\n pos = {\n found: false,\n index: 0\n }\n }\n\n if (leftKeys.length === 0) {\n if (pos.found && opts.leftInclusive === false) {\n pos.index += 1\n }\n\n for (let i = pos.index; i < this.keys.length; i += 1) {\n if (rightKey !== undefined) {\n if (opts.rightInclusive) {\n if (this.keys[i] > rightKey) { break }\n } else {\n if (this.keys[i] >= rightKey) { break }\n }\n }\n\n if (this.values[i].isIndex) {\n results = results.concat(this.values[i].getAll())\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n } else {\n for (let i = pos.index; i < this.keys.length; i += 1) {\n let currKey = this.keys[i]\n if (currKey > rightKey) { break }\n\n if (this.values[i].isIndex) {\n if (currKey === leftKey) {\n results = results.concat(this.values[i]._between(utils.copy(leftKeys), rightKeys.map(function () { return undefined }), opts))\n } else if (currKey === rightKey) {\n results = results.concat(this.values[i]._between(leftKeys.map(function () { return undefined }), utils.copy(rightKeys), opts))\n } else {\n results = results.concat(this.values[i].getAll())\n }\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n }\n\n if (opts.limit) {\n return results.slice(0, opts.limit + opts.offset)\n } else {\n return results\n }\n },\n\n peek () {\n if (this.values.length) {\n if (this.values[0].isIndex) {\n return this.values[0].peek()\n } else {\n return this.values[0]\n }\n }\n return []\n },\n\n clear () {\n this.keys = []\n this.values = []\n },\n\n insertRecord (data) {\n let keyList = this.fieldList.map(function (field) {\n if (utils.isFunction(field)) {\n return field(data) || null\n } else {\n return data[field] || null\n }\n })\n this.set(keyList, data)\n },\n\n removeRecord (data) {\n let removed\n this.values.forEach((value, i) => {\n if (value.isIndex) {\n if (value.removeRecord(data)) {\n if (value.keys.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n } else {\n const dataLocation = binarySearch(value, data, this.hashCode)\n if (dataLocation.found) {\n removeAt(value, dataLocation.index)\n if (value.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n }\n })\n return removed ? data : undefined\n },\n\n updateRecord (data) {\n this.removeRecord(data)\n this.insertRecord(data)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Query from './Query'\nimport Index from '../lib/mindex/index'\n\nconst COLLECTION_DEFAULTS = {\n /**\n * Field to be used as the unique identifier for records in this collection.\n * Defaults to `\"id\"` unless {@link Collection#mapper} is set, in which case\n * this will default to {@link Mapper#idAttribute}.\n *\n * @name Collection#idAttribute\n * @type {string}\n * @default \"id\"\n */\n idAttribute: 'id',\n\n /**\n * What to do when inserting a record into this Collection that shares a\n * primary key with a record already in this Collection.\n *\n * Possible values:\n * - merge\n * - replace\n *\n * Merge:\n *\n * Recursively shallow copy properties from the new record onto the existing\n * record.\n *\n * Replace:\n *\n * Shallow copy top-level properties from the new record onto the existing\n * record. Any top-level own properties of the existing record that are _not_\n * on the new record will be removed.\n *\n * @name Collection#onConflict\n * @type {string}\n * @default \"merge\"\n */\n onConflict: 'merge'\n}\n\n/**\n * ```javascript\n * import {Collection} from 'js-data'\n * ```\n *\n * An ordered set of {@link Record} instances.\n *\n * @example\n * import {Collection, Record} from 'js-data'\n * const user1 = new Record({ id: 1 })\n * const user2 = new Record({ id: 2 })\n * const UserCollection = new Collection([user1, user2])\n * UserCollection.get(1) === user1 // true\n *\n * @class Collection\n * @extends Component\n * @param {Array} [records] Initial set of records to insert into the\n * collection.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.idAttribute] See {@link Collection#idAttribute}.\n * @param {string} [opts.onConflict=\"merge\"] See {@link Collection#onConflict}.\n * @param {string} [opts.mapper] See {@link Collection#mapper}.\n */\nexport default Component.extend({\n constructor: function Collection (records, opts) {\n const self = this\n utils.classCallCheck(self, Collection)\n Collection.__super__.call(self)\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n opts = records\n records = []\n }\n if (utils.isString(opts)) {\n opts = { idAttribute: opts }\n }\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n /**\n * Default Mapper for this collection. Optional. If a Mapper is provided, then\n * the collection will use the {@link Mapper#idAttribute} setting, and will\n * wrap records in {@link Mapper#recordClass}.\n *\n * @example\n * import {Collection, Mapper} from 'js-data'\n *\n * class MyMapperClass extends Mapper {\n * foo () { return 'bar' }\n * }\n * const myMapper = new MyMapperClass()\n * const collection = new Collection(null, { mapper: myMapper })\n *\n * @name Collection#mapper\n * @type {Mapper}\n * @default null\n */\n Object.defineProperty(self, 'mapper', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n utils.fillIn(self, utils.copy(COLLECTION_DEFAULTS))\n\n const idAttribute = self.recordId()\n\n Object.defineProperties(self, {\n /**\n * The main index, which uses @{link Collection#recordId} as the key.\n *\n * @name Collection#index\n * @type {Index}\n */\n index: {\n value: new Index([idAttribute], {\n hashCode (obj) {\n return utils.get(obj, idAttribute)\n }\n })\n },\n\n /**\n * Object that holds the secondary indexes of this collection.\n *\n * @name Collection#indexes\n * @type {Object.}\n */\n indexes: {\n value: {}\n }\n })\n\n const mapper = self.mapper\n\n // Insert initial data into the collection\n records.forEach(function (record) {\n record = mapper ? mapper.createRecord(record, opts) : record\n self.index.insertRecord(record)\n if (record && utils.isFunction(record.on)) {\n record.on('all', self._onRecordEvent, self)\n }\n })\n },\n\n /**\n * Used to bind to events emitted by records in this Collection.\n *\n * @name Collection#_onRecordEvent\n * @method\n * @private\n * @param {...*} [arg] Args passed to {@link Collection#emit}.\n */\n _onRecordEvent (...args) {\n this.emit(...args)\n },\n\n /**\n * Insert the provided record or records.\n *\n * If a record is already in the collection then the provided record will\n * either merge with or replace the existing record based on the value of the\n * `onConflict` option.\n *\n * The collection's secondary indexes will be updated as each record is\n * visited.\n *\n * @name Collection#add\n * @method\n * @param {(Object|Object[]|Record|Record[])} data The record or records to insert.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.onConflict] What to do when a record is already in\n * the collection. Possible values are `merge` or `replace`.\n * @return {(Object|Object[]|Record|Record[])} The added record or records.\n */\n add (records, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n\n // Fill in \"opts\" with the Collection's configuration\n utils._(opts, self)\n records = self.beforeAdd(records, opts) || records\n\n // Track whether just one record or an array of records is being inserted\n let singular = false\n const idAttribute = self.recordId()\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n singular = true\n }\n\n // Map the provided records to existing records.\n // New records will be inserted. If any records map to existing records,\n // they will be merged into the existing records according to the onConflict\n // option.\n records = records.map(function (record) {\n let id = self.recordId(record)\n if (!utils.isSorN(id)) {\n throw new TypeError(`Collection#add: Expected string or number for ${idAttribute}, found ${typeof id}!`)\n }\n // Grab existing record if there is one\n const existing = self.get(id)\n // If the currently visited record is just a reference to an existing\n // record, then there is nothing to be done. Exit early.\n if (record === existing) {\n return existing\n }\n\n if (existing) {\n // Here, the currently visited record corresponds to a record already\n // in the collection, so we need to merge them\n const onConflict = opts.onConflict || self.onConflict\n if (onConflict === 'merge') {\n utils.deepMixIn(existing, record)\n } else if (onConflict === 'replace') {\n utils.forOwn(existing, (value, key) => {\n if (key !== idAttribute && !record.hasOwnProperty(key)) {\n delete existing[key]\n }\n })\n existing.set(record)\n }\n record = existing\n // Update all indexes in the collection\n self.updateIndexes(record)\n } else {\n // Here, the currently visted record does not correspond to any record\n // in the collection, so (optionally) instantiate this record and insert\n // it into the collection\n record = self.mapper ? self.mapper.createRecord(record, opts) : record\n self.index.insertRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.insertRecord(record)\n })\n if (record && utils.isFunction(record.on)) {\n record.on('all', self._onRecordEvent, self)\n }\n }\n return record\n })\n // Finally, return the inserted data\n const result = singular ? (records.length ? records[0] : undefined) : records\n // TODO: Make this more performant (batch events?)\n self.emit('add', result)\n return self.afterAdd(records, opts, result) || result\n },\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then {@link Collection#add} will return that same value.\n *\n * @name Collection#method\n * @method\n * @param {(Object|Object[]|Record|Record[])} result The record or records\n * that were added to this Collection by {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n afterAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}. If this method returns\n * a value then {@link Collection#remove} will return that same value.\n *\n * @name Collection#afterRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n * @param {Object} record The result that will be returned by {@link Collection#remove}.\n */\n afterRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}. If this method\n * returns a value then {@link Collection#removeAll} will return that same\n * value.\n *\n * @name Collection#afterRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n * @param {Object} records The result that will be returned by {@link Collection#removeAll}.\n */\n afterRemoveAll () {},\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then the `records` argument in {@link Collection#add} will be\n * re-assigned to the returned value.\n *\n * @name Collection#beforeAdd\n * @method\n * @param {(Object|Object[]|Record|Record[])} records The `records` argument passed to {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n beforeAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}.\n *\n * @name Collection#beforeRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n */\n beforeRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}.\n *\n * @name Collection#beforeRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n */\n beforeRemoveAll () {},\n\n /**\n * Find all records between two boundaries.\n *\n * Shortcut for `collection.query().between(18, 30, { index: 'age' }).run()`\n *\n * @example Get all users ages 18 to 30\n * const users = collection.between(18, 30, { index: 'age' })\n *\n * @example Same as above\n * const users = collection.between([18], [30], { index: 'age' })\n *\n * @name Collection#between\n * @method\n * @param {Array} leftKeys Keys defining the left boundary.\n * @param {Array} rightKeys Keys defining the right boundary.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.index] Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.limit] Limit the result to a certain number.\n * @param {boolean} [opts.offset] The number of resulting records to skip.\n * @return {Array} The result.\n */\n between (leftKeys, rightKeys, opts) {\n return this.query().between(leftKeys, rightKeys, opts).run()\n },\n\n /**\n * Create a new secondary index on the contents of the collection.\n *\n * @example Index users by age\n * collection.createIndex('age')\n *\n * @example Index users by status and role\n * collection.createIndex('statusAndRole', ['status', 'role'])\n *\n * @name Collection#createIndex\n * @method\n * @param {string} name - The name of the new secondary index.\n * @param {string[]} [fieldList] - Array of field names to use as the key or\n * compound key of the new secondary index. If no fieldList is provided, then\n * the name will also be the field that is used to index the collection.\n * @return {Collection} A reference to itself for chaining.\n */\n createIndex (name, fieldList, opts) {\n const self = this\n if (utils.isString(name) && fieldList === undefined) {\n fieldList = [name]\n }\n opts || (opts = {})\n opts.hashCode = opts.hashCode || function (obj) {\n return self.recordId(obj)\n }\n const index = self.indexes[name] = new Index(fieldList, opts)\n self.index.visitAll(index.insertRecord, index)\n return self\n },\n\n /**\n * Find the record or records that match the provided query or pass the\n * provided filter function.\n *\n * Shortcut for `collection.query().filter(queryOrFn[, thisArg]).run()`\n *\n * @example Get the draft posts created less than three months\n * const posts = collection.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * })\n *\n * @example Use a custom filter function\n * const posts = collection.filter(function (post) {\n * return post.isReady()\n * })\n *\n * @name Collection#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Object} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Array} The result.\n */\n filter (query, thisArg) {\n return this.query().filter(query, thisArg).run()\n },\n\n /**\n * Iterate over all records.\n *\n * @example\n * collection.forEach(function (record) {\n * // do something\n * })\n *\n * @name Collection#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Array} The result.\n */\n forEach (cb, thisArg) {\n this.index.visitAll(cb, thisArg)\n },\n\n /**\n * Get the record with the given id.\n *\n * @name Collection#get\n * @method\n * @param {(string|number)} id - The primary key of the record to get.\n * @return {(Object|Record)} The record with the given id.\n */\n get (id) {\n const instances = this.query().get(id).run()\n return instances.length ? instances[0] : undefined\n },\n\n /**\n * Find the record or records that match the provided keyLists.\n *\n * Shortcut for `collection.query().getAll(keyList1, keyList2, ...).run()`\n *\n * @example Get the posts where \"status\" is \"draft\" or \"inReview\"\n * const posts = collection.getAll('draft', 'inReview', { index: 'status' })\n *\n * @example Same as above\n * const posts = collection.getAll(['draft'], ['inReview'], { index: 'status' })\n *\n * @name Collection#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * records matching each keyList will be retrieved. If no keyLists are\n * provided, all records will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Array} The result.\n */\n getAll (...args) {\n return this.query().getAll(...args).run()\n },\n\n /**\n * Return the index with the given name. If no name is provided, return the\n * main index. Throws an error if the specified index does not exist.\n *\n * @name Collection#getIndex\n * @method\n * @param {string} [name] The name of the index to retrieve.\n */\n getIndex (name) {\n const index = name ? this.indexes[name] : this.index\n if (!index) {\n throw new Error(`Index ${name} does not exist!`)\n }\n return index\n },\n\n /**\n * Limit the result.\n *\n * Shortcut for `collection.query().limit(maximumNumber).run()`\n *\n * @example\n * const posts = collection.limit(10)\n *\n * @name Collection#limit\n * @method\n * @param {number} num - The maximum number of records to keep in the result.\n * @return {Array} The result.\n */\n limit (num) {\n return this.query().limit(num).run()\n },\n\n /**\n * Apply a mapping function to all records.\n *\n * @example\n * const names = collection.map(function (user) {\n * return user.name\n * })\n *\n * @name Collection#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Array} The result of the mapping.\n */\n map (cb, thisArg) {\n const data = []\n this.index.visitAll(function (value) {\n data.push(cb.call(thisArg, value))\n })\n return data\n },\n\n /**\n * Return the result of calling the specified function on each record in this\n * collection's main index.\n *\n * @name Collection#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Array} The result.\n */\n mapCall (funcName, ...args) {\n const data = []\n this.index.visitAll(function (record) {\n data.push(record[funcName](...args))\n })\n return data\n },\n\n /**\n * Return the primary key of the given, or if no record is provided, return the\n * name of the field that holds the primary key of records in this Collection.\n *\n * @name Collection#recordId\n * @method\n * @param {(Object|Record)} [record] The record whose primary key is to be\n * returned.\n * @return {(string|number)} Primary key or name of field that holds primary\n * key.\n */\n recordId (record) {\n const self = this\n if (record) {\n return utils.get(record, self.recordId())\n }\n return self.mapper ? self.mapper.idAttribute : self.idAttribute || 'id'\n },\n\n /**\n * Create a new query to be executed against the contents of the collection.\n * The result will be all or a subset of the contents of the collection.\n *\n * @example Grab page 2 of users between ages 18 and 30\n * collection.query()\n * .between(18, 30, { index: 'age' }) // between ages 18 and 30\n * .skip(10) // second page\n * .limit(10) // page size\n * .run()\n *\n * @name Collection#query\n * @method\n * @return {Query} New query object.\n */\n query () {\n return new Query(this)\n },\n\n /**\n * Reduce the data in the collection to a single value and return the result.\n *\n * @example\n * const totalVotes = collection.reduce(function (prev, record) {\n * return prev + record.upVotes + record.downVotes\n * }, 0)\n *\n * @name Collection#reduce\n * @method\n * @param {Function} cb - Reduction callback.\n * @param {*} initialValue - Initial value of the reduction.\n * @return {*} The result.\n */\n reduce (cb, initialValue) {\n const data = this.getAll()\n return data.reduce(cb, initialValue)\n },\n\n /**\n * Remove the record with the given id from this Collection.\n *\n * @name Collection#remove\n * @method\n * @param {(string|number)} id - The primary key of the record to be removed.\n * @param {Object} [opts] - Configuration options.\n * @return {Object|Record} The removed record, if any.\n */\n remove (id, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemove(id, opts)\n const record = self.get(id)\n\n // The record is in the collection, remove it\n if (record) {\n self.index.removeRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.removeRecord(record)\n })\n if (record && utils.isFunction(record.off)) {\n record.off('all', self._onRecordEvent, self)\n self.emit('remove', record)\n }\n }\n return self.afterRemove(id, opts, record) || record\n },\n\n /**\n * Remove the record selected by \"query\" from this collection.\n *\n * @name Collection#removeAll\n * @method\n * @param {Object} [query={}] - Selection query.\n * @param {Object} [query.where] - Filtering criteria.\n * @param {number} [query.skip] - Number to skip.\n * @param {number} [query.limit] - Number to limit to.\n * @param {Array} [query.orderBy] - Sorting criteria.\n * @param {Object} [opts] - Configuration options.\n * @return {(Object[]|Record[])} The removed records, if any.\n */\n removeAll (query, opts) {\n const self = this\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemoveAll(query, opts)\n const records = self.filter(query)\n\n // Remove each selected record from the collection\n records.forEach(function (item) {\n self.remove(self.recordId(item), opts)\n })\n return self.afterRemoveAll(query, opts, records) || records\n },\n\n /**\n * Skip a number of results.\n *\n * Shortcut for `collection.query().skip(numberToSkip).run()`\n *\n * @example\n * const posts = collection.skip(10)\n *\n * @name Collection#skip\n * @method\n * @param {number} num - The number of records to skip.\n * @return {Array} The result.\n */\n skip (num) {\n return this.query().skip(num).run()\n },\n\n /**\n * Return the plain JSON representation of all items in this collection.\n * Assumes records in this collection have a toJSON method.\n *\n * @name Collection#toJSON\n * @method\n * @param {Object} [opts] - Configuration options.\n * @param {string[]} [opts.with] - Array of relation names or relation fields\n * to include in the representation.\n * @return {Array} The records.\n */\n toJSON (opts) {\n return this.mapCall('toJSON', opts)\n },\n\n /**\n * Update a record's position in a single index of this collection. See\n * {@link Collection#updateIndexes} to update a record's position in all\n * indexes at once.\n *\n * @name Collection#updateIndex\n * @method\n * @param {Object} record - The record to update.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] The index in which to update the record's\n * position. If you don't specify an index then the record will be updated\n * in the main index.\n */\n updateIndex (record, opts) {\n opts || (opts = {})\n this.getIndex(opts.index).updateRecord(record)\n },\n\n /**\n * TODO\n *\n * @name Collection#updateIndexes\n * @method\n * @param {Object} record - TODO\n * @param {Object} [opts] - Configuration options.\n */\n updateIndexes (record) {\n const self = this\n self.index.updateRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.updateRecord(record)\n })\n }\n})\n","import utils from './utils'\n\nexport const belongsToType = 'belongsTo'\nexport const hasManyType = 'hasMany'\nexport const hasOneType = 'hasOne'\n\nfunction Relation (related, opts) {\n const self = this\n\n opts || (opts = {})\n\n const localField = opts.localField\n if (!localField) {\n throw new Error('localField is required!')\n }\n\n const foreignKey = opts.foreignKey = opts.foreignKey || opts.localKey\n if (!foreignKey && (opts.type === belongsToType || opts.type === hasOneType)) {\n throw new Error('foreignKey is required!')\n }\n const localKeys = opts.localKeys\n const foreignKeys = opts.foreignKeys\n if (!foreignKey && !localKeys && !foreignKeys && opts.type === hasManyType) {\n throw new Error('one of (foreignKey, localKeys, foreignKeys) is required!')\n }\n\n if (utils.isString(related)) {\n opts.relation = related\n if (!utils.isFunction(opts.getRelation)) {\n throw new Error('you must provide a reference to the related mapper!')\n }\n } else if (related) {\n opts.relation = related.name\n Object.defineProperty(self, 'relatedMapper', {\n value: related\n })\n } else {\n throw new Error('no relation provided!')\n }\n\n Object.defineProperty(self, 'inverse', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n}\n\nutils.addHiddenPropsToTarget(Relation.prototype, {\n getRelation () {\n return this.relatedMapper\n },\n getLocalKeys (record) {\n\n },\n getForeignKey (record) {\n if (this.type === belongsToType) {\n return utils.get(record, this.foreignKey)\n }\n return utils.get(record, this.mapper.idAttribute)\n },\n setForeignKey (record, relatedRecord) {\n const self = this\n if (!record || !relatedRecord) {\n return\n }\n if (self.type === belongsToType) {\n utils.set(record, self.foreignKey, utils.get(relatedRecord, self.getRelation().idAttribute))\n } else {\n const idAttribute = self.mapper.idAttribute\n if (utils.isArray(relatedRecord)) {\n relatedRecord.forEach(function (relatedRecordItem) {\n utils.set(relatedRecordItem, self.foreignKey, utils.get(record, idAttribute))\n })\n } else {\n utils.set(relatedRecord, self.foreignKey, utils.get(record, idAttribute))\n }\n }\n },\n getLocalField (record) {\n return utils.get(record, this.localField)\n },\n setLocalField (record, data) {\n return utils.set(record, this.localField, data)\n },\n getInverse (mapper) {\n const self = this\n if (self.inverse) {\n return self.inverse\n }\n self.getRelation().relationList.forEach(function (def) {\n if (def.getRelation() === mapper) {\n if (def.foreignKey && def.foreignKey !== self.foreignKey) {\n return\n }\n self.inverse = def\n return false\n }\n })\n return self.inverse\n }\n})\n\nconst relatedTo = function (mapper, related, opts) {\n opts.name = mapper.name\n const relation = new Relation(related, opts)\n Object.defineProperty(relation, 'mapper', {\n value: mapper\n })\n\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n mapper.relationFields || Object.defineProperty(mapper, 'relationFields', { value: [] })\n mapper.relationList.push(relation)\n mapper.relationFields.push(relation.localField)\n}\n\n/**\n * TODO\n *\n * @name module:js-data.belongsTo\n * @method\n * @param {Mapper} related The relation the target belongs to.\n * @param {Object} opts Configuration options.\n * @param {string} opts.foreignKey The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const belongsTo = function (related, opts) {\n opts || (opts = {})\n opts.type = belongsToType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasMany\n * @method\n * @param {Mapper} related The relation of which the target has many.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasMany = function (related, opts) {\n opts || (opts = {})\n opts.type = hasManyType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasOne\n * @method\n * @param {Mapper} related The relation of which the target has one.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasOne = function (related, opts) {\n opts || (opts = {})\n opts.type = hasOneType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n","import utils from './utils'\nimport Component from './Component'\n\nconst superMethod = function (mapper, name) {\n const store = mapper.datastore\n if (store && store[name]) {\n return function (...args) {\n return store[name](mapper.name, ...args)\n }\n }\n return mapper[name].bind(mapper)\n}\n\n/**\n * js-data's Record class.\n *\n * ```javascript\n * import {Record} from 'js-data'\n * ```\n *\n * @class Record\n * @extends Component\n * @param {Object} [props] The initial properties of the new Record instance.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation on the\n * initial properties.\n */\nconst Record = Component.extend({\n constructor: function Record (props, opts) {\n const self = this\n utils.classCallCheck(self, Record)\n\n props || (props = {})\n opts || (opts = {})\n const _props = {}\n Object.defineProperties(self, {\n _get: { value (key) { return utils.get(_props, key) } },\n _set: { value (key, value) { return utils.set(_props, key, value) } },\n _unset: { value (key) { return utils.unset(_props, key) } }\n })\n const _set = self._set\n // TODO: Optimize these strings\n _set('creating', true)\n if (opts.noValidate) {\n _set('noValidate', true)\n }\n utils.fillIn(self, props)\n _set('creating', false)\n _set('noValidate', false)\n _set('previous', utils.copy(props))\n },\n\n /**\n * TODO\n *\n * @name Record#_mapper\n * @method\n * @ignore\n */\n _mapper () {\n if (!this.constructor.mapper) {\n throw new Error('This recordClass has no Mapper!')\n }\n return this.constructor.mapper\n },\n\n /**\n * TODO\n *\n * @name Record#afterLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n afterLoadRelations () {},\n\n /**\n * TODO\n *\n * @name Record#beforeLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n beforeLoadRelations () {},\n\n /**\n * Return changes to this record since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#changes\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n changes (opts) {\n const self = this\n opts || (opts = {})\n return utils.diffObjects(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#commit\n * @method\n */\n commit () {\n const self = this\n self._set('changed') // unset\n self._set('previous', utils.copy(self))\n return self\n },\n\n /**\n * Call {@link Mapper#destroy} using this record's primary key.\n *\n * @name Record#destroy\n * @method\n * @param {Object} [opts] Configuration options passed to {@link Mapper#destroy}.\n * @return {Promise} The result of calling {@link Mapper#destroy}.\n */\n destroy (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n return superMethod(mapper, 'destroy')(utils.get(self, mapper.idAttribute), opts)\n },\n\n /**\n * Return the value at the given path for this instance.\n *\n * @name Record#get\n * @method\n * @param {string} key - Path of value to retrieve.\n * @return {*} Value at path.\n */\n 'get' (key) {\n return utils.get(this, key)\n },\n\n /**\n * Return whether this record has changed since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#hasChanges\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n hasChanges (opts) {\n const self = this\n const quickHasChanges = !!(self._get('changed') || []).length\n return quickHasChanges || utils.areDifferent(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#hashCode\n * @method\n */\n hashCode () {\n const self = this\n return utils.get(self, self._mapper().idAttribute)\n },\n\n isValid (opts) {\n const self = this\n return !self._mapper().validate(self, opts)\n },\n\n /**\n * TODO\n *\n * @name Record#loadRelations\n * @method\n * @param {string[]} [relations] TODO\n * @param {Object} [opts] TODO\n */\n loadRelations (relations, opts) {\n let op\n const self = this\n const mapper = self._mapper()\n\n // Default values for arguments\n relations || (relations = [])\n if (utils.isString(relations)) {\n relations = [relations]\n }\n opts || (opts = {})\n opts.with = relations\n\n // Fill in \"opts\" with the Model's configuration\n utils._(opts, mapper)\n opts.adapter = mapper.getAdapterName(opts)\n\n // beforeLoadRelations lifecycle hook\n op = opts.op = 'beforeLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n if (utils.isString(relations)) {\n relations = [relations]\n }\n // Now delegate to the adapter\n op = opts.op = 'loadRelations'\n mapper.dbg(op, self, relations, opts)\n let tasks = []\n let task\n utils.forEachRelation(mapper, opts, function (def, optsCopy) {\n const relatedMapper = def.getRelation()\n optsCopy.raw = false\n if (utils.isFunction(def.load)) {\n task = def.load(mapper, def, self, opts)\n } else if (def.type === 'hasMany') {\n if (def.foreignKey) {\n task = superMethod(relatedMapper, 'findAll')({\n [def.foreignKey]: utils.get(self, mapper.idAttribute)\n }, optsCopy)\n } else if (def.localKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [relatedMapper.idAttribute]: {\n 'in': utils.get(self, def.localKeys)\n }\n }\n })\n } else if (def.foreignKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [def.foreignKeys]: {\n 'contains': utils.get(self, mapper.idAttribute)\n }\n }\n }, opts)\n }\n } else if (def.type === 'belongsTo' || def.type === 'hasOne') {\n const key = utils.get(self, def.foreignKey)\n if (utils.isSorN(key)) {\n task = superMethod(relatedMapper, 'find')(key, optsCopy)\n }\n }\n if (task) {\n task = task.then(function (relatedData) {\n def.setLocalField(self, relatedData)\n })\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterLoadRelations lifecycle hook\n op = opts.op = 'afterLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n return self\n })\n })\n },\n\n /**\n * TODO\n *\n * @name Record#previous\n * @method\n * @param {string} [key] TODO\n */\n previous (key) {\n const self = this\n if (key) {\n return self._get(`previous.${key}`)\n }\n return self._get('previous')\n },\n\n /**\n * TODO\n *\n * @name Record#revert\n * @method\n * @param {Object} [opts] Configuration options.\n */\n revert (opts) {\n const self = this\n const previous = self._get('previous')\n opts || (opts = {})\n opts.preserve || (opts.preserve = [])\n utils.forOwn(self, (value, key) => {\n if (key !== self._mapper().idAttribute && !previous.hasOwnProperty(key) && self.hasOwnProperty(key) && opts.preserve.indexOf(key) === -1) {\n delete self[key]\n }\n })\n utils.forOwn(previous, (value, key) => {\n if (opts.preserve.indexOf(key) === -1) {\n self[key] = value\n }\n })\n self.commit()\n return self\n },\n\n /**\n * Delegates to {@link Mapper#create} or {@link Mapper#update}.\n *\n * @name Record#save\n * @method\n * @param {Object} [opts] Configuration options. See {@link Mapper#create}.\n * @param [opts] Configuration options.\n * @param {boolean} [opts.changesOnly] Equality function. Default uses `===`.\n * @param {Function} [opts.equalsFn] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @param {Array} [opts.ignore] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @return {Promise} The result of calling {@link Mapper#create} or\n * {@link Mapper#update}.\n */\n save (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n const id = utils.get(self, mapper.idAttribute)\n let props = self\n if (utils.isUndefined(id)) {\n return superMethod(mapper, 'create')(props, opts)\n }\n if (opts.changesOnly) {\n const changes = self.changes(opts)\n props = {}\n utils.fillIn(props, changes.added)\n utils.fillIn(props, changes.changed)\n }\n return superMethod(mapper, 'update')(id, props, opts)\n },\n\n /**\n * Set the value for a given key, or the values for the given keys if \"key\" is\n * an object.\n *\n * @name Record#set\n * @method\n * @param {(string|Object)} key - Key to set or hash of key-value pairs to set.\n * @param {*} [value] - Value to set for the given key.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n 'set' (key, value, opts) {\n const self = this\n if (utils.isObject(key)) {\n opts = value\n }\n opts || (opts = {})\n if (opts.silent) {\n self._set('silent', true)\n }\n utils.set(self, key, value)\n if (!self._get('eventId')) {\n self._set('silent') // unset\n }\n },\n\n // TODO: move logic for single-item async operations onto the instance.\n\n /**\n * Return a plain object representation of this record. If the class from\n * which this record was created has a mapper, then {@link Mapper#toJSON} will\n * be called instead.\n *\n * @name Record#toJSON\n * @method\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation. Only available as an option if the class\n * from which this record was created has a mapper.\n * @return {Object} Plain object representation of this record.\n */\n toJSON (opts) {\n const mapper = this.constructor.mapper\n if (mapper) {\n return mapper.toJSON(this, opts)\n } else {\n const json = {}\n utils.forOwn(this, function (prop, key) {\n json[key] = utils.copy(prop)\n })\n return json\n }\n },\n\n /**\n * Unset the value for a given key.\n *\n * @name Record#unset\n * @method\n * @param {string} key - Key to unset.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n unset (key, opts) {\n this.set(key, undefined, opts)\n },\n\n validate (opts) {\n return this._mapper().validate(this, opts)\n }\n})\n\n/**\n * Allow records to emit events.\n *\n * An record's registered listeners are stored in the record's private data.\n */\nutils.eventify(\n Record.prototype,\n function () {\n return this._get('events')\n },\n function (value) {\n this._set('events', value)\n }\n)\n\nexport default Record\n","import utils from './utils'\nimport Component from './Component'\n\n/**\n * TODO\n *\n * @name Schema.types\n * @type {Object}\n */\nconst types = {\n array: utils.isArray,\n boolean: utils.isBoolean,\n integer: utils.isInteger,\n 'null': utils.isNull,\n number: utils.isNumber,\n object: utils.isObject,\n string: utils.isString\n}\n\n/**\n * @ignore\n */\nconst segmentToString = function (segment, prev) {\n let str = ''\n if (segment) {\n if (utils.isNumber(segment)) {\n str += `[${segment}]`\n } else if (prev) {\n str += `.${segment}`\n } else {\n str += `${segment}`\n }\n }\n return str\n}\n\n/**\n * @ignore\n */\nconst makePath = function (opts) {\n opts || (opts = {})\n let path = ''\n const segments = opts.path || []\n segments.forEach(function (segment) {\n path += segmentToString(segment, path)\n })\n path += segmentToString(opts.prop, path)\n return path\n}\n\n/**\n * @ignore\n */\nconst makeError = function (actual, expected, opts) {\n return {\n expected,\n actual: '' + actual,\n path: makePath(opts)\n }\n}\n\n/**\n * @ignore\n */\nconst addError = function (actual, expected, opts, errors) {\n errors.push(makeError(actual, expected, opts))\n}\n\n/**\n * @ignore\n */\nconst maxLengthCommon = function (keyword, value, schema, opts) {\n const max = schema[keyword]\n if (value.length > max) {\n return makeError(value.length, `length no more than ${max}`, opts)\n }\n}\n\n/**\n * @ignore\n */\nconst minLengthCommon = function (keyword, value, schema, opts) {\n const min = schema[keyword]\n if (value.length < min) {\n return makeError(value.length, `length no less than ${min}`, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name Schema.validationKeywords\n * @type {Object}\n */\nconst validationKeywords = {\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor82\n *\n * @name Schema.validationKeywords.allOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n allOf (value, schema, opts) {\n let allErrors = []\n schema.allOf.forEach(function (_schema) {\n allErrors = allErrors.concat(validate(value, _schema, opts) || [])\n })\n return allErrors.length ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor85\n *\n * @name Schema.validationKeywords.anyOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n anyOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.anyOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor70\n *\n * @name Schema.validationKeywords.dependencies\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n dependencies (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor76\n *\n * @name Schema.validationKeywords.enum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n enum (value, schema, opts) {\n const possibleValues = schema['enum']\n if (possibleValues.indexOf(value) === -1) {\n return makeError(value, `one of (${possibleValues.join(', ')})`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor37\n *\n * @name Schema.validationKeywords.items\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n items (value, schema, opts) {\n opts || (opts = {})\n // TODO: additionalItems\n let items = schema.items\n let errors = []\n const checkingTuple = utils.isArray(items)\n const length = value.length\n for (var prop = 0; prop < length; prop++) {\n if (checkingTuple) {\n // Validating a tuple, instead of just checking each item against the\n // same schema\n items = schema.items[prop]\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], items, opts) || [])\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor17\n *\n * @name Schema.validationKeywords.maximum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maximum (value, schema, opts) {\n // Must be a number\n const maximum = schema.maximum\n // Must be a boolean\n // Depends on maximum\n // default: false\n const exclusiveMaximum = schema.exclusiveMaximum\n if (typeof value === typeof maximum && (exclusiveMaximum ? maximum < value : maximum <= value)) {\n // TODO: Account for value of exclusiveMaximum in messaging\n return makeError(value, `no more than ${maximum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.maxItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxItems (value, schema, opts) {\n return maxLengthCommon('maxItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor26\n *\n * @name Schema.validationKeywords.maxLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxLength (value, schema, opts) {\n return maxLengthCommon('maxLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor54\n *\n * @name Schema.validationKeywords.maxProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxProperties (value, schema, opts) {\n const maxProperties = schema.maxProperties\n const length = Object.keys(value).length\n if (length > maxProperties) {\n return makeError(length, `no more than ${maxProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor21\n *\n * @name Schema.validationKeywords.minimum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minimum (value, schema, opts) {\n // Must be a number\n const minimum = schema.minimum\n // Must be a boolean\n // Depends on minimum\n // default: false\n const exclusiveMinimum = schema.exclusiveMinimum\n if (typeof value === typeof minimum && (exclusiveMinimum ? minimum > value : minimum >= value)) {\n // TODO: Account for value of exclusiveMinimum in messaging\n return makeError(value, `no less than ${minimum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.minItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minItems (value, schema, opts) {\n return minLengthCommon('minItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor29\n *\n * @name Schema.validationKeywords.minLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minLength (value, schema, opts) {\n return minLengthCommon('minLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor57\n *\n * @name Schema.validationKeywords.minProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minProperties (value, schema, opts) {\n const minProperties = schema.minProperties\n const length = Object.keys(value).length\n if (length < minProperties) {\n return makeError(length, `no more than ${minProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor14\n *\n * @name Schema.validationKeywords.multipleOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n multipleOf (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor91\n *\n * @name Schema.validationKeywords.not\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n not (value, schema, opts) {\n if (!validate(value, schema.not, opts)) {\n // TODO: better messaging\n return makeError('succeeded', 'should have failed', opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor88\n *\n * @name Schema.validationKeywords.oneOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n oneOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.oneOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else if (validated) {\n allErrors = [makeError('valid against more than one', 'valid against only one', opts)]\n validated = false\n return false\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor33\n *\n * @name Schema.validationKeywords.pattern\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n pattern (value, schema, opts) {\n const pattern = schema.pattern\n if (utils.isString(value) && !value.match(pattern)) {\n return makeError(value, pattern, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor64\n *\n * @name Schema.validationKeywords.properties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n properties (value, schema, opts) {\n opts || (opts = {})\n // Can be a boolean or an object\n // Technically the default is an \"empty schema\", but here \"true\" is\n // functionally the same\n const additionalProperties = utils.isUndefined(schema.additionalProperties) ? true : schema.additionalProperties\n // \"s\": The property set of the instance to validate.\n const toValidate = {}\n // \"p\": The property set from \"properties\".\n // Default is an object\n const properties = schema.properties || {}\n // \"pp\": The property set from \"patternProperties\".\n // Default is an object\n const patternProperties = schema.patternProperties || {}\n let errors = []\n\n // Collect set \"s\"\n utils.forOwn(value, function (_value, prop) {\n toValidate[prop] = undefined\n })\n // Remove from \"s\" all elements of \"p\", if any.\n utils.forOwn(properties || {}, function (_schema, prop) {\n if (utils.isUndefined(value[prop]) && !utils.isUndefined(_schema['default'])) {\n value[prop] = utils.copy(_schema['default'])\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n })\n // For each regex in \"pp\", remove all elements of \"s\" which this regex\n // matches.\n utils.forOwn(patternProperties, function (_schema, pattern) {\n utils.forOwn(toValidate, function (undef, prop) {\n if (prop.match(pattern)) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n }\n })\n })\n const keys = Object.keys(toValidate)\n // If \"s\" is not empty, validation fails\n if (additionalProperties === false) {\n if (keys.length) {\n addError(`extra fields: ${keys.join(', ')}`, 'no extra fields', opts, errors)\n }\n } else if (utils.isObject(additionalProperties)) {\n // Otherwise, validate according to provided schema\n keys.forEach(function (prop) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], additionalProperties, opts) || [])\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor61\n *\n * @name Schema.validationKeywords.required\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n required (value, schema, opts) {\n const required = schema.required\n let errors = []\n if (!opts.existingOnly) {\n required.forEach(function (prop) {\n if (utils.isUndefined(utils.get(value, prop))) {\n const prevProp = opts.prop\n opts.prop = prop\n addError(undefined, 'a value', opts, errors)\n opts.prop = prevProp\n }\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor79\n *\n * @name Schema.validationKeywords.type\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n type (value, schema, opts) {\n let type = schema.type\n let validType\n // Can be one of several types\n if (utils.isString(type)) {\n type = [type]\n }\n // Try to match the value against an expected type\n type.forEach(function (_type) {\n // TODO: throw an error if type is not defined\n if (types[_type](value, schema, opts)) {\n // Matched a type\n validType = _type\n return false\n }\n })\n // Value did not match any expected type\n if (!validType) {\n return makeError(value ? typeof value : '' + value, `one of (${type.join(', ')})`, opts)\n }\n // Run keyword validators for matched type\n // http://json-schema.org/latest/json-schema-validation.html#anchor12\n const validator = typeGroupValidators[validType]\n if (validator) {\n return validator(value, schema, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor49\n *\n * @name Schema.validationKeywords.uniqueItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n uniqueItems (value, schema, opts) {\n if (value && value.length && schema.uniqueItems) {\n const length = value.length\n let item, i, j\n // Check n - 1 items\n for (i = length - 1; i > 0; i--) {\n item = value[i]\n // Only compare against unchecked items\n for (j = i - 1; j >= 0; j--) {\n // Found a duplicate\n if (item === value[j]) {\n return makeError(item, 'no duplicates', opts)\n }\n }\n }\n }\n }\n}\n\n/**\n * @ignore\n */\nconst validateKeyword = function (op, value, schema, opts) {\n return !utils.isUndefined(schema[op]) && validationKeywords[op](value, schema, opts)\n}\n\n/**\n * @ignore\n */\nconst runOps = function (ops, value, schema, opts) {\n let errors = []\n ops.forEach(function (op) {\n errors = errors.concat(validateKeyword(op, value, schema, opts) || [])\n })\n return errors.length ? errors : undefined\n}\n\nconst ANY_OPS = ['enum', 'type', 'allOf', 'anyOf', 'oneOf', 'not']\nconst ARRAY_OPS = ['items', 'maxItems', 'minItems', 'uniqueItems']\nconst NUMERIC_OPS = ['multipleOf', 'maximum', 'minimum']\nconst OBJECT_OPS = ['maxProperties', 'minProperties', 'required', 'properties', 'dependencies']\nconst STRING_OPS = ['maxLength', 'minLength', 'pattern']\n\n/**\n * http://json-schema.org/latest/json-schema-validation.html#anchor75\n * @ignore\n */\nconst validateAny = function (value, schema, opts) {\n return runOps(ANY_OPS, value, schema, opts)\n}\n\n/**\n * TODO\n *\n * @name Schema.validate\n * @method\n * @param {*} value TODO\n * @param {Object} [schema] TODO\n * @param {Object} [opts] Configuration options.\n */\nconst validate = function (value, schema, opts) {\n let errors = []\n opts || (opts = {})\n let shouldPop\n let prevProp = opts.prop\n if (utils.isUndefined(schema)) {\n return\n }\n if (!utils.isObject(schema)) {\n throw new Error(`Invalid schema at path: \"${opts.path}\"`)\n }\n if (utils.isUndefined(opts.path)) {\n opts.path = []\n }\n // Track our location as we recurse\n if (!utils.isUndefined(opts.prop)) {\n shouldPop = true\n opts.path.push(opts.prop)\n opts.prop = undefined\n }\n // Validate against parent schema\n if (schema['extends']) {\n // opts.path = path\n // opts.prop = prop\n if (utils.isFunction(schema['extends'].validate)) {\n errors = errors.concat(schema['extends'].validate(value, opts) || [])\n } else {\n errors = errors.concat(validate(value, schema['extends'], opts) || [])\n }\n }\n if (utils.isUndefined(value)) {\n // Check if property is required\n if (schema.required === true) {\n addError(value, 'a value', opts, errors)\n }\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n }\n errors = errors.concat(validateAny(value, schema, opts) || [])\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n}\n\n// These strings are cached for optimal performance of the change detection\n// boolean - Whether a Record is changing in the current execution frame\nconst changingPath = 'changing'\n// string[] - Properties that have changed in the current execution frame\nconst changedPath = 'changed'\n// boolean - Whether a Record is currently being instantiated\nconst creatingPath = 'creating'\n// number - The setTimeout change event id of a Record, if any\nconst eventIdPath = 'eventId'\n// boolean - Whether to skip validation for a Record's currently changing property\nconst noValidatePath = 'noValidate'\n// boolean - Whether to skip change notification for a Record's currently\n// changing property\nconst silentPath = 'silent'\nconst validationFailureMsg = 'validation failed'\n\n/**\n * Assemble a property descriptor which will be added to the prototype of\n * {@link Mapper#recordClass}. This method is called when\n * {@link Mapper#applySchema} is set to `true`.\n *\n * TODO: Make this more configurable, i.e. not so tied to the Record class.\n *\n * @ignore\n */\nconst makeDescriptor = function (prop, schema, opts) {\n const descriptor = {\n // These properties are enumerable by default, but regardless of their\n // enumerability, they won't be \"own\" properties of individual records\n enumerable: utils.isUndefined(schema.enumerable) ? true : !!schema.enumerable\n }\n // Cache a few strings for optimal performance\n const keyPath = `props.${prop}`\n const previousPath = `previous.${prop}`\n const getter = opts.getter\n const setter = opts.setter\n const unsetter = opts.unsetter\n\n descriptor.get = function () { return this._get(keyPath) }\n descriptor.set = function (value) {\n const self = this\n // These are accessed a lot\n const _get = self[getter]\n const _set = self[setter]\n const _unset = self[unsetter]\n\n // Optionally check that the new value passes validation\n if (!_get(noValidatePath)) {\n const errors = schema.validate(value)\n if (errors) {\n // Immediately throw an error, preventing the record from getting into\n // an invalid state\n const error = new Error(validationFailureMsg)\n error.errors = errors\n throw error\n }\n }\n // TODO: Make it so tracking can be turned on for all properties instead of\n // only per-property\n if (schema.track && !_get(creatingPath)) {\n const previous = _get(previousPath)\n const current = _get(keyPath)\n let changing = _get(changingPath)\n let changed = _get(changedPath)\n\n if (!changing) {\n // Track properties that are changing in the current event loop\n changed = []\n }\n\n // Add changing properties to this array once at most\n const index = changed.indexOf(prop)\n if (current !== value && index === -1) {\n changed.push(prop)\n }\n if (previous === value) {\n if (index >= 0) {\n changed.splice(index, 1)\n }\n }\n // No changes in current event loop\n if (!changed.length) {\n changing = false\n _unset(changingPath)\n _unset(changedPath)\n // Cancel pending change event\n if (_get(eventIdPath)) {\n clearTimeout(_get(eventIdPath))\n _unset(eventIdPath)\n }\n }\n // Changes detected in current event loop\n if (!changing && changed.length) {\n _set(changedPath, changed)\n _set(changingPath, true)\n // Saving the timeout id allows us to batch all changes in the same\n // event loop into a single \"change\"\n // TODO: Optimize\n _set(eventIdPath, setTimeout(() => {\n // Previous event loop where changes were gathered has ended, so\n // notify any listeners of those changes and prepare for any new\n // changes\n _unset(changedPath)\n _unset(eventIdPath)\n _unset(changingPath)\n // TODO: Optimize\n if (!_get(silentPath)) {\n let i\n for (i = 0; i < changed.length; i++) {\n self.emit('change:' + changed[i], self, utils.get(self, changed[i]))\n }\n self.emit('change', self, self.changes())\n }\n _unset(silentPath)\n }, 0))\n }\n }\n _set(keyPath, value)\n return value\n }\n\n return descriptor\n}\n\n/**\n * TODO\n *\n * @name Schema.typeGroupValidators\n * @type {Object}\n */\nconst typeGroupValidators = {\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.array\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n array: function (value, schema, opts) {\n return runOps(ARRAY_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.integer\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n integer: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.number\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n number: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor13.\n *\n * @name Schema.typeGroupValidators.numeric\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n numeric: function (value, schema, opts) {\n return runOps(NUMERIC_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor53.\n *\n * @name Schema.typeGroupValidators.object\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n object: function (value, schema, opts) {\n return runOps(OBJECT_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor25.\n *\n * @name Schema.typeGroupValidators.string\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n string: function (value, schema, opts) {\n return runOps(STRING_OPS, value, schema, opts)\n }\n}\n\n/**\n * js-data's Schema class.\n *\n * ```javascript\n * import {Schema} from 'js-data'\n * ```\n *\n * @class Schema\n * @extends Component\n * @param {Object} definition Schema definition according to json-schema.org\n */\nexport default Component.extend({\n constructor: function Schema (definition) {\n // const self = this\n definition || (definition = {})\n // TODO: schema validation\n utils.fillIn(this, definition)\n\n // TODO: rework this to make sure all possible keywords are converted\n if (definition.properties) {\n utils.forOwn(definition.properties, function (_definition, prop) {\n if (!(_definition instanceof Schema)) {\n definition.properties[prop] = new Schema(_definition)\n }\n })\n }\n },\n\n /**\n * This adds ES5 getters/setters to the target based on the \"properties\" in\n * this Schema, which makes possible change tracking and validation on\n * property assignment.\n *\n * @name Schema#validate\n * @method\n * @param {Object} target The prototype to which to apply this schema.\n */\n apply (target, opts) {\n opts || (opts = {})\n opts.getter = opts.getter || '_get'\n opts.setter = opts.setter || '_set'\n opts.unsetter = opts.unsetter || '_unset'\n const properties = this.properties || {}\n utils.forOwn(properties, function (schema, prop) {\n Object.defineProperty(\n target,\n prop,\n makeDescriptor(prop, schema, opts)\n )\n })\n },\n\n /**\n * Validate the provided value against this schema.\n *\n * @name Schema#validate\n * @method\n * @param {*} value Value to validate.\n * @param {Object} [opts] Configuration options.\n * @return {(array|undefined)} Array of errors or `undefined` if valid.\n */\n validate (value, opts) {\n return validate(value, this, opts)\n }\n}, {\n typeGroupValidators,\n types,\n validate,\n validationKeywords\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Record from './Record'\nimport Schema from './Schema'\nimport {\n belongsTo,\n belongsToType,\n hasMany,\n hasManyType,\n hasOne,\n hasOneType\n} from './decorators'\n\nconst makeNotify = function (num) {\n return function (...args) {\n const self = this\n const opts = args[args.length - num]\n self.dbg(opts.op, ...args)\n if (opts.notify || (opts.notify === undefined && self.notify)) {\n setTimeout(() => {\n self.emit(opts.op, ...args)\n })\n }\n }\n}\n\n// These are the default implementations of all of the lifecycle hooks\nconst notify = makeNotify(1)\nconst notify2 = makeNotify(2)\n\n// This object provides meta information used by Mapper#crud to actually\n// execute each lifecycle method\nconst LIFECYCLE_METHODS = {\n count: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroy: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroyAll: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n find: {\n defaults: [undefined, {}],\n types: []\n },\n findAll: {\n defaults: [{}, {}],\n types: []\n },\n sum: {\n defaults: [undefined, {}, {}],\n skip: true,\n types: []\n },\n update: {\n adapterArgs (mapper, id, props, opts) {\n return [id, mapper.toJSON(props, opts), opts]\n },\n beforeAssign: 1,\n defaults: [undefined, {}, {}],\n types: []\n },\n updateAll: {\n adapterArgs (mapper, props, query, opts) {\n return [mapper.toJSON(props, opts), query, opts]\n },\n beforeAssign: 0,\n defaults: [{}, {}, {}],\n types: []\n },\n updateMany: {\n adapterArgs (mapper, records, opts) {\n return [records.map(function (record) {\n return mapper.toJSON(record, opts)\n }), opts]\n },\n beforeAssign: 0,\n defaults: [[], {}],\n types: []\n }\n}\n\nconst MAPPER_DEFAULTS = {\n /**\n * Hash of registered adapters. Don't modify directly. Use {@link Mapper#registerAdapter}.\n *\n * @name Mapper#_adapters\n */\n _adapters: {},\n\n /**\n * Whether to augment {@link Mapper#recordClass} with getter/setter property\n * accessors according to the properties defined in {@link Mapper#schema}.\n * This makes possible validation and change tracking on individual properties\n * when using the dot (e.g. `user.name = \"Bob\"`) operator to modify a\n * property.\n *\n * @name Mapper#applySchema\n * @type {boolean}\n * @default true\n */\n applySchema: true,\n\n /**\n * Whether to enable debug-level logs.\n *\n * @name Mapper#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * The name of the registered adapter that this Mapper should used by default.\n *\n * @name Mapper#defaultAdapter\n * @type {string}\n * @default \"http\"\n */\n defaultAdapter: 'http',\n\n /**\n * The field used as the unique identifier on records handled by this Mapper.\n *\n * @name Mapper#idAttribute\n * @type {string}\n * @default id\n */\n idAttribute: 'id',\n\n /**\n * Whether this Mapper should emit operational events.\n *\n * Defaults to `true` in the browser and `false` in Node.js\n *\n * @name Mapper#notify\n * @type {boolean}\n */\n notify: utils.isBrowser,\n\n /**\n * Whether {@link Mapper#create}, {@link Mapper#createMany}, {@link Mapper#save},\n * {@link Mapper#update}, {@link Mapper#updateAll}, {@link Mapper#updateMany},\n * {@link Mapper#find}, {@link Mapper#findAll}, {@link Mapper#destroy}, and\n * {@link Mapper#destroyAll} should return a raw result object that contains\n * both the instance data returned by the adapter _and_ metadata about the\n * operation.\n *\n * The default is to NOT return the result object, and instead return just the\n * instance data.\n *\n * @name Mapper#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * ```javascript\n * import {Mapper} from 'js-data'\n * ```\n *\n * The core of JSData's [ORM/ODM][orm] implementation. Given a minimum amout of\n * meta information about a resource, a Mapper can perform generic CRUD\n * operations against that resource. Apart from its configuration, a Mapper is\n * stateless. The particulars of various persistence layers has been abstracted\n * into adapters, which a Mapper uses to perform its operations.\n *\n * The term \"Mapper\" comes from the [Data Mapper Pattern][pattern] described in\n * Martin Fowler's [Patterns of Enterprise Application Architecture][book]. A\n * Data Mapper moves data between [in-memory object instances][record] and a\n * relational or document-based database. JSData's Mapper can work with any\n * persistence layer you can write an adapter for.\n *\n * _(\"Model\" is a heavily overloaded term and is avoided in this documentation\n * to prevent confusion.)_\n *\n * [orm]: https://en.wikipedia.org/wiki/Object-relational_mapping\n * [pattern]: https://en.wikipedia.org/wiki/Data_mapper_pattern\n * [book]: http://martinfowler.com/books/eaa.html\n * [record]: Record.html\n *\n * @class Mapper\n * @extends Component\n * @param {Object} opts Configuration options.\n * @param {boolean} [opts.applySchema=true] Whether to apply this Mapper's\n * {@link Schema} to the prototype of this Mapper's Record class. The enables\n * features like active change detection, validation during use of the\n * assignment operator, etc.\n * @param {boolean} [opts.debug=false] Wether to log debugging information\n * during operation.\n * @param {string} [opts.defaultAdapter=http] The name of the adapter to use by\n * default.\n * @param {string} [opts.idAttribute=id] The field that uniquely identifies\n * Records that this Mapper will be dealing with. Typically called a primary\n * key.\n * @param {string} opts.name The name for this Mapper. This is the minimum\n * amount of meta information required for a Mapper to be able to execute CRUD\n * operations for a \"Resource\".\n * @param {boolean} [opts.notify] Whether to emit lifecycle events.\n * @param {boolean} [opts.raw=false] Whether lifecycle methods should return a\n * more detailed reponse object instead of just a Record instance or Record\n * instances.\n */\nexport default Component.extend({\n constructor: function Mapper (opts) {\n const self = this\n utils.classCallCheck(self, Mapper)\n Mapper.__super__.call(self)\n opts || (opts = {})\n\n // Prepare certain properties to be non-enumerable\n Object.defineProperties(self, {\n _adapters: {\n value: undefined,\n writable: true\n },\n\n /**\n * Set the `false` to force the Mapper to work with POJO objects only.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * const UserMapper = new Mapper({ recordClass: false })\n * UserMapper.recordClass // false\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * ```\n *\n * Set to a custom class to have records wrapped in your custom class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User {\n * constructor (props = {}) {\n * for (var key in props) {\n * if (props.hasOwnProperty(key)) {\n * this[key] = props[key]\n * }\n * }\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * user instanceof User // true\n * ```\n *\n * Extend the {@link Record} class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User extends Record {\n * constructor () {\n * super(props)\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // true\n * user instanceof User // true\n * ```\n *\n * @name Mapper#recordClass\n * @default {@link Record}\n */\n recordClass: {\n value: undefined,\n writable: true\n },\n\n lifecycleMethods: {\n value: LIFECYCLE_METHODS\n },\n\n schema: {\n value: undefined,\n writable: true\n }\n })\n\n // Apply user-provided configuration\n utils.fillIn(self, opts)\n // Fill in any missing options with the defaults\n utils.fillIn(self, utils.copy(MAPPER_DEFAULTS))\n\n /**\n * Minimum amount of meta information required for a Mapper to be able to\n * execute CRUD operations for a \"Resource\".\n *\n * @name Mapper#name\n * @type {string}\n */\n if (!self.name) {\n throw new Error('name is required!')\n }\n\n // Setup schema, with an empty default schema if necessary\n if (!(self.schema instanceof Schema)) {\n self.schema = new Schema(self.schema || {})\n }\n\n // Create a subclass of Record that's tied to this Mapper\n if (utils.isUndefined(self.recordClass)) {\n const superClass = Record\n self.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n\n if (self.recordClass) {\n self.recordClass.mapper = self\n\n // We can only apply the schema to the prototype of self.recordClass if the\n // class extends Record\n if (utils.getSuper(self.recordClass, true) === Record && self.schema && self.schema.apply && self.applySchema) {\n self.schema.apply(self.recordClass.prototype)\n }\n }\n },\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n * @param {*} result The result, if any.\n */\n afterCount: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n * @param {*} result The result, if any.\n */\n afterCreate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n * @param {*} result The result, if any.\n */\n afterCreateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n * @param {*} result The result, if any.\n */\n afterDestroy: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroyAll\n * @method\n * @param {*} data The `data` returned by the adapter.\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n * @param {*} result The result, if any.\n */\n afterDestroyAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n * @param {*} result The result, if any.\n */\n afterFind: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n * @param {*} result The result, if any.\n */\n afterFindAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterSum\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n * @param {*} result The result, if any.\n */\n afterSum: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n * @param {*} result The result, if any.\n */\n afterUpdate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n * @param {*} result The result, if any.\n */\n afterUpdateAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n * @param {*} result The result, if any.\n */\n afterUpdateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n */\n beforeCreate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n */\n beforeCreateMany: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n */\n beforeCount: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n */\n beforeDestroy: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroyAll\n * @method\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n */\n beforeDestroyAll: notify,\n\n /**\n * Mappers lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n */\n beforeFind: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n */\n beforeFindAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeSum\n * @method\n * @param {string} field The `field` argument passed to {@link Mapper#sum}.\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n */\n beforeSum: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n */\n beforeUpdate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n */\n beforeUpdateAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n */\n beforeUpdateMany: notify,\n\n /**\n * This method is called at the end of most lifecycle methods. It does the\n * following:\n *\n * 1. If `opts.raw` is `true`, add this Mapper's configuration to the `opts`\n * argument as metadata for the operation.\n * 2. Wrap the result data appropriately using {@link Mapper#wrap}, which\n * calls {@link Mapper#createRecord}.\n *\n * @name Mapper#_end\n * @method\n * @private\n */\n _end (result, opts, skip) {\n const self = this\n if (opts.raw) {\n utils._(result, opts)\n }\n if (skip) {\n return result\n }\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(self.wrap)) {\n _data = self.wrap(_data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Define a belongsTo relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * Post.belongsTo(User, {\n * localKey: 'myUserId'\n * })\n *\n * Comment.belongsTo(User)\n * Comment.belongsTo(Post, {\n * localField: '_post'\n * })\n * ```\n *\n * @name Mapper#belongsTo\n * @method\n */\n belongsTo (relatedMapper, opts) {\n return belongsTo(relatedMapper, opts)(this)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeCount} will be called before calling the adapter.\n * {@link Mapper#afterCount} will be called after calling the adapter.\n *\n * @name Mapper#count\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n count (query, opts) {\n return this.crud('count', query, opts)\n },\n\n /**\n * Create and save a new the record using the provided `props`.\n *\n * {@link Mapper#beforeCreate} will be called before calling the adapter.\n * {@link Mapper#afterCreate} will be called after calling the adapter.\n *\n * @name Mapper#create\n * @method\n * @param {Object} props The properties for the new record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * created data. If `true` return a response object that includes the created\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `props` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#create}\n * or {@link Mapper#createMany} call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n create (props, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n props || (props = {})\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n const relatedMapper = def.getRelation()\n const relatedIdAttribute = relatedMapper.idAttribute\n optsCopy.raw = false\n if (!relationData) {\n return\n }\n if (def.type === belongsToType) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(relatedMapper.create(relationData, optsCopy).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n def.setForeignKey(props, data)\n }))\n } else if (def.type === hasManyType && def.localKeys) {\n // Create his hasMany relation first because it uses localKeys\n tasks.push(relatedMapper.createMany(relationData, optsCopy)).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n utils.set(props, def.localKeys, data.map(function (record) {\n return utils.get(record, relatedIdAttribute)\n }))\n })\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter for the main create\n op = opts.op = 'create'\n self.dbg(op, props, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, self.toJSON(props, { with: opts.pass || [] }), opts))\n }).then(function (data) {\n const createdRecord = opts.raw ? data.data : data\n // Deep post-create hasMany and hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n if (!relationData) {\n return\n }\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType && def.foreignKey) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, opts.raw ? data.data : data)\n })\n } else if (def.type === hasOneType) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().create(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, opts.raw ? data.data : data)\n })\n } else if (def.type === belongsToType && def.getLocalField(belongsToRelationData)) {\n def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData))\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](props, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n createInstance (props, opts) {\n return this.createRecord(props, opts)\n },\n\n /**\n * Given an array of records, batch create them via an adapter.\n *\n * {@link Mapper#beforeCreateMany} will be called before calling the adapter.\n * {@link Mapper#afterCreateMany} will be called after calling the adapter.\n *\n * @name Mapper#createMany\n * @method\n * @param {Array} records Array of records to be created in one batch.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `records` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#createMany}\n * call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n createMany (records, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (def.type === belongsToType && relationData.length === records.length) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedRecords = optsCopy.raw ? data.data : data\n def.setLocalField(belongsToRelationData, relatedRecords)\n records.forEach(function (record, i) {\n def.setForeignKey(record, relatedRecords[i])\n })\n }))\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter\n op = opts.op = 'createMany'\n const json = records.map(function (record) {\n return self.toJSON(record, { with: opts.pass || [] })\n })\n self.dbg(op, records, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, json, opts))\n }).then(function (data) {\n const createdRecords = opts.raw ? data.data : data\n\n // Deep post-create hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (relationData.length !== records.length) {\n return\n }\n const belongsToData = def.getLocalField(belongsToRelationData)\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType) {\n // Not supported\n self.log('warn', 'deep createMany of hasMany type not supported!')\n } else if (def.type === hasOneType) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setForeignKey(createdRecord, relationData[i])\n })\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedData = opts.raw ? data.data : data\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, relatedData[i])\n })\n })\n } else if (def.type === belongsToType && belongsToData && belongsToData.length === createdRecords.length) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, belongsToData[i])\n })\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](records, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Create an unsaved, uncached instance of this Mapper's\n * {@link Mapper#recordClass}.\n *\n * Returns `props` if `props` is already an instance of\n * {@link Mapper#recordClass}.\n *\n * @name Mapper#createRecord\n * @method\n * @param {Object|Array} props The properties for the Record instance or an\n * array of property objects for the Record instances.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation when\n * the Record instances are created.\n * @return {Object|Array} The Record instance or Record instances.\n */\n createRecord (props, opts) {\n props || (props = {})\n const self = this\n if (utils.isArray(props)) {\n return props.map(function (_props) {\n return self.createRecord(_props, opts)\n })\n }\n if (!utils.isObject(props)) {\n throw new Error('Cannot create a record from ' + props + '!')\n }\n const recordClass = self.recordClass\n const relationList = self.relationList || []\n relationList.forEach(function (def) {\n const relatedMapper = def.getRelation()\n const relationData = def.getLocalField(props)\n if (relationData && !relatedMapper.is(relationData)) {\n if (utils.isArray(relationData) && (!relationData.length || relatedMapper.is(relationData[0]))) {\n return\n }\n utils.set(props, def.localField, relatedMapper.createRecord(relationData, opts))\n }\n })\n // Check to make sure \"props\" is not already an instance of this Mapper.\n return recordClass ? (props instanceof recordClass ? props : new recordClass(props, opts)) : props // eslint-disable-line\n },\n\n /**\n * Lifecycle invocation method.\n *\n * @name Mapper#crud\n * @method\n * @param {string} method Name of the lifecycle method to invoke.\n * @param {...*} args Arguments to pass to the lifecycle method.\n * @return {Promise}\n */\n crud (method, ...args) {\n const self = this\n const config = self.lifecycleMethods[method]\n if (!config) {\n throw new Error(`${method}: No such CRUD method!`)\n }\n\n const upper = `${method.charAt(0).toUpperCase()}${method.substr(1)}`\n const before = `before${upper}`\n const after = `after${upper}`\n\n let op, adapter\n\n // Default values for arguments\n config.defaults.forEach(function (value, i) {\n if (utils.isUndefined(args[i])) {\n args[i] = utils.copy(value)\n }\n })\n\n const opts = args[args.length - 1]\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // before lifecycle hook\n op = opts.op = before\n return utils.resolve(self[op](...args)).then(function (_value) {\n if (!utils.isUndefined(config.beforeAssign)) {\n // Allow for re-assignment from lifecycle hook\n args[config.beforeAssign] = utils.isUndefined(_value) ? args[config.beforeAssign] : _value\n }\n // Now delegate to the adapter\n op = opts.op = method\n args = config.adapterArgs ? config.adapterArgs(self, ...args) : args\n self.dbg(op, ...args)\n return utils.resolve(self.getAdapter(adapter)[op](self, ...args))\n }).then(function (result) {\n result = self._end(result, opts, !!config.skip)\n args.push(result)\n // after lifecycle hook\n op = opts.op = after\n return utils.resolve(self[op](...args)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Using an adapter, destroy the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeDestroy} will be called before destroying the record.\n * {@link Mapper#afterDestroy} will be called after destroying the record.\n *\n * @name Mapper#destroy\n * @method\n * @param {(string|number)} id The primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroy (id, opts) {\n return this.crud('destroy', id, opts)\n },\n\n /**\n * Using the `query` argument, destroy the selected records via an adapter.\n * If no `query` is provided then all records will be destroyed.\n *\n * {@link Mapper#beforeDestroyAll} will be called before destroying the records.\n * {@link Mapper#afterDestroyAll} will be called after destroying the records.\n *\n * @name Mapper#destroyAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroyAll (query, opts) {\n return this.crud('destroyAll', query, opts)\n },\n\n /**\n * Retrieve via an adapter the record with the given primary key.\n *\n * {@link Mapper#beforeFind} will be called before calling the adapter.\n * {@link Mapper#afterFind} will be called after calling the adapter.\n *\n * @name Mapper#find\n * @method\n * @param {(string|number)} id The primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n find (id, opts) {\n return this.crud('find', id, opts)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeFindAll} will be called before calling the adapter.\n * {@link Mapper#afterFindAll} will be called after calling the adapter.\n *\n * @name Mapper#findAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n findAll (query, opts) {\n return this.crud('findAll', query, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Mapper#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n self.dbg('getAdapter', 'name:', name)\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw new ReferenceError(`${adapter} not found!`)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Mapper#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || opts.defaultAdapter\n },\n\n /**\n * @name Mapper#getAdapters\n * @method\n * @return {Object} This Mapper's adapters\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Returns this Mapper's schema.\n *\n * @return {Schema} This Mapper's schema.\n */\n getSchema () {\n return this.schema\n },\n\n /**\n * Defines a hasMany relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasMany(Post, {\n * localField: 'my_posts'\n * })\n * ```\n *\n * @name Mapper#hasMany\n * @method\n */\n hasMany (relatedMapper, opts) {\n return hasMany(relatedMapper, opts)(this)\n },\n\n /**\n * Defines a hasOne relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasOne(Profile, {\n * localField: '_profile'\n * })\n * ```\n *\n * @name Mapper#hasOne\n * @method\n */\n hasOne (relatedMapper, opts) {\n return hasOne(relatedMapper, opts)(this)\n },\n\n /**\n * Return whether `record` is an instance of this Mapper's recordClass.\n *\n * @name Mapper#is\n * @method\n * @param {Object} record The record to check.\n * @return {boolean} Whether `record` is an instance of this Mapper's\n * {@link Mapper#recordClass}.\n */\n is (record) {\n const recordClass = this.recordClass\n return recordClass ? record instanceof recordClass : false\n },\n\n /**\n * Register an adapter on this mapper under the given name.\n *\n * @name Mapper#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for this Mapper.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.defaultAdapter = name\n }\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeSum} will be called before calling the adapter.\n * {@link Mapper#afterSum} will be called after calling the adapter.\n *\n * @name Mapper#sum\n * @method\n * @param {string} field The field to sum.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n sum (field, query, opts) {\n return this.crud('sum', field, query, opts)\n },\n\n /**\n * Return a plain object representation of the given record.\n *\n * @name Mapper#toJSON\n * @method\n * @param {Object} record Record from which to create a plain object\n * representation.\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation.\n * @return {Object} Plain object representation of the record.\n */\n toJSON (record, opts) {\n const self = this\n opts || (opts = {})\n const relationFields = (self ? self.relationFields : []) || []\n let json = {}\n let properties\n if (self && self.schema) {\n properties = self.schema.properties || {}\n // TODO: Make this work recursively\n utils.forOwn(properties, function (opts, prop) {\n json[prop] = utils.plainCopy(record[prop])\n })\n }\n properties || (properties = {})\n if (!opts.strict) {\n for (var key in record) {\n if (!properties[key] && relationFields.indexOf(key) === -1) {\n json[key] = utils.plainCopy(record[key])\n }\n }\n }\n // The user wants to include relations in the resulting plain object\n // representation\n if (self && opts.withAll) {\n opts.with = relationFields.slice()\n }\n if (self && opts.with) {\n if (utils.isString(opts.with)) {\n opts.with = [opts.with]\n }\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(record)\n if (relationData) {\n // The actual recursion\n if (utils.isArray(relationData)) {\n def.setLocalField(json, relationData.map(function (item) {\n return def.getRelation().toJSON(item, optsCopy)\n }))\n } else {\n def.setLocalField(json, def.getRelation().toJSON(relationData, optsCopy))\n }\n }\n })\n }\n return json\n },\n\n /**\n * Using an adapter, update the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeUpdate} will be called before updating the record.\n * {@link Mapper#afterUpdate} will be called after updating the record.\n *\n * @name Mapper#update\n * @method\n * @param {(string|number)} id The primary key of the record to update.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n update (id, props, opts) {\n return this.crud('update', id, props, opts)\n },\n\n /**\n * Using the `query` argument, perform the a single updated to the selected\n * records. Expects back from the adapter an array of the updated records.\n *\n * {@link Mapper#beforeUpdateAll} will be called before making the update.\n * {@link Mapper#afterUpdateAll} will be called after making the update.\n *\n * @name Mapper#updateAll\n * @method\n * @param {Object} props Update to apply to selected records.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n updateAll (props, query, opts) {\n return this.crud('updateAll', props, query, opts)\n },\n\n /**\n * Given an array of updates, perform each of the updates via an adapter. Each\n * \"update\" is a hash of properties with which to update an record. Each\n * update must contain the primary key to be updated.\n *\n * {@link Mapper#beforeUpdateMany} will be called before making the update.\n * {@link Mapper#afterUpdateMany} will be called after making the update.\n *\n * @name Mapper#updateMany\n * @method\n * @param {Array} records Array up record updates.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if each record update contains nested updates for relations. NOT\n * performed in a transaction.\n * @return {Promise}\n */\n updateMany (records, opts) {\n return this.crud('updateMany', records, opts)\n },\n\n /**\n * Validate the given record or records according to this Mapper's\n * {@link Schema}. No return value means no errors.\n *\n * @name Mapper#validate\n * @method\n * @param {Object|Array} record The record or records to validate.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Schema#validate}.\n * @return {Array} Array of errors or undefined if no errors.\n */\n validate (record, opts) {\n const self = this\n const schema = self.getSchema()\n if (!schema) {\n throw new Error(`${self.name} mapper has no schema!`)\n }\n if (utils.isArray(record)) {\n return record.map(function (_record) {\n return schema.validate(_record, opts)\n })\n } else if (utils.isObject(record)) {\n return schema.validate(record, opts)\n } else {\n throw new Error('not a record!')\n }\n },\n\n /**\n * Method used to wrap data returned by an adapter with this Mapper's Record\n * class.\n *\n * @name Mapper#wrap\n * @method\n * @param {Object|Array} data The data to be wrapped.\n * @param {Object} [opts] Configuration options. Passed to {@link Mapper#createRecord}.\n * @return {Object|Array}\n */\n wrap (data, opts) {\n return this.createRecord(data, opts)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Mapper from './Mapper'\n\nconst toProxy = [\n /**\n * Proxy for {@link Mapper#count}.\n *\n * @name Container#count\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.count}.\n * @param {Object} [opts] - Passed to {@link Model.count}.\n * @return {Promise}\n */\n 'count',\n\n /**\n * Proxy for {@link Mapper#create}.\n *\n * @name Container#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n 'create',\n\n /**\n * Proxy for {@link Mapper#createMany}.\n *\n * @name Container#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n 'createMany',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#createRecord\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} props Passed to {@link Mapper#createRecord}.\n * @param {Object} [opts] Passed to {@link Mapper#createRecord}. See\n * {@link Mapper#createRecord} for configuration options.\n * @return {Promise}\n */\n 'createRecord',\n\n /**\n * Proxy for {@link Mapper#dbg}.\n *\n * @name Container#dbg\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#dbg}.\n */\n 'dbg',\n\n /**\n * Proxy for {@link Mapper#destroy}.\n *\n * @name Container#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n 'destroy',\n\n /**\n * Proxy for {@link Mapper#destroyAll}.\n *\n * @name Container#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n 'destroyAll',\n\n /**\n * Proxy for {@link Mapper#find}.\n *\n * @name Container#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n 'find',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n 'findAll',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#getSchema\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n */\n 'getSchema',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#is\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#is}.\n */\n 'is',\n\n /**\n * Proxy for {@link Mapper#log}.\n *\n * @name Container#log\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#log}.\n */\n 'log',\n\n /**\n * Proxy for {@link Mapper#sum}.\n *\n * @name Container#sum\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {string} field - Passed to {@link Model.sum}.\n * @param {Object} [query] - Passed to {@link Model.sum}.\n * @param {Object} [opts] - Passed to {@link Model.sum}.\n * @return {Promise}\n */\n 'sum',\n\n /**\n * Proxy for {@link Mapper#toJSON}.\n *\n * @name Container#toJSON\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#toJSON}.\n */\n 'toJSON',\n\n /**\n * Proxy for {@link Mapper#update}.\n *\n * @name Container#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n 'update',\n\n /**\n * Proxy for {@link Mapper#updateAll}.\n *\n * @name Container#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object?} query - Passed to {@link Model.updateAll}.\n * @param {Object} props - Passed to {@link Model.updateAll}.\n * @param {Object} [opts] - Passed to {@link Model.updateAll}. See\n * {@link Model.updateAll} for more configuration options.\n * @return {Promise}\n */\n 'updateAll',\n\n /**\n * Proxy for {@link Mapper#updateMany}.\n *\n * @name Container#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n 'updateMany'\n]\n\nconst props = {\n constructor: function Container (opts) {\n const self = this\n utils.classCallCheck(self, Container)\n Container.__super__.call(self)\n opts || (opts = {})\n\n // Apply options provided by the user\n utils.fillIn(self, opts)\n /**\n * Defaults options to pass to {@link Container#mapperClass} when creating a\n * new mapper.\n *\n * @name Container#mapperDefaults\n * @type {Object}\n */\n self.mapperDefaults = self.mapperDefaults || {}\n /**\n * Constructor function to use in {@link Container#defineMapper} to create a\n * new mapper.\n *\n * @name Container#mapperClass\n * @type {Function}\n */\n self.mapperClass = self.mapperClass || Mapper\n\n // Initilize private data\n\n // Holds the adapters, shared by all mappers in this container\n self._adapters = {}\n // The the mappers in this container\n self._mappers = {}\n },\n\n /**\n * Register a new event listener on this Container.\n *\n * Proxy for {@link Component#on}. If an event was emitted by a Mapper in the\n * Container, then the name of the Mapper will be prepended to the arugments\n * passed to the listener.\n *\n * @name Container#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by mappers in this container.\n *\n * @name Container#_onMapperEvent\n * @method\n * @private\n * @param {string} name Name of the mapper that emitted the event.\n * @param {...*} [args] Args passed to {@link Mapper#emit}.\n */\n _onMapperEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * Create a new mapper and register it in this container.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container({\n * mapperDefaults: { foo: 'bar' }\n * })\n * const userMapper = container.defineMapper('user')\n * userMapper.foo // \"bar\"\n *\n * @name Container#defineMapper\n * @method\n * @param {string} name Name under which to register the new {@link Mapper}.\n * {@link Mapper#name} will be set to this value.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Container#mapperClass} when creating the new {@link Mapper}.\n * @return {Mapper}\n */\n defineMapper (name, opts) {\n const self = this\n\n // For backwards compatibility with defineResource\n if (utils.isObject(name)) {\n opts = name\n if (!opts.name) {\n throw new Error('name is required!')\n }\n name = opts.name\n } else if (!utils.isString(name)) {\n throw new Error('name is required!')\n }\n\n // Default values for arguments\n opts || (opts = {})\n // Set Mapper#name\n opts.name = name\n opts.relations || (opts.relations = {})\n\n // Check if the user is overriding the datastore's default mapperClass\n const mapperClass = opts.mapperClass || self.mapperClass\n delete opts.mapperClass\n\n // Apply the datastore's defaults to the options going into the mapper\n utils.fillIn(opts, self.mapperDefaults)\n\n // Instantiate a mapper\n const mapper = self._mappers[name] = new mapperClass(opts) // eslint-disable-line\n // Make sure the mapper's name is set\n mapper.name = name\n // All mappers in this datastore will share adapters\n mapper._adapters = self.getAdapters()\n\n mapper.datastore = self\n\n mapper.on('all', function (...args) {\n self._onMapperEvent(name, ...args)\n })\n\n // Setup the mapper's relations, including generating Mapper#relationList\n // and Mapper#relationFields\n utils.forOwn(mapper.relations, function (group, type) {\n utils.forOwn(group, function (relations, _name) {\n if (utils.isObject(relations)) {\n relations = [relations]\n }\n relations.forEach(function (def) {\n def.getRelation = function () {\n return self.getMapper(_name)\n }\n const relatedMapper = self._mappers[_name] || _name\n if (type === belongsToType) {\n mapper.belongsTo(relatedMapper, def)\n } else if (type === hasOneType) {\n mapper.hasOne(relatedMapper, def)\n } else if (type === hasManyType) {\n mapper.hasMany(relatedMapper, def)\n }\n })\n })\n })\n\n return mapper\n },\n\n defineResource (name, opts) {\n return this.defineMapper(name, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Container#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw new ReferenceError(`${adapter} not found!`)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Container#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || this.mapperDefaults.defaultAdapter\n },\n\n /**\n * Return the registered adapters of this container.\n *\n * @name Container#getAdapters\n * @method\n * @return {Adapter}\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Return the mapper registered under the specified name.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container()\n * const userMapper = container.defineMapper('user')\n * userMapper === container.getMapper('user') // true\n *\n * @name Container#getMapper\n * @method\n * @param {string} name {@link Mapper#name}.\n * @return {Mapper}\n */\n getMapper (name) {\n const mapper = this._mappers[name]\n if (!mapper) {\n throw new ReferenceError(`${name} is not a registered mapper!`)\n }\n return mapper\n },\n\n /**\n * Register an adapter on this container under the given name. Adapters\n * registered on a container are shared by all mappers in the container.\n *\n * @example\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * container.registerAdapter('http', new HttpAdapter, { default: true })\n *\n * @name Container#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for all Mappers in this container.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.mapperDefaults.defaultAdapter = name\n utils.forOwn(self._mappers, function (mapper) {\n mapper.defaultAdapter = name\n })\n }\n }\n}\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getMapper(name)[method](...args)\n }\n})\n\n/**\n * ```javascript\n * import {Container} from 'js-data'\n * ```\n *\n * The `Container` class is a place to store {@link Mapper} instances.\n *\n * Without a container, you need to manage mappers yourself, including resolving\n * circular dependencies among relations. All mappers in a container share the\n * same adapters, so you don't have to add each adapter to all of your mappers.\n *\n * @example Without Container\n * import {Mapper} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const adapter = new HttpAdapter()\n * const userMapper = new Mapper({ name: 'user' })\n * userMapper.registerAdapter('http', adapter, { default: true })\n * const commentMapper = new Mapper({ name: 'comment' })\n * commentMapper.registerAdapter('http', adapter, { default: true })\n *\n * // This might be more difficult if the mappers were defined in different\n * // modules.\n * userMapper.hasMany(commentMapper, {\n * localField: 'comments',\n * foreignKey: 'userId'\n * })\n * commentMapper.belongsTo(userMapper, {\n * localField: 'user',\n * foreignKey: 'userId'\n * })\n *\n * @example With Container\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * // All mappers in container share adapters\n * container.registerAdapter('http', new HttpAdapter(), { default: true })\n *\n * // These could be defined in separate modules without a problem.\n * container.defineMapper('user', {\n * relations: {\n * hasMany: {\n * comment: {\n * localField: 'comments',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n * container.defineMapper('comment', {\n * relations: {\n * belongsTo: {\n * user: {\n * localField: 'user',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n *\n * @class Container\n * @extends Component\n * @param {Object} [opts] Configuration options.\n * @param {Function} [opts.mapperClass] Constructor function to use in\n * {@link Container#defineMapper} to create a new mapper.\n * @param {Object} [opts.mapperDefaults] Defaults options to pass to\n * {@link Container#mapperClass} when creating a new mapper.\n * @return {Container}\n */\nexport default Component.extend(props)\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Collection from './Collection'\n\n/**\n * TODO\n *\n * ```javascript\n * import {LinkedCollection} from 'js-data'\n * ```\n *\n * @class LinkedCollection\n * @extends Collection\n * @param {Array} [records] Initial set of records to insert into the\n * collection. See {@link Collection}.\n * @param {Object} [opts] Configuration options. See {@link Collection}.\n * @return {Mapper}\n */\nexport default Collection.extend({\n constructor: function LinkedCollection (records, opts) {\n const self = this\n utils.classCallCheck(self, LinkedCollection)\n LinkedCollection.__super__.call(self, records, opts)\n\n // Make sure this collection has somewhere to store \"added\" timestamps\n self._added = {}\n\n // Make sure this collection a reference to a datastore\n if (!self.datastore) {\n throw new Error('This collection must have a datastore!')\n }\n return self\n },\n\n _onRecordEvent (...args) {\n const self = this\n utils.getSuper(self).prototype._onRecordEvent.apply(self, args)\n const event = args[0]\n // This is a very brute force method\n // Lots of room for optimization\n if (utils.isString(event) && event.indexOf('change') === 0) {\n self.updateIndexes(args[1])\n }\n },\n\n add (records, opts) {\n const self = this\n const datastore = self.datastore\n const mapper = self.mapper\n const relationList = mapper.relationList || []\n const timestamp = new Date().getTime()\n const usesRecordClass = !!mapper.recordClass\n const idAttribute = mapper.idAttribute\n let singular\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n\n records = utils.getSuper(self).prototype.add.call(self, records, opts)\n\n if (relationList.length && records.length) {\n // Check the currently visited record for relations that need to be\n // inserted into their respective collections.\n mapper.relationList.forEach(function (def) {\n const relationName = def.relation\n // A reference to the Mapper that this Mapper is related to\n const relatedMapper = datastore.getMapper(relationName)\n // The field used by the related Mapper as the primary key\n const relationIdAttribute = relatedMapper.idAttribute\n // Grab the foreign key in this relationship, if there is one\n const foreignKey = def.foreignKey\n // A lot of this is an optimization for being able to insert a lot of\n // data as quickly as possible\n const relatedCollection = datastore.getCollection(relationName)\n const type = def.type\n const isHasMany = type === hasManyType\n const shouldAdd = utils.isUndefined(def.add) ? true : !!def.add\n let relatedData\n\n records.forEach(function (record) {\n // Grab a reference to the related data attached or linked to the\n // currently visited record\n relatedData = def.getLocalField(record)\n const id = utils.get(record, idAttribute)\n\n if (utils.isFunction(def.add)) {\n relatedData = def.add(datastore, def, record)\n } else if (relatedData) {\n // Otherwise, if there is something to be added, add it\n if (isHasMany) {\n // Handle inserting hasMany relations\n relatedData = relatedData.map(function (toInsertItem) {\n // Check that this item isn't the same item that is already in the\n // store\n if (toInsertItem !== relatedCollection.get(relatedCollection.recordId(toInsertItem))) {\n // Make sure this item has its foreignKey\n if (foreignKey) {\n // TODO: slow, could be optimized? But user loses hook\n def.setForeignKey(record, toInsertItem)\n }\n // Finally add this related item\n if (shouldAdd) {\n toInsertItem = relatedCollection.add(toInsertItem)\n }\n }\n return toInsertItem\n })\n // If it's the parent that has the localKeys\n if (def.localKeys && !utils.get(record, def.localKeys)) {\n utils.set(record, def.localKeys, relatedData.map(function (inserted) {\n return utils.get(inserted, relationIdAttribute)\n }))\n }\n } else {\n const relatedDataId = utils.get(relatedData, relationIdAttribute)\n // Handle inserting belongsTo and hasOne relations\n if (relatedData !== relatedCollection.get(relatedDataId)) {\n // Make sure foreignKey field is set\n def.setForeignKey(record, relatedData)\n // Finally insert this related item\n if (shouldAdd) {\n relatedData = relatedCollection.add(relatedData)\n }\n }\n }\n }\n\n if (!relatedData || (utils.isArray(relatedData) && !relatedData.length)) {\n if (type === belongsToType) {\n const relatedId = utils.get(record, foreignKey)\n if (!utils.isUndefined(relatedId)) {\n relatedData = relatedCollection.get(relatedId)\n }\n } else if (type === hasOneType) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records[0] : undefined\n } else if (type === hasManyType) {\n if (foreignKey) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.localKeys) {\n const _records = relatedCollection.filter({\n where: {\n [relationIdAttribute]: {\n 'in': utils.get(record, def.localKeys || [])\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.foreignKeys) {\n const _records = relatedCollection.filter({\n where: {\n [def.foreignKeys]: {\n 'contains': id\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n }\n }\n }\n if (relatedData) {\n def.setLocalField(record, relatedData)\n }\n })\n })\n }\n\n records.forEach(function (record) {\n // Track when this record was added\n self._added[self.recordId(record)] = timestamp\n\n if (usesRecordClass) {\n record._set('$', timestamp)\n }\n })\n\n return singular ? records[0] : records\n },\n\n remove (id, opts) {\n const self = this\n const mapper = self.mapper\n const record = utils.getSuper(self).prototype.remove.call(self, id, opts)\n if (record) {\n delete self._added[id]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n }\n return record\n },\n\n removeAll (query, opts) {\n const self = this\n const mapper = self.mapper\n const records = utils.getSuper(self).prototype.removeAll.call(self, query, opts)\n records.forEach(function (record) {\n delete self._added[self.recordId(record)]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n })\n return records\n }\n})\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Container from './Container'\nimport LinkedCollection from './LinkedCollection'\n\nconst DATASTORE_DEFAULTS = {}\n\nconst safeSet = function (record, field, value) {\n if (record && record._set) {\n record._set(field, value)\n } else {\n utils.set(record, field, value)\n }\n}\n\nconst cachedFn = function (name, hashOrId, opts) {\n const self = this\n const cached = self._completedQueries[name][hashOrId]\n if (utils.isFunction(cached)) {\n return cached(name, hashOrId, opts)\n }\n return cached\n}\n\nconst props = {\n constructor: function DataStore (opts) {\n const self = this\n utils.classCallCheck(self, DataStore)\n DataStore.__super__.call(self, opts)\n\n self.collectionClass = self.collectionClass || LinkedCollection\n self._collections = {}\n utils.fillIn(self, DATASTORE_DEFAULTS)\n self._pendingQueries = {}\n self._completedQueries = {}\n return self\n },\n\n _callSuper (method, ...args) {\n return this.constructor.__super__.prototype[method].apply(this, args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#_end\n * @method\n * @private\n * @param {string} name Name of the {@link LinkedCollection} to which to\n * add the data.\n * @param {Object} data TODO.\n * @param {Object} [opts] Configuration options.\n * @return {(Object|Array)} Result.\n */\n _end (name, result, opts) {\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(this.addToCache)) {\n _data = this.addToCache(name, _data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Register a new event listener on this DataStore.\n *\n * Proxy for {@link Container#on}. If an event was emitted by a Mapper or\n * Collection in the DataStore, then the name of the Mapper or Collection will\n * be prepended to the arugments passed to the provided event handler.\n *\n * @name DataStore#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by collections in this store.\n *\n * @name DataStore#_onCollectionEvent\n * @method\n * @private\n * @param {string} name Name of the collection that emitted the event.\n * @param {...*} [args] Args passed to {@link Collection#emit}.\n */\n _onCollectionEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#addToCache\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {*} data - Data from which data should be selected for add.\n * @param {Object} [opts] - Configuration options.\n */\n addToCache (name, data, opts) {\n return this.getCollection(name).add(data, opts)\n },\n\n /**\n * Retrieve a cached `find` result, if any.\n *\n * @name DataStore#cachedFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cachedFind: cachedFn,\n\n /**\n * Retrieve a cached `findAll` result, if any.\n *\n * @name DataStore#cachedFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cachedFindAll: cachedFn,\n\n /**\n * Cache a `find` result. The default implementation does the following:\n *\n * ```\n * // Find and return the record from the data store\n * return this.get(name, id)\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {*} data The result to cache.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cacheFind (name, data, id, opts) {\n const self = this\n self._completedQueries[name][id] = function (name, id, opts) {\n return self.get(name, id)\n }\n },\n\n /**\n * Cache a `findAll` result. The default implementation does the following:\n *\n * ```\n * // Find and return the records from the data store\n * return this.filter(name, utils.fromJson(hash))\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {*} data The result to cache.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cacheFindAll (name, data, hash, opts) {\n const self = this\n self._completedQueries[name][hash] = function (name, hash, opts) {\n return self.filter(name, utils.fromJson(hash))\n }\n },\n\n /**\n * TODO\n *\n * @name DataStore#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n create (name, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('create', name, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n createMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('createMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n defineMapper (name, opts) {\n const self = this\n const mapper = utils.getSuper(self).prototype.defineMapper.call(self, name, opts)\n self._pendingQueries[name] = {}\n self._completedQueries[name] = {}\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n\n // The datastore uses a subclass of Collection that is \"datastore-aware\"\n const collection = self._collections[name] = new self.collectionClass(null, { // eslint-disable-line\n // Make sure the collection has somewhere to store \"added\" timestamps\n _added: {},\n // Give the collection a reference to this datastore\n datastore: self,\n // The mapper tied to the collection\n mapper\n })\n\n const schema = mapper.schema || {}\n const properties = schema.properties || {}\n // TODO: Make it possible index nested properties?\n utils.forOwn(properties, function (opts, prop) {\n if (opts.indexed) {\n collection.createIndex(prop)\n }\n })\n\n // Create a secondary index on the \"added\" timestamps of records in the\n // collection\n collection.createIndex('addedTimestamps', ['$'], {\n fieldGetter (obj) {\n return collection._added[collection.recordId(obj)]\n }\n })\n\n collection.on('all', function (...args) {\n self._onCollectionEvent(name, ...args)\n })\n\n const idAttribute = mapper.idAttribute\n\n mapper.relationList.forEach(function (def) {\n const relation = def.relation\n const localField = def.localField\n const path = `links.${localField}`\n const foreignKey = def.foreignKey\n const type = def.type\n const updateOpts = { index: foreignKey }\n let descriptor\n\n const getter = function () { return this._get(path) }\n\n if (type === belongsToType) {\n if (!collection.indexes[foreignKey]) {\n collection.createIndex(foreignKey)\n }\n\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const id = utils.get(_self, idAttribute)\n const inverseDef = def.getInverse(mapper)\n\n if (record) {\n const relatedIdAttribute = def.getRelation().idAttribute\n const relatedId = utils.get(record, relatedIdAttribute)\n\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n safeSet(_self, foreignKey, relatedId)\n collection.updateIndex(_self, updateOpts)\n\n // Update (set) inverse relation\n if (inverseDef.type === hasOneType) {\n utils.set(record, inverseDef.localField, _self)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(record, inverseDef.localField)\n utils.noDupeAdd(children, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n } else {\n // Unset locals\n _self._set(path, undefined)\n safeSet(_self, foreignKey, undefined)\n collection.updateIndex(_self, updateOpts)\n }\n if (current) {\n if (inverseDef.type === hasOneType) {\n utils.set(current, inverseDef.localField, undefined)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(current, inverseDef.localField)\n utils.remove(children, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n }\n return record\n }\n }\n\n if (mapper.recordClass.prototype.hasOwnProperty(foreignKey)) {\n const superClass = mapper.recordClass\n mapper.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n Object.defineProperty(mapper.recordClass.prototype, foreignKey, {\n enumerable: true,\n get () { return this._get(foreignKey) },\n set (value) {\n const _self = this\n if (utils.isUndefined(value)) {\n // Unset locals\n utils.set(_self, localField, undefined)\n } else {\n safeSet(_self, foreignKey, value)\n let storeRecord = self.get(relation, value)\n if (storeRecord) {\n utils.set(_self, localField, storeRecord)\n }\n }\n }\n })\n } else if (type === hasManyType) {\n const localKeys = def.localKeys\n const foreignKeys = def.foreignKeys\n\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n\n descriptor = {\n get () {\n const _self = this\n let current = getter.call(_self)\n if (!current) {\n _self._set(path, [])\n }\n return getter.call(_self)\n },\n set (records) {\n const _self = this\n records || (records = [])\n if (records && !utils.isArray(records)) {\n records = [records]\n }\n const id = utils.get(_self, idAttribute)\n const relatedIdAttribute = def.getRelation().idAttribute\n const inverseDef = def.getInverse(mapper)\n const inverseLocalField = inverseDef.localField\n let linked = _self._get(path)\n if (!linked) {\n linked = []\n }\n\n const current = linked\n linked = []\n const toLink = {}\n records.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId)) {\n // Prefer store record\n record = self.get(relation, relatedId) || record\n toLink[relatedId] = record\n }\n linked.push(record)\n })\n if (foreignKey) {\n records.forEach(function (record) {\n // Update (set) inverse relation\n safeSet(record, foreignKey, id)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n })\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update (unset) inverse relation\n safeSet(record, foreignKey, undefined)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (localKeys) {\n const _localKeys = []\n records.forEach(function (record) {\n // Update (set) inverse relation\n utils.set(record, inverseLocalField, _self)\n _localKeys.push(utils.get(record, relatedIdAttribute))\n })\n // Update locals\n utils.set(_self, localKeys, _localKeys)\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update inverse relation\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (foreignKeys) {\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.remove(_localKeys, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.remove(_localField, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n // Update (set) inverse relation\n records.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.noDupeAdd(_localKeys, id, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.noDupeAdd(_localField, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n }\n\n _self._set(path, linked)\n return linked\n }\n }\n } else if (type === hasOneType) {\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const relatedId = utils.get(record, def.getRelation().idAttribute)\n const inverseLocalField = def.getInverse(mapper).localField\n // Update (unset) inverse relation\n if (current) {\n safeSet(current, foreignKey, undefined)\n self.getCollection(relation).updateIndex(current, updateOpts)\n utils.set(current, inverseLocalField, undefined)\n }\n if (record) {\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n\n // Update (set) inverse relation\n safeSet(record, foreignKey, utils.get(_self, idAttribute))\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n } else {\n // Set locals\n _self._set(path, undefined)\n }\n return record\n }\n }\n }\n\n if (descriptor) {\n descriptor.enumerable = utils.isUndefined(def.enumerable) ? true : def.enumerable\n if (def.get) {\n let origGet = descriptor.get\n descriptor.get = function () {\n return def.get(def, this, (...args) => origGet.apply(this, args))\n }\n }\n if (def.set) {\n let origSet = descriptor.set\n descriptor.set = function (related) {\n return def.set(def, this, related, (value) => origSet.call(this, value === undefined ? related : value))\n }\n }\n Object.defineProperty(mapper.recordClass.prototype, localField, descriptor)\n }\n })\n\n return mapper\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n destroy (name, id, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroy', name, id, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).remove(id, opts)\n } else {\n data = self.getCollection(name).remove(id, opts)\n }\n delete self._pendingQueries[name][id]\n delete self._completedQueries[name][id]\n return data\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n destroyAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroyAll', name, query, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).removeAll(query, opts)\n } else {\n data = self.getCollection(name).removeAll(query, opts)\n }\n const hash = self.hashQuery(name, query, opts)\n delete self._pendingQueries[name][hash]\n delete self._completedQueries[name][hash]\n return data\n })\n },\n\n eject (id, opts) {\n return this.remove(id, opts)\n },\n\n ejectAll (query, opts) {\n return this.removeAll(query, opts)\n },\n\n /**\n * TODO\n *\n * @name DataStore#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n find (name, id, opts) {\n const self = this\n opts || (opts = {})\n const pendingQuery = self._pendingQueries[name][id]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n const item = self.cachedFind(name, id, opts)\n let promise\n\n if (opts.force || !item) {\n promise = self._pendingQueries[name][id] = self._callSuper('find', name, id, opts).then(function (data) {\n delete self._pendingQueries[name][id]\n const result = self._end(name, data, opts)\n self.cacheFind(name, result, id, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][id]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(item)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n findAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n const hash = self.hashQuery(name, query, opts)\n const pendingQuery = self._pendingQueries[name][hash]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n\n const items = self.cachedFindAll(name, hash, opts)\n let promise\n\n if (opts.force || !items) {\n promise = self._pendingQueries[name][hash] = self._callSuper('findAll', name, query, opts).then(function (data) {\n delete self._pendingQueries[name][hash]\n const result = self._end(name, data, opts)\n self.cacheFindAll(name, result, hash, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][hash]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(items)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#getCollection\n * @method\n * @param {string} name Name of the {@link LinkedCollection} to retrieve.\n * @return {LinkedCollection}\n */\n getCollection (name) {\n const collection = this._collections[name]\n if (!collection) {\n throw new ReferenceError(`${name} is not a registered collection!`)\n }\n return collection\n },\n\n hashQuery (name, query, opts) {\n return utils.toJson(query)\n },\n\n inject (records, opts) {\n return this.add(records, opts)\n },\n\n remove (name, id, opts) {\n const self = this\n const record = self.getCollection(name).remove(id, opts)\n if (record) {\n self.removeRelated(name, [record], opts)\n }\n return record\n },\n\n removeAll (name, query, opts) {\n const self = this\n const records = self.getCollection(name).removeAll(query, opts)\n if (records.length) {\n self.removeRelated(name, records, opts)\n }\n return records\n },\n\n removeRelated (name, records, opts) {\n const self = this\n utils.forEachRelation(self.getMapper(name), opts, function (def, optsCopy) {\n records.forEach(function (record) {\n let relatedData\n let query\n if (def.foreignKey && (def.type === hasOneType || def.type === hasManyType)) {\n query = { [def.foreignKey]: def.getForeignKey(record) }\n } else if (def.type === hasManyType && def.localKeys) {\n query = {\n where: {\n [def.getRelation().idAttribute]: {\n 'in': utils.get(record, def.localKeys)\n }\n }\n }\n } else if (def.type === hasManyType && def.foreignKeys) {\n query = {\n where: {\n [def.foreignKeys]: {\n 'contains': def.getForeignKey(record)\n }\n }\n }\n } else if (def.type === belongsToType) {\n relatedData = self.remove(def.relation, def.getForeignKey(record), optsCopy)\n }\n if (query) {\n relatedData = self.removeAll(def.relation, query, optsCopy)\n }\n if (relatedData) {\n if (utils.isArray(relatedData) && !relatedData.length) {\n return\n }\n if (def.type === hasOneType) {\n relatedData = relatedData[0]\n }\n def.setLocalField(record, relatedData)\n }\n })\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n update (name, id, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('update', name, id, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} props - Passed to {@link Mapper#updateAll}.\n * @param {Object} [query] - Passed to {@link Mapper#updateAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#updateAll}. See\n * {@link Mapper#updateAll} for more configuration options.\n * @return {Promise}\n */\n updateAll (name, props, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateAll', name, query, props, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n updateMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n }\n}\n\nconst toProxy = [\n 'add',\n 'between',\n 'createIndex',\n 'filter',\n 'get',\n 'getAll',\n 'query',\n 'toJson'\n]\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getCollection(name)[method](...args)\n }\n})\n\n/**\n * The `DataStore` class is an extension of {@link Container}. Not only does\n * `DataStore` manage mappers, but also collections. `DataStore` implements the\n * asynchronous {@link Mapper} methods, such as {@link Mapper#find} and\n * {@link Mapper#create}. If you use the asynchronous `DataStore` methods\n * instead of calling them directly on the mappers, then the results of the\n * method calls will be inserted into the store's collections. You can think of\n * a `DataStore` as an [Identity Map](https://en.wikipedia.org/wiki/Identity_map_pattern)\n * for the [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)\n * (the Mappers).\n *\n * ```javascript\n * import {DataStore} from 'js-data'\n * ```\n *\n * @example\n * import {DataStore} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const store = new DataStore()\n * const UserMapper = store.defineMapper('user')\n *\n * // Call \"find\" on \"UserMapper\" (Stateless ORM)\n * UserMapper.find(1).then(function (user) {\n * // retrieved a \"user\" record via the http adapter, but that's it\n *\n * // Call \"find\" on \"store\" for the \"user\" mapper (Stateful DataStore)\n * return store.find('user', 1)\n * }).then(function (user) {\n * // not only was a \"user\" record retrieved, but it was added to the\n * // store's \"user\" collection\n * const cachedUser = store.getCollection('user').get(1)\n * user === cachedUser // true\n * })\n *\n * @class DataStore\n * @extends Container\n * @param {Object} [opts] Configuration options. See {@link Container}.\n * @return {DataStore}\n */\nexport default Container.extend(props)\n","/**\n * Registered as `js-data` in NPM and Bower.\n * #### Script tag\n * ```js\n * window.JSData\n * ```\n * #### CommonJS\n * ```js\n * var JSData = require('js-data')\n * ```\n * #### ES6 Modules\n * ```js\n * import JSData from 'js-data'\n * ```\n * #### AMD\n * ```js\n * define('myApp', ['js-data'], function (JSData) { ... })\n * ```\n *\n * @module js-data\n */\n\n/**\n * Details of the current version of the `js-data` module.\n *\n * @name version\n * @memberof module:js-data\n * @type {Object}\n * @property {string} full The full semver value.\n * @property {number} major The major version number.\n * @property {number} minor The minor version number.\n * @property {number} patch The patch version number.\n * @property {(string|boolean)} alpha The alpha version value, otherwise `false`\n * if the current version is not alpha.\n * @property {(string|boolean)} beta The beta version value, otherwise `false`\n * if the current version is not beta.\n */\nexport const version = {\n alpha: '<%= alpha %>' !== 'false' ? '<%= alpha %>' : false,\n beta: '<%= beta %>' !== 'false' ? '<%= beta %>' : false,\n full: '<%= pkg.version %>',\n major: parseInt('<%= major %>', 10),\n minor: parseInt('<%= minor %>', 10),\n patch: parseInt('<%= patch %>', 10)\n}\n\nimport utils from './utils'\n\n/**\n * {@link Collection} class.\n * @name module:js-data.Collection\n */\nimport Collection from './Collection'\n\n/**\n * {@link Component} class.\n * @name module:js-data.Component\n */\nimport Component from './Component'\n\n/**\n * {@link Container} class.\n * @name module:js-data.Container\n */\nimport Container from './Container'\n\n/**\n * {@link DataStore} class.\n * @name module:js-data.DataStore\n */\nimport DataStore from './DataStore'\n\n/**\n * {@link LinkedCollection} class.\n * @name module:js-data.LinkedCollection\n */\nimport LinkedCollection from './LinkedCollection'\n\n/**\n * {@link Mapper} class.\n * @name module:js-data.Mapper\n */\nimport Mapper from './Mapper'\n\n/**\n * {@link Query} class.\n * @name module:js-data.Query\n */\nimport Query from './Query'\n\n/**\n * {@link Record} class.\n * @name module:js-data.Record\n */\nimport Record from './Record'\n\n/**\n * {@link Schema} class.\n * @name module:js-data.Schema\n */\nimport Schema from './Schema'\n\nexport * from './decorators'\n\nexport {\n Collection,\n Component,\n Container,\n DataStore,\n LinkedCollection,\n Mapper,\n Query,\n Record,\n Schema,\n utils\n}\n"],"names":["utils","belongsTo","hasMany","hasOne","props","toProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,EAAA,IAAM,WAAW,IAAI,CAAJ;AACjB,EAAA,IAAM,cAAc,uBAAd;AACN,EAAA,IAAM,WAAW,kBAAX;AACN,EAAA,IAAM,WAAW,eAAX;AACN,EA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,UAAU,MAAV,CAAiBD,OAAjB,CAAf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACr0BA,EAAO,IAAM,UAAU;AACrB,EAAA,SAAO,AAA6B,cAA7B,AAAA;AACP,EAAA,QAAM,AAA4B,aAA5B,AAAA;AACN,EAAA,QAAM,oBAAN;AACA,EAAA,SAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,EAAA,SAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,EAAA,SAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;GANW,CAAb;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"js-data.js","sources":["../src/utils.js","../src/Component.js","../src/Query.js","../lib/mindex/_utils.js","../lib/mindex/index.js","../src/Collection.js","../src/decorators.js","../src/Record.js","../src/Schema.js","../src/Mapper.js","../src/Container.js","../src/LinkedCollection.js","../src/DataStore.js","../src/index.js"],"sourcesContent":["/**\n * @name utils\n * @memberof module:js-data\n * @type {Object}\n * @property {Function} addHiddenPropsToTarget TODO\n * @property {Function} classCallCheck TODO\n * @property {Function} copy TODO\n * @property {Function} deepMixIn TODO\n * @property {Function} eventify TODO\n * @property {Function} extend TODO\n * @property {Function} fillIn TODO\n * @property {Function} fromJson TODO\n * @property {Function} get TODO\n * @property {Function} getSuper TODO\n * @property {Function} intersection TODO\n * @property {Function} isArray TODO\n * @property {Function} isBlacklisted TODO\n * @property {boolean} isBrowser TODO\n * @property {Function} isBoolean TODO\n * @property {Function} isFunction TODO\n * @property {Function} isInteger TODO\n * @property {Function} isNull TODO\n * @property {Function} isNumber TODO\n * @property {Function} isObject TODO\n * @property {Function} isRegExp TODO\n * @property {Function} isSorN TODO\n * @property {Function} isString TODO\n * @property {Function} isUndefined TODO\n * @property {Function} reject TODO\n * @property {Function} resolve TODO\n * @property {Function} set TODO\n * @property {Function} toJson TODO\n */\n\nconst DOMAIN = 'utils'\n\nconst INFINITY = 1 / 0\nconst MAX_INTEGER = 1.7976931348623157e+308\nconst BOOL_TAG = '[object Boolean]'\nconst DATE_TAG = '[object Date]'\nconst FUNC_TAG = '[object Function]'\nconst NUMBER_TAG = '[object Number]'\nconst OBJECT_TAG = '[object Object]'\nconst REGEXP_TAG = '[object RegExp]'\nconst STRING_TAG = '[object String]'\nconst objToString = Object.prototype.toString\nconst PATH = /^(.+)\\.(.+)$/\n\nconst ERRORS = {\n '400' () { return `expected: ${arguments[0]}, found: ${arguments[2] ? arguments[1] : typeof arguments[1]}` },\n '404' () { return `${arguments[0]} not found` }\n}\n\nconst toInteger = function (value) {\n if (!value) {\n return 0\n }\n // Coerce to number\n value = +value\n if (value === INFINITY || value === -INFINITY) {\n const sign = (value < 0 ? -1 : 1)\n return sign * MAX_INTEGER\n }\n const remainder = value % 1\n return value === value ? (remainder ? value - remainder : value) : 0 // eslint-disable-line\n}\n\nconst toStr = function (value) {\n return objToString.call(value)\n}\n\nconst isPlainObject = function (value) {\n return (!!value && typeof value === 'object' && value.constructor === Object)\n}\n\nconst mkdirP = function (object, path) {\n if (!path) {\n return object\n }\n const parts = path.split('.')\n parts.forEach(function (key) {\n if (!object[key]) {\n object[key] = {}\n }\n object = object[key]\n })\n return object\n}\n\nconst utils = {\n /**\n * TODO\n *\n * @ignore\n */\n Promise: Promise,\n\n /**\n * Shallow copy properties from src to dest that meet the following criteria:\n * - own enumerable\n * - not a function\n * - does not start with \"_\"\n *\n * @ignore\n * @param {Object} dest Destination object.\n * @param {Object} src Source object.\n */\n _ (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (key && utils.isUndefined(dest[key]) && !utils.isFunction(value) && key.indexOf('_') !== 0) {\n dest[key] = value\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _forRelation (opts, def, fn, ctx) {\n const relationName = def.relation\n let containedName = null\n let index\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n if ((index = utils._getIndex(opts.with, relationName)) >= 0) {\n containedName = relationName\n } else if ((index = utils._getIndex(opts.with, def.localField)) >= 0) {\n containedName = def.localField\n }\n\n if (opts.withAll) {\n fn.call(ctx, def, {})\n return\n } else if (!containedName) {\n return\n }\n let optsCopy = {}\n utils.fillIn(optsCopy, def.getRelation())\n utils.fillIn(optsCopy, opts)\n optsCopy.with = opts.with.slice()\n optsCopy._activeWith = optsCopy.with.splice(index, 1)[0]\n optsCopy.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n optsCopy.with[i] = relation.substr(containedName.length + 1)\n } else {\n optsCopy.with[i] = ''\n }\n })\n fn.call(ctx, def, optsCopy)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n _getIndex (list, relation) {\n let index = -1\n list.forEach(function (_relation, i) {\n if (_relation === relation) {\n index = i\n return false\n } else if (utils.isObject(_relation)) {\n if (_relation.relation === relation) {\n index = i\n return false\n }\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n addHiddenPropsToTarget (target, props) {\n const map = {}\n utils.forOwn(props, function (value, key) {\n map[key] = {\n writable: true,\n value\n }\n })\n Object.defineProperties(target, map)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n areDifferent (a, b, opts) {\n opts || (opts = {})\n const diff = utils.diffObjects(a, b, opts)\n const diffCount = Object.keys(diff.added).length +\n Object.keys(diff.removed).length +\n Object.keys(diff.changed).length\n return diffCount > 0\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n classCallCheck (instance, ctor) {\n if (!(instance instanceof ctor)) {\n throw utils.err(`${ctor.name}`)(500, 'Cannot call a class as a function')\n }\n },\n\n /**\n * Deep copy a value.\n *\n * @ignore\n * @param {*} from Value to deep copy.\n * @return {*} Deep copy of `from`.\n */\n copy (from, to, stackFrom, stackTo, blacklist, plain) {\n if (!to) {\n to = from\n if (from) {\n if (utils.isArray(from)) {\n to = utils.copy(from, [], stackFrom, stackTo, blacklist, plain)\n } else if (utils.isDate(from)) {\n to = new Date(from.getTime())\n } else if (utils.isRegExp(from)) {\n to = new RegExp(from.source, from.toString().match(/[^\\/]*$/)[0])\n to.lastIndex = from.lastIndex\n } else if (utils.isObject(from)) {\n if (plain) {\n to = utils.copy(from, {}, stackFrom, stackTo, blacklist, plain)\n } else {\n to = utils.copy(from, Object.create(Object.getPrototypeOf(from)), stackFrom, stackTo, blacklist, plain)\n }\n }\n }\n } else {\n if (from === to) {\n throw utils.err(`${DOMAIN}.copy`)(500, 'Cannot copy! Source and destination are identical.')\n }\n\n stackFrom = stackFrom || []\n stackTo = stackTo || []\n\n if (utils.isObject(from)) {\n let index = stackFrom.indexOf(from)\n if (index !== -1) {\n return stackTo[index]\n }\n\n stackFrom.push(from)\n stackTo.push(to)\n }\n\n let result\n if (utils.isArray(from)) {\n let i\n to.length = 0\n for (i = 0; i < from.length; i++) {\n result = utils.copy(from[i], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[i])) {\n stackFrom.push(from[i])\n stackTo.push(result)\n }\n to.push(result)\n }\n } else {\n if (utils.isArray(to)) {\n to.length = 0\n } else {\n utils.forOwn(to, function (value, key) {\n delete to[key]\n })\n }\n for (var key in from) {\n if (from.hasOwnProperty(key)) {\n if (utils.isBlacklisted(key, blacklist)) {\n continue\n }\n result = utils.copy(from[key], null, stackFrom, stackTo, blacklist, plain)\n if (utils.isObject(from[key])) {\n stackFrom.push(from[key])\n stackTo.push(result)\n }\n to[key] = result\n }\n }\n }\n }\n return to\n },\n\n /**\n * Recursively shallow fill in own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepFillIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepFillIn(existing, value)\n } else if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * Recursively shallow copy own enumberable properties from `source` to `dest`.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n deepMixIn (dest, source) {\n if (source) {\n utils.forOwn(source, function (value, key) {\n const existing = dest[key]\n if (isPlainObject(value) && isPlainObject(existing)) {\n utils.deepMixIn(existing, value)\n } else {\n dest[key] = value\n }\n })\n }\n return dest\n },\n\n /**\n * @param {Object} a Base object.\n * @param {Object} b Comparison object.\n * @return {Object} Diff.\n */\n diffObjects (a, b, opts) {\n opts || (opts = {})\n let equalsFn = opts.equalsFn\n let bl = opts.ignore\n const diff = {\n added: {},\n changed: {},\n removed: {}\n }\n if (!utils.isFunction(equalsFn)) {\n equalsFn = utils.strictEqual\n }\n\n utils.forOwn(b, function (oldValue, key) {\n const newValue = a[key]\n\n if (utils.isBlacklisted(key, bl) || equalsFn(newValue, oldValue)) {\n return\n }\n\n if (utils.isUndefined(newValue)) {\n diff.removed[key] = undefined\n } else if (!equalsFn(newValue, oldValue)) {\n diff.changed[key] = newValue\n }\n })\n\n utils.forOwn(a, function (newValue, key) {\n if (!utils.isUndefined(b[key]) || utils.isBlacklisted(key, bl)) {\n return\n }\n diff.added[key] = newValue\n })\n\n return diff\n },\n\n /**\n * TODO\n */\n equal (a, b) {\n return a == b // eslint-disable-line\n },\n\n /**\n * TODO\n */\n err (domain, target) {\n return function (code) {\n const prefix = `[${domain}:${target}] `\n let message = ERRORS[code].apply(null, Array.prototype.slice.call(arguments, 1))\n message = `${prefix}${message}\\nhttp://www.js-data.io/v3.0/docs/errors#${code}`\n return new Error(message)\n }\n },\n\n /**\n * Add eventing capabilities into the target object.\n *\n * @ignore\n * @param {Object} target Target object.\n * @param {Function} [getter] Custom getter for retrieving the object's event\n * listeners.\n * @param {Function} [setter] Custom setter for setting the object's event\n * listeners.\n */\n eventify (target, getter, setter) {\n target = target || this\n let _events = {}\n if (!getter && !setter) {\n getter = function () { return _events }\n setter = function (value) { _events = value }\n }\n Object.defineProperties(target, {\n emit: {\n value (...args) {\n const events = getter.call(this) || {}\n const type = args.shift()\n let listeners = events[type] || []\n let i\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n listeners = events.all || []\n args.unshift(type)\n for (i = 0; i < listeners.length; i++) {\n listeners[i].f.apply(listeners[i].c, args)\n }\n }\n },\n off: {\n value (type, func) {\n const events = getter.call(this)\n const listeners = events[type]\n if (!listeners) {\n setter.call(this, {})\n } else if (func) {\n for (let i = 0; i < listeners.length; i++) {\n if (listeners[i].f === func) {\n listeners.splice(i, 1)\n break\n }\n }\n } else {\n listeners.splice(0, listeners.length)\n }\n }\n },\n on: {\n value (type, func, ctx) {\n if (!getter.call(this)) {\n setter.call(this, {})\n }\n const events = getter.call(this)\n events[type] = events[type] || []\n events[type].push({\n c: ctx,\n f: func\n })\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n extend (props, classProps) {\n const superClass = this\n let subClass\n\n props || (props = {})\n classProps || (classProps = {})\n\n if (props.hasOwnProperty('constructor')) {\n subClass = props.constructor\n delete props.constructor\n } else {\n subClass = function (...args) {\n utils.classCallCheck(this, subClass)\n superClass.apply(this, args)\n }\n }\n\n // Setup inheritance of instance members\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n configurable: true,\n enumerable: false,\n value: subClass,\n writable: true\n }\n })\n\n const obj = Object\n // Setup inheritance of static members\n if (obj.setPrototypeOf) {\n obj.setPrototypeOf(subClass, superClass)\n } else if (classProps.strictEs6Class) {\n subClass.__proto__ = superClass // eslint-disable-line\n } else {\n utils.forOwn(superClass, function (value, key) {\n subClass[key] = value\n })\n }\n Object.defineProperty(subClass, '__super__', {\n configurable: true,\n value: superClass\n })\n\n utils.addHiddenPropsToTarget(subClass.prototype, props)\n utils.fillIn(subClass, classProps)\n\n return subClass\n },\n\n /**\n * Shallow copy own enumerable properties from `src` to `dest` that are on `src`\n * but are missing from `dest.\n *\n * @ignore\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n */\n fillIn (dest, src) {\n utils.forOwn(src, function (value, key) {\n if (!dest.hasOwnProperty(key) || dest[key] === undefined) {\n dest[key] = value\n }\n })\n return dest\n },\n\n /**\n * Find the index of something according to the given checker function.\n *\n * @ignore\n * @param {Array} array The array to search.\n * @param {Function} fn Checker function.\n * @param {number} Index if found or -1 if not found.\n */\n findIndex (array, fn) {\n let index = -1\n if (!array) {\n return index\n }\n array.forEach(function (record, i) {\n if (fn(record)) {\n index = i\n return false\n }\n })\n return index\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n forEachRelation (mapper, opts, fn, ctx) {\n const relationList = mapper.relationList || []\n if (!relationList.length) {\n return\n }\n relationList.forEach(function (def) {\n utils._forRelation(opts, def, fn, ctx)\n })\n },\n\n /**\n * Iterate over an object's own enumerable properties.\n *\n * @ignore\n * @param {Object} object The object whose properties are to be enumerated.\n * @param {Function} fn Iteration function.\n * @param {Object} [thisArg] Content to which to bind `fn`.\n */\n forOwn (obj, fn, thisArg) {\n const keys = Object.keys(obj)\n const len = keys.length\n let i\n for (i = 0; i < len; i++) {\n fn.call(thisArg, obj[keys[i]], keys[i], obj)\n }\n },\n\n /**\n * Proxy for `JSON.parse`.\n *\n * @ignore\n * @param {string} json JSON to parse.\n * @return {Object} Parsed object.\n */\n fromJson (json) {\n return utils.isString(json) ? JSON.parse(json) : json\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n 'get': function (object, prop) {\n if (!prop) {\n return\n }\n const parts = prop.split('.')\n const last = parts.pop()\n\n while (prop = parts.shift()) { // eslint-disable-line\n object = object[prop]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n return object[last]\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n getSuper (instance, isCtor) {\n const ctor = isCtor ? instance : instance.constructor\n return (ctor.__super__ || Object.getPrototypeOf(ctor) || ctor.__proto__) // eslint-disable-line\n },\n\n /**\n * Return the intersection of two arrays.\n *\n * @ignore\n * @param {Array} array1 First array.\n * @param {Array} array2 Second array.\n * @return {Array} Array of elements common to both arrays.\n */\n intersection (array1, array2) {\n if (!array1 || !array2) {\n return []\n }\n const result = []\n let item\n let i\n const len = array1.length\n for (i = 0; i < len; i++) {\n item = array1[i]\n if (result.indexOf(item) !== -1) {\n continue\n }\n if (array2.indexOf(item) !== -1) {\n result.push(item)\n }\n }\n return result\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isArray: Array.isArray,\n\n /**\n * Return whether `prop` is matched by any string or regular expression in `bl`.\n *\n * @ignore\n * @param {string} prop The name of a property.\n * @param {Array} bl Array of strings and regular expressions.\n * @return {boolean} Whether `prop` was matched.\n */\n isBlacklisted (prop, bl) {\n if (!bl || !bl.length) {\n return false\n }\n let matches\n for (var i = 0; i < bl.length; i++) {\n if ((toStr(bl[i]) === REGEXP_TAG && bl[i].test(prop)) || bl[i] === prop) {\n matches = prop\n return matches\n }\n }\n return !!matches\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBoolean (value) {\n return toStr(value) === BOOL_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isBrowser: false,\n\n /**\n * TODO\n *\n * @ignore\n */\n isDate (value) {\n return (value && typeof value === 'object' && toStr(value) === DATE_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isFunction (value) {\n return typeof value === 'function' || (value && toStr(value) === FUNC_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isInteger (value) {\n return toStr(value) === NUMBER_TAG && value == toInteger(value) // eslint-disable-line\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNull (value) {\n return value === null\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isNumber (value) {\n const type = typeof value\n return type === 'number' || (value && type === 'object' && toStr(value) === NUMBER_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isObject (value) {\n return toStr(value) === OBJECT_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isRegExp (value) {\n return toStr(value) === REGEXP_TAG\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isSorN (value) {\n return utils.isString(value) || utils.isNumber(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isString (value) {\n return typeof value === 'string' || (value && typeof value === 'object' && toStr(value) === STRING_TAG)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n isUndefined (value) {\n return value === undefined\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n logify (target) {\n utils.addHiddenPropsToTarget(target, {\n dbg (...args) {\n this.log('debug', ...args)\n },\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (${this.name || this.constructor.name})`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n }\n })\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n noDupeAdd (array, record, fn) {\n if (!array) {\n return\n }\n const index = this.findIndex(array, fn)\n if (index < 0) {\n array.push(record)\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n omit (props, keys) {\n // Remove relations\n const _props = {}\n utils.forOwn(props, function (value, key) {\n if (keys.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n return _props\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n plainCopy (from) {\n return utils.copy(from, undefined, undefined, undefined, undefined, true)\n },\n\n /**\n * Proxy for `Promise.reject`.\n *\n * @ignore\n * @param {*} [value] Value with which to reject the Promise.\n * @return {Promise} Promise reject with `value`.\n */\n reject (value) {\n return utils.Promise.reject(value)\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n remove (array, fn) {\n if (!array || !array.length) {\n return\n }\n const index = this.findIndex(array, fn)\n if (index >= 0) {\n array.splice(index, 1)\n }\n },\n\n /**\n * Proxy for `Promise.resolve`.\n *\n * @ignore\n * @param {*} [value] Value with which to resolve the Promise.\n * @return {Promise} Promise resolved with `value`.\n */\n resolve (value) {\n return utils.Promise.resolve(value)\n },\n\n /**\n * Set the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object on which to set a property.\n * @param {(string|Object)} path The key or path to the property. Can also\n * pass in an object of path/value pairs, which will all be set on the target\n * object.\n * @param {*} [value] The value to set.\n */\n set: function (object, path, value) {\n if (utils.isObject(path)) {\n utils.forOwn(path, function (value, _path) {\n utils.set(object, _path, value)\n })\n } else {\n const parts = PATH.exec(path)\n if (parts) {\n mkdirP(object, parts[1])[parts[2]] = value\n } else {\n object[path] = value\n }\n }\n },\n\n /**\n * TODO\n *\n * @ignore\n */\n strictEqual (a, b) {\n let _equal = a === b\n if (!_equal) {\n if (utils.isObject(a) && utils.isObject(b)) {\n utils.forOwn(a, function (value, key) {\n _equal = _equal && utils.strictEqual(value, b[key])\n })\n utils.forOwn(b, function (value, key) {\n _equal = _equal && utils.strictEqual(value, a[key])\n })\n } else if (utils.isArray(a) && utils.isArray(b)) {\n a.forEach(function (value, i) {\n _equal = _equal && utils.strictEqual(value, b[i])\n })\n }\n }\n return _equal\n },\n\n /**\n * Proxy for `JSON.stringify`.\n *\n * @ignore\n * @param {*} value Value to serialize to JSON.\n * @return {string} JSON string.\n */\n toJson: JSON.stringify,\n\n /**\n * Unset the value at the provided key or path.\n *\n * @ignore\n * @param {Object} object The object from which to delete the property.\n * @param {string} path The key or path to the property.\n */\n unset (object, path) {\n const parts = path.split('.')\n const last = parts.pop()\n\n while (path = parts.shift()) { // eslint-disable-line\n object = object[path]\n if (object == null) { // eslint-disable-line\n return\n }\n }\n\n object[last] = undefined\n }\n}\n\n// Attempt to detect whether we are in the browser.\ntry {\n utils.isBrowser = !!window\n} catch (e) {\n utils.isBrowser = false\n}\n\nexport default utils\n","import utils from './utils'\n\nexport default function Component () {\n /**\n * Event listeners attached to this Component. Do not modify. Use\n * {@link Component#on} and {@link Component#off} instead.\n *\n * @name Component#_listeners\n * @instance\n * @type {Object}\n */\n Object.defineProperty(this, '_listeners', { value: {} })\n}\n\n/**\n * Create a subclass of this component.\n *\n * @name Component.extend\n * @method\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @return {Function} Subclass of this component.\n */\nComponent.extend = utils.extend\n\n/**\n * TODO\n *\n * @name Component#dbg\n * @method\n */\n/**\n * TODO\n *\n * @name Component#log\n * @method\n */\nutils.logify(Component.prototype)\n\n/**\n * Register a new event listener on this Component.\n *\n * @name Component#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n/**\n * Remove an event listener from this Component. If no listener is provided,\n * then all listeners for the specified event will be removed. If no event is\n * specified then all listeners for all events will be removed.\n *\n * @name Component#off\n * @method\n * @param {string} [event] Name of event to unsubsribe to.\n * @param {Function} [listener] Listener to remove.\n */\n/**\n * Trigger an event on this Component.\n *\n * @name Component#emit\n * @method\n * @param {string} event Name of event to emit.\n * @param {...*} [args] Arguments to pass to any listeners.\n */\nutils.eventify(\n Component.prototype,\n function () {\n return this._listeners\n },\n function (value) {\n this._listeners = value\n }\n)\n","import utils from './utils'\nimport Component from './Component'\n\nconst DOMAIN = 'Query'\nconst INDEX_ERR = 'Index inaccessible after first operation'\n\n// Reserved words used by JSData's Query Syntax\nconst reserved = {\n limit: '',\n offset: '',\n orderBy: '',\n skip: '',\n sort: '',\n where: ''\n}\n\n// Used by our JavaScript implementation of the LIKE operator\nconst escapeRegExp = /([.*+?^=!:${}()|[\\]\\/\\\\])/g\nconst percentRegExp = /%/g\nconst underscoreRegExp = /_/g\nconst escape = function (pattern) {\n return pattern.replace(escapeRegExp, '\\\\$1')\n}\n\n/**\n * A class used by the {@link Collection} class to build queries to be executed\n * against the collection's data. An instance of `Query` is returned by\n * {@link Collection#query}. Query instances are typically short-lived.\n *\n * ```javascript\n * import {Query} from 'js-data'\n * ```\n *\n * @class Query\n * @extends Component\n * @param {Collection} collection The collection on which this query operates.\n */\nexport default Component.extend({\n constructor: function Query (collection) {\n const self = this\n utils.classCallCheck(self, Query)\n\n /**\n * The {@link Collection} on which this query operates.\n *\n * @name Query#collection\n * @type {Collection}\n */\n self.collection = collection\n\n /**\n * The current data result of this query.\n *\n * @name Query#data\n * @type {Array}\n */\n self.data = null\n },\n\n /**\n * Find all entities between two boundaries.\n *\n * Get the users ages 18 to 30\n * ```js\n * const users = query.between(18, 30, { index: 'age' }).run()\n * ```\n * Same as above\n * ```js\n * const users = query.between([18], [30], { index: 'age' }).run()\n * ```\n *\n * @name Query#between\n * @method\n * @param {Array} leftKeys - Keys defining the left boundary.\n * @param {Array} rightKeys - Keys defining the right boundary.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] - Whether to include entities\n * on the left boundary.\n * @param {boolean} [opts.limit] - Limit the result to a certain number.\n * @param {boolean} [opts.offset] - The number of resulting entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n between (leftKeys, rightKeys, opts) {\n const self = this\n opts || (opts = {})\n if (self.data) {\n throw utils.err(`${DOMAIN}#between`)(500, 'Cannot access index')\n }\n self.data = self.collection.getIndex(opts.index).between(leftKeys, rightKeys, opts)\n return self\n },\n\n /**\n * The comparison function used by the Query class.\n *\n * @name Query#compare\n * @method\n * @param {Array} orderBy An orderBy clause used for sorting and sub-sorting.\n * @param {number} index The index of the current orderBy clause being used.\n * @param {*} a The first item in the comparison.\n * @param {*} b The second item in the comparison.\n * @return {number} -1 if `b` should preceed `a`. 0 if `a` and `b` are equal.\n * 1 if `a` should preceed `b`.\n */\n compare (orderBy, index, a, b) {\n const def = orderBy[index]\n let cA = utils.get(a, def[0])\n let cB = utils.get(b, def[0])\n if (cA && utils.isString(cA)) {\n cA = cA.toUpperCase()\n }\n if (cB && utils.isString(cB)) {\n cB = cB.toUpperCase()\n }\n if (a === undefined) {\n a = null\n }\n if (b === undefined) {\n b = null\n }\n if (def[1].toUpperCase() === 'DESC') {\n const temp = cB\n cB = cA\n cA = temp\n }\n if (cA < cB) {\n return -1\n } else if (cA > cB) {\n return 1\n } else {\n if (index < orderBy.length - 1) {\n return this.compare(orderBy, index + 1, a, b)\n } else {\n return 0\n }\n }\n },\n\n /**\n * Predicate evaluation function used by the Query class.\n *\n * @name Query#evaluate\n * @method\n * @param {*} value The value to evaluate.\n * @param {string} op The operator to use in this evaluation.\n * @param {*} predicate The predicate to use in this evaluation.\n * @return {boolean} Whether the value passed the evaluation or not.\n */\n evaluate (value, op, predicate) {\n const ops = this.constructor.ops\n if (ops[op]) {\n return ops[op](value, predicate)\n }\n if (op.indexOf('like') === 0) {\n return !utils.isNull(this.like(predicate, op.substr(4)).exec(value))\n } else if (op.indexOf('notLike') === 0) {\n return utils.isNull(this.like(predicate, op.substr(7)).exec(value))\n }\n },\n\n /**\n * Find the entity or entities that match the provided query or pass the\n * provided filter function.\n *\n * #### Example\n *\n * Get the draft posts created less than three months\n * ```js\n * const posts = query.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * }).run()\n * ```\n * Use a custom filter function\n * ```js\n * const posts = query.filter(function (post) {\n * return post.isReady()\n * }).run()\n * ```\n *\n * @name Query#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Function} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Query} A reference to itself for chaining.\n */\n filter (query, thisArg) {\n const self = this\n query || (query = {})\n self.getData()\n if (utils.isObject(query)) {\n let where = {}\n // Filter\n if (utils.isObject(query.where)) {\n where = query.where\n }\n utils.forOwn(query, function (value, key) {\n if (!(key in reserved) && !(key in where)) {\n where[key] = {\n '==': value\n }\n }\n })\n\n const fields = []\n const ops = []\n const predicates = []\n utils.forOwn(where, function (clause, field) {\n if (!utils.isObject(clause)) {\n clause = {\n '==': clause\n }\n }\n utils.forOwn(clause, function (expr, op) {\n fields.push(field)\n ops.push(op)\n predicates.push(expr)\n })\n })\n if (fields.length) {\n let i\n let len = fields.length\n self.data = self.data.filter(function (item) {\n let first = true\n let keep = true\n\n for (i = 0; i < len; i++) {\n let op = ops[i]\n const isOr = op.charAt(0) === '|'\n op = isOr ? op.substr(1) : op\n const expr = self.evaluate(utils.get(item, fields[i]), op, predicates[i])\n if (expr !== undefined) {\n keep = first ? expr : (isOr ? keep || expr : keep && expr)\n }\n first = false\n }\n return keep\n })\n }\n\n // Sort\n let orderBy = query.orderBy || query.sort\n\n if (utils.isString(orderBy)) {\n orderBy = [\n [orderBy, 'ASC']\n ]\n }\n if (!utils.isArray(orderBy)) {\n orderBy = null\n }\n\n // Apply 'orderBy'\n if (orderBy) {\n let index = 0\n orderBy.forEach(function (def, i) {\n if (utils.isString(def)) {\n orderBy[i] = [def, 'ASC']\n }\n })\n self.data.sort(function (a, b) {\n return self.compare(orderBy, index, a, b)\n })\n }\n\n // Skip\n if (utils.isNumber(query.skip)) {\n self.skip(query.skip)\n } else if (utils.isNumber(query.offset)) {\n self.skip(query.offset)\n }\n // Limit\n if (utils.isNumber(query.limit)) {\n self.limit(query.limit)\n }\n } else if (utils.isFunction(query)) {\n self.data = self.data.filter(query, thisArg)\n }\n return self\n },\n\n /**\n * Iterate over all entities.\n *\n * @name Query#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Query} A reference to itself for chaining.\n */\n forEach (forEachFn, thisArg) {\n this.getData().forEach(forEachFn, thisArg)\n return this\n },\n\n /**\n * Find the entity or entities that match the provided key.\n *\n * #### Example\n *\n * Get the entity whose primary key is 25\n * ```js\n * const entities = query.get(25).run()\n * ```\n * Same as above\n * ```js\n * const entities = query.get([25]).run()\n * ```\n * Get all users who are active and have the \"admin\" role\n * ```js\n * const activeAdmins = query.get(['active', 'admin'], {\n * index: 'activityAndRoles'\n * }).run()\n * ```\n * Get all entities that match a certain weather condition\n * ```js\n * const niceDays = query.get(['sunny', 'humid', 'calm'], {\n * index: 'weatherConditions'\n * }).run()\n * ```\n *\n * @name Query#get\n * @method\n * @param {Array} keyList - Key(s) defining the entity to retrieve. If\n * `keyList` is not an array (i.e. for a single-value key), it will be\n * wrapped in an array.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.string] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n get (keyList, opts) {\n const self = this\n keyList || (keyList = [])\n opts || (opts = {})\n if (self.data) {\n throw utils.err(`${DOMAIN}#get`)(500, INDEX_ERR)\n }\n if (keyList && !utils.isArray(keyList)) {\n keyList = [keyList]\n }\n if (!keyList.length) {\n self.getData()\n return self\n }\n self.data = self.collection.getIndex(opts.index).get(keyList)\n return self\n },\n\n /**\n * Find the entity or entities that match the provided keyLists.\n *\n * #### Example\n *\n * Get the posts where \"status\" is \"draft\" or \"inReview\"\n * ```js\n * const posts = query.getAll('draft', 'inReview', { index: 'status' }).run()\n * ```\n * Same as above\n * ```js\n * const posts = query.getAll(['draft'], ['inReview'], { index: 'status' }).run()\n * ```\n *\n * @name Query#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * entities matching each keyList will be retrieved. If no keyLists are\n * provided, all entities will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Query} A reference to itself for chaining.\n */\n getAll (...args) {\n const self = this\n let opts = {}\n if (self.data) {\n throw utils.err(`${DOMAIN}#getAll`)(500, INDEX_ERR)\n }\n if (!args.length || args.length === 1 && utils.isObject(args[0])) {\n self.getData()\n return self\n } else if (args.length && utils.isObject(args[args.length - 1])) {\n opts = args[args.length - 1]\n args.pop()\n }\n const collection = self.collection\n const index = collection.getIndex(opts.index)\n self.data = []\n args.forEach(function (keyList) {\n self.data = self.data.concat(index.get(keyList))\n })\n return self\n },\n\n /**\n * Return the current data result of this query.\n * @name Query#getData\n * @method\n * @return {Array} The data in this query.\n */\n getData () {\n const self = this\n if (!self.data) {\n self.data = self.collection.index.getAll()\n }\n return self.data\n },\n\n like (pattern, flags) {\n return new RegExp(`^${(escape(pattern).replace(percentRegExp, '.*').replace(underscoreRegExp, '.'))}$`, flags)\n },\n\n /**\n * Limit the result.\n *\n * #### Example\n *\n * Get only the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).limit(10).run()\n * ```\n *\n * @name Query#limit\n * @method\n * @param {number} num - The maximum number of entities to keep in the result.\n * @return {Query} A reference to itself for chaining.\n */\n limit (num) {\n if (!utils.isNumber(num)) {\n throw utils.err(`${DOMAIN}#limit`, 'num')(400, 'number', num)\n }\n const data = this.getData()\n this.data = data.slice(0, Math.min(data.length, num))\n return this\n },\n\n /**\n * Apply a mapping function to the result data.\n *\n * @name Query#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Query} A reference to itself for chaining.\n */\n map (mapFn, thisArg) {\n this.data = this.getData().map(mapFn, thisArg)\n return this\n },\n\n /**\n * Return the result of calling the specified function on each item in this\n * collection's main index.\n * @name Query#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Query} A reference to itself for chaining.\n */\n mapCall (funcName, ...args) {\n this.data = this.getData().map(function (item) {\n return item[funcName](...args)\n })\n return this\n },\n\n /**\n * Complete the execution of the query and return the resulting data.\n *\n * @name Query#run\n * @method\n * @return {Array} The result of executing this query.\n */\n run () {\n const data = this.data\n this.data = null\n return data\n },\n\n /**\n * Skip a number of results.\n *\n * #### Example\n *\n * Get all but the first 10 draft posts\n * ```js\n * const posts = query.get('draft', { index: 'status' }).skip(10).run()\n * ```\n *\n * @name Query#skip\n * @method\n * @param {number} num - The number of entities to skip.\n * @return {Query} A reference to itself for chaining.\n */\n skip (num) {\n if (!utils.isNumber(num)) {\n throw utils.err(`${DOMAIN}#skip`, 'num')(400, 'number', num)\n }\n const data = this.getData()\n if (num < data.length) {\n this.data = data.slice(num)\n } else {\n this.data = []\n }\n return this\n }\n}, {\n /**\n * TODO\n *\n * @name Query.ops\n * @type {Object}\n */\n ops: {\n '==': function (value, predicate) {\n return value == predicate // eslint-disable-line\n },\n '===': function (value, predicate) {\n return value === predicate\n },\n '!=': function (value, predicate) {\n return value != predicate // eslint-disable-line\n },\n '!==': function (value, predicate) {\n return value !== predicate\n },\n '>': function (value, predicate) {\n return value > predicate\n },\n '>=': function (value, predicate) {\n return value >= predicate\n },\n '<': function (value, predicate) {\n return value < predicate\n },\n '<=': function (value, predicate) {\n return value <= predicate\n },\n 'isectEmpty': function (value, predicate) {\n return !utils.intersection((value || []), (predicate || [])).length\n },\n 'isectNotEmpty': function (value, predicate) {\n return utils.intersection((value || []), (predicate || [])).length\n },\n 'in': function (value, predicate) {\n return predicate.indexOf(value) !== -1\n },\n 'notIn': function (value, predicate) {\n return predicate.indexOf(value) === -1\n },\n 'contains': function (value, predicate) {\n return (value || []).indexOf(predicate) !== -1\n },\n 'notContains': function (value, predicate) {\n return (value || []).indexOf(predicate) === -1\n }\n }\n})\n","export function sort (a, b, hashCode) {\n // Short-curcuit comparison if a and b are strictly equal\n // This is absolutely necessary for indexed objects that\n // don't have the idAttribute field\n if (a === b) {\n return 0\n }\n if (hashCode) {\n a = hashCode(a)\n b = hashCode(b)\n }\n if (a === null && b === null) {\n return 0\n }\n\n if (a === null) {\n return -1\n }\n\n if (b === null) {\n return 1\n }\n\n if (a < b) {\n return -1\n }\n\n if (a > b) {\n return 1\n }\n\n return 0\n}\n\nexport function insertAt (array, index, value) {\n array.splice(index, 0, value)\n return array\n}\n\nexport function removeAt (array, index) {\n array.splice(index, 1)\n return array\n}\n\nexport function binarySearch (array, value, field) {\n let lo = 0\n let hi = array.length\n let compared\n let mid\n\n while (lo < hi) {\n mid = ((lo + hi) / 2) | 0\n compared = sort(value, array[mid], field)\n if (compared === 0) {\n return {\n found: true,\n index: mid\n }\n } else if (compared < 0) {\n hi = mid\n } else {\n lo = mid + 1\n }\n }\n\n return {\n found: false,\n index: hi\n }\n}\n","// Copyright (c) 2015, InternalFX.\n\n// Permission to use, copy, modify, and/or distribute this software for any purpose with or\n// without fee is hereby granted, provided that the above copyright notice and this permission\n// notice appear in all copies.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO\n// THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT\n// SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR\n// ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE\n// USE OR PERFORMANCE OF THIS SOFTWARE.\n\n// Modifications\n// Copyright 2015-2016 Jason Dobry\n//\n// Summary of modifications:\n// Converted to ES6 Class syntax\n// Reworked dependencies so as to re-use code already in js-data\nimport utils from '../../src/utils'\nimport {binarySearch, insertAt, removeAt} from './_utils'\n\nexport default function Index (fieldList, opts) {\n utils.classCallCheck(this, Index)\n fieldList || (fieldList = [])\n\n if (!utils.isArray(fieldList)) {\n throw new Error('fieldList must be an array.')\n }\n\n opts || (opts = {})\n this.fieldList = fieldList\n this.fieldGetter = opts.fieldGetter\n this.hashCode = opts.hashCode\n this.isIndex = true\n this.keys = []\n this.values = []\n}\n\nutils.addHiddenPropsToTarget(Index.prototype, {\n 'set' (keyList, value) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n let dataLocation = binarySearch(this.values[pos.index], value, this.hashCode)\n if (!dataLocation.found) {\n insertAt(this.values[pos.index], dataLocation.index, value)\n }\n } else {\n insertAt(this.keys, pos.index, key)\n insertAt(this.values, pos.index, [value])\n }\n } else {\n if (pos.found) {\n this.values[pos.index].set(keyList, value)\n } else {\n insertAt(this.keys, pos.index, key)\n let newIndex = new Index([], { hashCode: this.hashCode })\n newIndex.set(keyList, value)\n insertAt(this.values, pos.index, newIndex)\n }\n }\n },\n\n 'get' (keyList) {\n if (!utils.isArray(keyList)) {\n keyList = [keyList]\n }\n\n let key = keyList.shift() || null\n let pos = binarySearch(this.keys, key)\n\n if (keyList.length === 0) {\n if (pos.found) {\n if (this.values[pos.index].isIndex) {\n return this.values[pos.index].getAll()\n } else {\n return this.values[pos.index]\n }\n } else {\n return []\n }\n } else {\n if (pos.found) {\n return this.values[pos.index].get(keyList)\n } else {\n return []\n }\n }\n },\n\n getAll () {\n let results = []\n this.values.forEach(function (value) {\n if (value.isIndex) {\n results = results.concat(value.getAll())\n } else {\n results = results.concat(value)\n }\n })\n return results\n },\n\n visitAll (cb, thisArg) {\n this.values.forEach(function (value) {\n if (value.isIndex) {\n value.visitAll(cb, thisArg)\n } else {\n value.forEach(cb, thisArg)\n }\n })\n },\n\n between (leftKeys, rightKeys, opts) {\n opts || (opts = {})\n if (!utils.isArray(leftKeys)) {\n leftKeys = [leftKeys]\n }\n if (!utils.isArray(rightKeys)) {\n rightKeys = [rightKeys]\n }\n utils.fillIn(opts, {\n leftInclusive: true,\n rightInclusive: false,\n limit: undefined,\n offset: 0\n })\n\n let results = this._between(leftKeys, rightKeys, opts)\n\n if (opts.limit) {\n return results.slice(opts.offset, opts.limit + opts.offset)\n } else {\n return results.slice(opts.offset)\n }\n },\n\n _between (leftKeys, rightKeys, opts) {\n let results = []\n\n let leftKey = leftKeys.shift()\n let rightKey = rightKeys.shift()\n\n let pos\n\n if (leftKey !== undefined) {\n pos = binarySearch(this.keys, leftKey)\n } else {\n pos = {\n found: false,\n index: 0\n }\n }\n\n if (leftKeys.length === 0) {\n if (pos.found && opts.leftInclusive === false) {\n pos.index += 1\n }\n\n for (let i = pos.index; i < this.keys.length; i += 1) {\n if (rightKey !== undefined) {\n if (opts.rightInclusive) {\n if (this.keys[i] > rightKey) { break }\n } else {\n if (this.keys[i] >= rightKey) { break }\n }\n }\n\n if (this.values[i].isIndex) {\n results = results.concat(this.values[i].getAll())\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n } else {\n for (let i = pos.index; i < this.keys.length; i += 1) {\n let currKey = this.keys[i]\n if (currKey > rightKey) { break }\n\n if (this.values[i].isIndex) {\n if (currKey === leftKey) {\n results = results.concat(this.values[i]._between(utils.copy(leftKeys), rightKeys.map(function () { return undefined }), opts))\n } else if (currKey === rightKey) {\n results = results.concat(this.values[i]._between(leftKeys.map(function () { return undefined }), utils.copy(rightKeys), opts))\n } else {\n results = results.concat(this.values[i].getAll())\n }\n } else {\n results = results.concat(this.values[i])\n }\n\n if (opts.limit) {\n if (results.length >= (opts.limit + opts.offset)) {\n break\n }\n }\n }\n }\n\n if (opts.limit) {\n return results.slice(0, opts.limit + opts.offset)\n } else {\n return results\n }\n },\n\n peek () {\n if (this.values.length) {\n if (this.values[0].isIndex) {\n return this.values[0].peek()\n } else {\n return this.values[0]\n }\n }\n return []\n },\n\n clear () {\n this.keys = []\n this.values = []\n },\n\n insertRecord (data) {\n let keyList = this.fieldList.map(function (field) {\n if (utils.isFunction(field)) {\n return field(data) || null\n } else {\n return data[field] || null\n }\n })\n this.set(keyList, data)\n },\n\n removeRecord (data) {\n let removed\n this.values.forEach((value, i) => {\n if (value.isIndex) {\n if (value.removeRecord(data)) {\n if (value.keys.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n } else {\n const dataLocation = binarySearch(value, data, this.hashCode)\n if (dataLocation.found) {\n removeAt(value, dataLocation.index)\n if (value.length === 0) {\n removeAt(this.keys, i)\n removeAt(this.values, i)\n }\n removed = true\n return false\n }\n }\n })\n return removed ? data : undefined\n },\n\n updateRecord (data) {\n this.removeRecord(data)\n this.insertRecord(data)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Query from './Query'\nimport Index from '../lib/mindex/index'\n\nconst DOMAIN = 'Collection'\n\nconst COLLECTION_DEFAULTS = {\n /**\n * Field to be used as the unique identifier for records in this collection.\n * Defaults to `\"id\"` unless {@link Collection#mapper} is set, in which case\n * this will default to {@link Mapper#idAttribute}.\n *\n * @name Collection#idAttribute\n * @type {string}\n * @default \"id\"\n */\n idAttribute: 'id',\n\n /**\n * What to do when inserting a record into this Collection that shares a\n * primary key with a record already in this Collection.\n *\n * Possible values:\n * - merge\n * - replace\n *\n * Merge:\n *\n * Recursively shallow copy properties from the new record onto the existing\n * record.\n *\n * Replace:\n *\n * Shallow copy top-level properties from the new record onto the existing\n * record. Any top-level own properties of the existing record that are _not_\n * on the new record will be removed.\n *\n * @name Collection#onConflict\n * @type {string}\n * @default \"merge\"\n */\n onConflict: 'merge'\n}\n\n/**\n * ```javascript\n * import {Collection} from 'js-data'\n * ```\n *\n * An ordered set of {@link Record} instances.\n *\n * @example\n * import {Collection, Record} from 'js-data'\n * const user1 = new Record({ id: 1 })\n * const user2 = new Record({ id: 2 })\n * const UserCollection = new Collection([user1, user2])\n * UserCollection.get(1) === user1 // true\n *\n * @class Collection\n * @extends Component\n * @param {Array} [records] Initial set of records to insert into the\n * collection.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.idAttribute] See {@link Collection#idAttribute}.\n * @param {string} [opts.onConflict=\"merge\"] See {@link Collection#onConflict}.\n * @param {string} [opts.mapper] See {@link Collection#mapper}.\n */\nexport default Component.extend({\n constructor: function Collection (records, opts) {\n const self = this\n utils.classCallCheck(self, Collection)\n Collection.__super__.call(self)\n\n if (records && !utils.isArray(records)) {\n opts = records\n records = []\n }\n if (utils.isString(opts)) {\n opts = { idAttribute: opts }\n }\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n /**\n * Default Mapper for this collection. Optional. If a Mapper is provided, then\n * the collection will use the {@link Mapper#idAttribute} setting, and will\n * wrap records in {@link Mapper#recordClass}.\n *\n * @example\n * import {Collection, Mapper} from 'js-data'\n *\n * class MyMapperClass extends Mapper {\n * foo () { return 'bar' }\n * }\n * const myMapper = new MyMapperClass()\n * const collection = new Collection(null, { mapper: myMapper })\n *\n * @name Collection#mapper\n * @type {Mapper}\n * @default null\n */\n Object.defineProperty(self, 'mapper', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n utils.fillIn(self, utils.copy(COLLECTION_DEFAULTS))\n\n const idAttribute = self.recordId()\n\n Object.defineProperties(self, {\n /**\n * The main index, which uses @{link Collection#recordId} as the key.\n *\n * @name Collection#index\n * @type {Index}\n */\n index: {\n value: new Index([idAttribute], {\n hashCode (obj) {\n return utils.get(obj, idAttribute)\n }\n })\n },\n\n /**\n * Object that holds the secondary indexes of this collection.\n *\n * @name Collection#indexes\n * @type {Object.}\n */\n indexes: {\n value: {}\n }\n })\n\n // Insert initial data into the collection\n if (records) {\n self.add(records)\n }\n },\n\n /**\n * Used to bind to events emitted by records in this Collection.\n *\n * @name Collection#_onRecordEvent\n * @method\n * @private\n * @param {...*} [arg] Args passed to {@link Collection#emit}.\n */\n _onRecordEvent (...args) {\n this.emit(...args)\n },\n\n /**\n * Insert the provided record or records.\n *\n * If a record is already in the collection then the provided record will\n * either merge with or replace the existing record based on the value of the\n * `onConflict` option.\n *\n * The collection's secondary indexes will be updated as each record is\n * visited.\n *\n * @name Collection#add\n * @method\n * @param {(Object|Object[]|Record|Record[])} data The record or records to insert.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.onConflict] What to do when a record is already in\n * the collection. Possible values are `merge` or `replace`.\n * @return {(Object|Object[]|Record|Record[])} The added record or records.\n */\n add (records, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n\n // Fill in \"opts\" with the Collection's configuration\n utils._(opts, self)\n records = self.beforeAdd(records, opts) || records\n\n // Track whether just one record or an array of records is being inserted\n let singular = false\n const idAttribute = self.recordId()\n if (!utils.isArray(records)) {\n if (utils.isObject(records)) {\n records = [records]\n singular = true\n } else {\n throw utils.err(`${DOMAIN}#add`, 'records')(400, 'object or array', records)\n }\n }\n\n // Map the provided records to existing records.\n // New records will be inserted. If any records map to existing records,\n // they will be merged into the existing records according to the onConflict\n // option.\n records = records.map(function (record) {\n let id = self.recordId(record)\n if (!utils.isSorN(id)) {\n throw utils.err(`${DOMAIN}#add`, `record.${idAttribute}`)(400, 'string or number', id)\n }\n // Grab existing record if there is one\n const existing = self.get(id)\n // If the currently visited record is just a reference to an existing\n // record, then there is nothing to be done. Exit early.\n if (record === existing) {\n return existing\n }\n\n if (existing) {\n // Here, the currently visited record corresponds to a record already\n // in the collection, so we need to merge them\n const onConflict = opts.onConflict || self.onConflict\n if (onConflict === 'merge') {\n utils.deepMixIn(existing, record)\n } else if (onConflict === 'replace') {\n utils.forOwn(existing, (value, key) => {\n if (key !== idAttribute && !record.hasOwnProperty(key)) {\n delete existing[key]\n }\n })\n existing.set(record)\n } else {\n throw utils.err(`${DOMAIN}#add`, 'opts.onConflict')(400, 'one of (merge, replace)', onConflict, true)\n }\n record = existing\n // Update all indexes in the collection\n self.updateIndexes(record)\n } else {\n // Here, the currently visted record does not correspond to any record\n // in the collection, so (optionally) instantiate this record and insert\n // it into the collection\n record = self.mapper ? self.mapper.createRecord(record, opts) : record\n self.index.insertRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.insertRecord(record)\n })\n if (record && utils.isFunction(record.on)) {\n record.on('all', self._onRecordEvent, self)\n }\n }\n return record\n })\n // Finally, return the inserted data\n const result = singular ? records[0] : records\n // TODO: Make this more performant (batch events?)\n self.emit('add', result)\n return self.afterAdd(records, opts, result) || result\n },\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then {@link Collection#add} will return that same value.\n *\n * @name Collection#method\n * @method\n * @param {(Object|Object[]|Record|Record[])} result The record or records\n * that were added to this Collection by {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n afterAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}. If this method returns\n * a value then {@link Collection#remove} will return that same value.\n *\n * @name Collection#afterRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n * @param {Object} record The result that will be returned by {@link Collection#remove}.\n */\n afterRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}. If this method\n * returns a value then {@link Collection#removeAll} will return that same\n * value.\n *\n * @name Collection#afterRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n * @param {Object} records The result that will be returned by {@link Collection#removeAll}.\n */\n afterRemoveAll () {},\n\n /**\n * Lifecycle hook called by {@link Collection#add}. If this method returns a\n * value then the `records` argument in {@link Collection#add} will be\n * re-assigned to the returned value.\n *\n * @name Collection#beforeAdd\n * @method\n * @param {(Object|Object[]|Record|Record[])} records The `records` argument passed to {@link Collection#add}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#add}.\n */\n beforeAdd () {},\n\n /**\n * Lifecycle hook called by {@link Collection#remove}.\n *\n * @name Collection#beforeRemove\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Collection#remove}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#remove}.\n */\n beforeRemove () {},\n\n /**\n * Lifecycle hook called by {@link Collection#removeAll}.\n *\n * @name Collection#beforeRemoveAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Collection#removeAll}.\n * @param {Object} opts The `opts` argument passed to {@link Collection#removeAll}.\n */\n beforeRemoveAll () {},\n\n /**\n * Find all records between two boundaries.\n *\n * Shortcut for `collection.query().between(18, 30, { index: 'age' }).run()`\n *\n * @example Get all users ages 18 to 30\n * const users = collection.between(18, 30, { index: 'age' })\n *\n * @example Same as above\n * const users = collection.between([18], [30], { index: 'age' })\n *\n * @name Collection#between\n * @method\n * @param {Array} leftKeys Keys defining the left boundary.\n * @param {Array} rightKeys Keys defining the right boundary.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.index] Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @param {boolean} [opts.leftInclusive=true] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.rightInclusive=false] Whether to include records\n * on the left boundary.\n * @param {boolean} [opts.limit] Limit the result to a certain number.\n * @param {boolean} [opts.offset] The number of resulting records to skip.\n * @return {Array} The result.\n */\n between (leftKeys, rightKeys, opts) {\n return this.query().between(leftKeys, rightKeys, opts).run()\n },\n\n /**\n * Create a new secondary index on the contents of the collection.\n *\n * @example Index users by age\n * collection.createIndex('age')\n *\n * @example Index users by status and role\n * collection.createIndex('statusAndRole', ['status', 'role'])\n *\n * @name Collection#createIndex\n * @method\n * @param {string} name - The name of the new secondary index.\n * @param {string[]} [fieldList] - Array of field names to use as the key or\n * compound key of the new secondary index. If no fieldList is provided, then\n * the name will also be the field that is used to index the collection.\n * @return {Collection} A reference to itself for chaining.\n */\n createIndex (name, fieldList, opts) {\n const self = this\n if (utils.isString(name) && fieldList === undefined) {\n fieldList = [name]\n }\n opts || (opts = {})\n opts.hashCode = opts.hashCode || function (obj) {\n return self.recordId(obj)\n }\n const index = self.indexes[name] = new Index(fieldList, opts)\n self.index.visitAll(index.insertRecord, index)\n return self\n },\n\n /**\n * Find the record or records that match the provided query or pass the\n * provided filter function.\n *\n * Shortcut for `collection.query().filter(queryOrFn[, thisArg]).run()`\n *\n * @example Get the draft posts created less than three months\n * const posts = collection.filter({\n * where: {\n * status: {\n * '==': 'draft'\n * },\n * created_at_timestamp: {\n * '>=': (new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 3)) // 3 months ago\n * }\n * }\n * })\n *\n * @example Use a custom filter function\n * const posts = collection.filter(function (post) {\n * return post.isReady()\n * })\n *\n * @name Collection#filter\n * @method\n * @param {(Object|Function)} [queryOrFn={}] - Selection query or filter\n * function.\n * @param {Object} [thisArg] - Context to which to bind `queryOrFn` if\n * `queryOrFn` is a function.\n * @return {Array} The result.\n */\n filter (query, thisArg) {\n return this.query().filter(query, thisArg).run()\n },\n\n /**\n * Iterate over all records.\n *\n * @example\n * collection.forEach(function (record) {\n * // do something\n * })\n *\n * @name Collection#forEach\n * @method\n * @param {Function} forEachFn - Iteration function.\n * @param {*} [thisArg] - Context to which to bind `forEachFn`.\n * @return {Array} The result.\n */\n forEach (cb, thisArg) {\n this.index.visitAll(cb, thisArg)\n },\n\n /**\n * Get the record with the given id.\n *\n * @name Collection#get\n * @method\n * @param {(string|number)} id - The primary key of the record to get.\n * @return {(Object|Record)} The record with the given id.\n */\n get (id) {\n const instances = this.query().get(id).run()\n return instances.length ? instances[0] : undefined\n },\n\n /**\n * Find the record or records that match the provided keyLists.\n *\n * Shortcut for `collection.query().getAll(keyList1, keyList2, ...).run()`\n *\n * @example Get the posts where \"status\" is \"draft\" or \"inReview\"\n * const posts = collection.getAll('draft', 'inReview', { index: 'status' })\n *\n * @example Same as above\n * const posts = collection.getAll(['draft'], ['inReview'], { index: 'status' })\n *\n * @name Collection#getAll\n * @method\n * @param {...Array} [keyList] - Provide one or more keyLists, and all\n * records matching each keyList will be retrieved. If no keyLists are\n * provided, all records will be returned.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] - Name of the secondary index to use in the\n * query. If no index is specified, the main index is used.\n * @return {Array} The result.\n */\n getAll (...args) {\n return this.query().getAll(...args).run()\n },\n\n /**\n * Return the index with the given name. If no name is provided, return the\n * main index. Throws an error if the specified index does not exist.\n *\n * @name Collection#getIndex\n * @method\n * @param {string} [name] The name of the index to retrieve.\n */\n getIndex (name) {\n const index = name ? this.indexes[name] : this.index\n if (!index) {\n throw utils.err(`${DOMAIN}#getIndex`, name)(404, 'index')\n }\n return index\n },\n\n /**\n * Limit the result.\n *\n * Shortcut for `collection.query().limit(maximumNumber).run()`\n *\n * @example\n * const posts = collection.limit(10)\n *\n * @name Collection#limit\n * @method\n * @param {number} num - The maximum number of records to keep in the result.\n * @return {Array} The result.\n */\n limit (num) {\n return this.query().limit(num).run()\n },\n\n /**\n * Apply a mapping function to all records.\n *\n * @example\n * const names = collection.map(function (user) {\n * return user.name\n * })\n *\n * @name Collection#map\n * @method\n * @param {Function} mapFn - Mapping function.\n * @param {*} [thisArg] - Context to which to bind `mapFn`.\n * @return {Array} The result of the mapping.\n */\n map (cb, thisArg) {\n const data = []\n this.index.visitAll(function (value) {\n data.push(cb.call(thisArg, value))\n })\n return data\n },\n\n /**\n * Return the result of calling the specified function on each record in this\n * collection's main index.\n *\n * @name Collection#mapCall\n * @method\n * @param {string} funcName - Name of function to call\n * @parama {...*} [args] - Remaining arguments to be passed to the function.\n * @return {Array} The result.\n */\n mapCall (funcName, ...args) {\n const data = []\n this.index.visitAll(function (record) {\n data.push(record[funcName](...args))\n })\n return data\n },\n\n /**\n * Return the primary key of the given, or if no record is provided, return the\n * name of the field that holds the primary key of records in this Collection.\n *\n * @name Collection#recordId\n * @method\n * @param {(Object|Record)} [record] The record whose primary key is to be\n * returned.\n * @return {(string|number)} Primary key or name of field that holds primary\n * key.\n */\n recordId (record) {\n const self = this\n if (record) {\n return utils.get(record, self.recordId())\n }\n return self.mapper ? self.mapper.idAttribute : self.idAttribute\n },\n\n /**\n * Create a new query to be executed against the contents of the collection.\n * The result will be all or a subset of the contents of the collection.\n *\n * @example Grab page 2 of users between ages 18 and 30\n * collection.query()\n * .between(18, 30, { index: 'age' }) // between ages 18 and 30\n * .skip(10) // second page\n * .limit(10) // page size\n * .run()\n *\n * @name Collection#query\n * @method\n * @return {Query} New query object.\n */\n query () {\n return new Query(this)\n },\n\n /**\n * Reduce the data in the collection to a single value and return the result.\n *\n * @example\n * const totalVotes = collection.reduce(function (prev, record) {\n * return prev + record.upVotes + record.downVotes\n * }, 0)\n *\n * @name Collection#reduce\n * @method\n * @param {Function} cb - Reduction callback.\n * @param {*} initialValue - Initial value of the reduction.\n * @return {*} The result.\n */\n reduce (cb, initialValue) {\n const data = this.getAll()\n return data.reduce(cb, initialValue)\n },\n\n /**\n * Remove the record with the given id from this Collection.\n *\n * @name Collection#remove\n * @method\n * @param {(string|number)} id - The primary key of the record to be removed.\n * @param {Object} [opts] - Configuration options.\n * @return {Object|Record} The removed record, if any.\n */\n remove (id, opts) {\n const self = this\n\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemove(id, opts)\n const record = self.get(id)\n\n // The record is in the collection, remove it\n if (record) {\n self.index.removeRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.removeRecord(record)\n })\n if (record && utils.isFunction(record.off)) {\n record.off('all', self._onRecordEvent, self)\n self.emit('remove', record)\n }\n }\n return self.afterRemove(id, opts, record) || record\n },\n\n /**\n * Remove the record selected by \"query\" from this collection.\n *\n * @name Collection#removeAll\n * @method\n * @param {Object} [query={}] - Selection query.\n * @param {Object} [query.where] - Filtering criteria.\n * @param {number} [query.skip] - Number to skip.\n * @param {number} [query.limit] - Number to limit to.\n * @param {Array} [query.orderBy] - Sorting criteria.\n * @param {Object} [opts] - Configuration options.\n * @return {(Object[]|Record[])} The removed records, if any.\n */\n removeAll (query, opts) {\n const self = this\n // Default values for arguments\n opts || (opts = {})\n self.beforeRemoveAll(query, opts)\n const records = self.filter(query)\n\n // Remove each selected record from the collection\n records.forEach(function (item) {\n self.remove(self.recordId(item), opts)\n })\n return self.afterRemoveAll(query, opts, records) || records\n },\n\n /**\n * Skip a number of results.\n *\n * Shortcut for `collection.query().skip(numberToSkip).run()`\n *\n * @example\n * const posts = collection.skip(10)\n *\n * @name Collection#skip\n * @method\n * @param {number} num - The number of records to skip.\n * @return {Array} The result.\n */\n skip (num) {\n return this.query().skip(num).run()\n },\n\n /**\n * Return the plain JSON representation of all items in this collection.\n * Assumes records in this collection have a toJSON method.\n *\n * @name Collection#toJSON\n * @method\n * @param {Object} [opts] - Configuration options.\n * @param {string[]} [opts.with] - Array of relation names or relation fields\n * to include in the representation.\n * @return {Array} The records.\n */\n toJSON (opts) {\n return this.mapCall('toJSON', opts)\n },\n\n /**\n * Update a record's position in a single index of this collection. See\n * {@link Collection#updateIndexes} to update a record's position in all\n * indexes at once.\n *\n * @name Collection#updateIndex\n * @method\n * @param {Object} record - The record to update.\n * @param {Object} [opts] - Configuration options.\n * @param {string} [opts.index] The index in which to update the record's\n * position. If you don't specify an index then the record will be updated\n * in the main index.\n */\n updateIndex (record, opts) {\n opts || (opts = {})\n this.getIndex(opts.index).updateRecord(record)\n },\n\n /**\n * TODO\n *\n * @name Collection#updateIndexes\n * @method\n * @param {Object} record - TODO\n * @param {Object} [opts] - Configuration options.\n */\n updateIndexes (record) {\n const self = this\n self.index.updateRecord(record)\n utils.forOwn(self.indexes, function (index, name) {\n index.updateRecord(record)\n })\n }\n})\n","import utils from './utils'\n\nexport const belongsToType = 'belongsTo'\nexport const hasManyType = 'hasMany'\nexport const hasOneType = 'hasOne'\n\nconst DOMAIN = 'Relation'\n\nfunction Relation (related, opts) {\n const self = this\n const DOMAIN_ERR = `new ${DOMAIN}`\n\n opts || (opts = {})\n\n const localField = opts.localField\n if (!localField) {\n throw utils.err(DOMAIN_ERR, 'opts.localField')(400, 'string', localField)\n }\n\n const foreignKey = opts.foreignKey = opts.foreignKey || opts.localKey\n if (!foreignKey && (opts.type === belongsToType || opts.type === hasOneType)) {\n throw utils.err(DOMAIN_ERR, 'opts.foreignKey')(400, 'string', foreignKey)\n }\n const localKeys = opts.localKeys\n const foreignKeys = opts.foreignKeys\n if (!foreignKey && !localKeys && !foreignKeys && opts.type === hasManyType) {\n throw utils.err(DOMAIN_ERR, 'opts.')(400, 'string', foreignKey)\n }\n\n if (utils.isString(related)) {\n opts.relation = related\n if (!utils.isFunction(opts.getRelation)) {\n throw utils.err(DOMAIN_ERR, 'opts.getRelation')(400, 'function', opts.getRelation)\n }\n } else if (related) {\n opts.relation = related.name\n Object.defineProperty(self, 'relatedMapper', {\n value: related\n })\n } else {\n throw utils.err(DOMAIN_ERR, 'related')(400, 'Mapper or string', related)\n }\n\n Object.defineProperty(self, 'inverse', {\n value: undefined,\n writable: true\n })\n\n utils.fillIn(self, opts)\n}\n\nutils.addHiddenPropsToTarget(Relation.prototype, {\n getRelation () {\n return this.relatedMapper\n },\n getForeignKey (record) {\n if (this.type === belongsToType) {\n return utils.get(record, this.foreignKey)\n }\n return utils.get(record, this.mapper.idAttribute)\n },\n setForeignKey (record, relatedRecord) {\n const self = this\n if (!record || !relatedRecord) {\n return\n }\n if (self.type === belongsToType) {\n utils.set(record, self.foreignKey, utils.get(relatedRecord, self.getRelation().idAttribute))\n } else {\n const idAttribute = self.mapper.idAttribute\n if (utils.isArray(relatedRecord)) {\n relatedRecord.forEach(function (relatedRecordItem) {\n utils.set(relatedRecordItem, self.foreignKey, utils.get(record, idAttribute))\n })\n } else {\n utils.set(relatedRecord, self.foreignKey, utils.get(record, idAttribute))\n }\n }\n },\n getLocalField (record) {\n return utils.get(record, this.localField)\n },\n setLocalField (record, data) {\n return utils.set(record, this.localField, data)\n },\n getInverse (mapper) {\n const self = this\n if (self.inverse) {\n return self.inverse\n }\n self.getRelation().relationList.forEach(function (def) {\n if (def.getRelation() === mapper) {\n if (def.foreignKey && def.foreignKey !== self.foreignKey) {\n return\n }\n self.inverse = def\n return false\n }\n })\n return self.inverse\n }\n})\n\nconst relatedTo = function (mapper, related, opts) {\n opts.name = mapper.name\n const relation = new Relation(related, opts)\n Object.defineProperty(relation, 'mapper', {\n value: mapper\n })\n\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n mapper.relationFields || Object.defineProperty(mapper, 'relationFields', { value: [] })\n mapper.relationList.push(relation)\n mapper.relationFields.push(relation.localField)\n}\n\n/**\n * TODO\n *\n * @name module:js-data.belongsTo\n * @method\n * @param {Mapper} related The relation the target belongs to.\n * @param {Object} opts Configuration options.\n * @param {string} opts.foreignKey The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const belongsTo = function (related, opts) {\n opts || (opts = {})\n opts.type = belongsToType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasMany\n * @method\n * @param {Mapper} related The relation of which the target has many.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasMany = function (related, opts) {\n opts || (opts = {})\n opts.type = hasManyType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name module:js-data.hasOne\n * @method\n * @param {Mapper} related The relation of which the target has one.\n * @param {Object} opts Configuration options.\n * @param {string} [opts.foreignKey] The field that holds the primary key of the\n * related record.\n * @param {string} opts.localField The field that holds a reference to the\n * related record object.\n * @return {Function} Invocation function, which accepts the target as the only\n * parameter.\n */\nexport const hasOne = function (related, opts) {\n opts || (opts = {})\n opts.type = hasOneType\n return function (target) {\n relatedTo(target, related, opts)\n }\n}\n","import utils from './utils'\nimport Component from './Component'\n\nconst DOMAIN = 'Record'\n\nconst superMethod = function (mapper, name) {\n const store = mapper.datastore\n if (store && store[name]) {\n return function (...args) {\n return store[name](mapper.name, ...args)\n }\n }\n return mapper[name].bind(mapper)\n}\n\n/**\n * js-data's Record class.\n *\n * ```javascript\n * import {Record} from 'js-data'\n * ```\n *\n * @class Record\n * @extends Component\n * @param {Object} [props] The initial properties of the new Record instance.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation on the\n * initial properties.\n */\nconst Record = Component.extend({\n constructor: function Record (props, opts) {\n const self = this\n utils.classCallCheck(self, Record)\n\n props || (props = {})\n opts || (opts = {})\n const _props = {}\n Object.defineProperties(self, {\n _get: { value (key) { return utils.get(_props, key) } },\n _set: { value (key, value) { return utils.set(_props, key, value) } },\n _unset: { value (key) { return utils.unset(_props, key) } }\n })\n const _set = self._set\n // TODO: Optimize these strings\n _set('creating', true)\n if (opts.noValidate) {\n _set('noValidate', true)\n }\n utils.fillIn(self, props)\n _set('creating', false)\n _set('noValidate', false)\n _set('previous', utils.copy(props))\n },\n\n /**\n * TODO\n *\n * @name Record#_mapper\n * @method\n * @ignore\n */\n _mapper () {\n const self = this\n const mapper = self.constructor.mapper\n if (!mapper) {\n throw utils.err(`${DOMAIN}#_mapper`, '')(404, 'mapper')\n }\n return mapper\n },\n\n /**\n * TODO\n *\n * @name Record#afterLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n afterLoadRelations () {},\n\n /**\n * TODO\n *\n * @name Record#beforeLoadRelations\n * @method\n * @param {string[]} relations TODO\n * @param {Object} opts TODO\n */\n beforeLoadRelations () {},\n\n /**\n * Return changes to this record since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#changes\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n changes (opts) {\n const self = this\n opts || (opts = {})\n return utils.diffObjects(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#commit\n * @method\n */\n commit () {\n const self = this\n self._set('changed') // unset\n self._set('previous', utils.copy(self))\n return self\n },\n\n /**\n * Call {@link Mapper#destroy} using this record's primary key.\n *\n * @name Record#destroy\n * @method\n * @param {Object} [opts] Configuration options passed to {@link Mapper#destroy}.\n * @return {Promise} The result of calling {@link Mapper#destroy}.\n */\n destroy (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n return superMethod(mapper, 'destroy')(utils.get(self, mapper.idAttribute), opts)\n },\n\n /**\n * Return the value at the given path for this instance.\n *\n * @name Record#get\n * @method\n * @param {string} key - Path of value to retrieve.\n * @return {*} Value at path.\n */\n 'get' (key) {\n return utils.get(this, key)\n },\n\n /**\n * Return whether this record has changed since it was instantiated or\n * {@link Record#commit} was called.\n *\n * @name Record#hasChanges\n * @method\n * @param [opts] Configuration options.\n * @param {Function} [opts.equalsFn] Equality function. Default uses `===`.\n * @param {Array} [opts.ignore] Array of strings or RegExp of fields to ignore.\n */\n hasChanges (opts) {\n const self = this\n const quickHasChanges = !!(self._get('changed') || []).length\n return quickHasChanges || utils.areDifferent(self, self._get('previous'), opts)\n },\n\n /**\n * TODO\n *\n * @name Record#hashCode\n * @method\n */\n hashCode () {\n const self = this\n return utils.get(self, self._mapper().idAttribute)\n },\n\n isValid (opts) {\n const self = this\n return !self._mapper().validate(self, opts)\n },\n\n /**\n * TODO\n *\n * @name Record#loadRelations\n * @method\n * @param {string[]} [relations] TODO\n * @param {Object} [opts] TODO\n */\n loadRelations (relations, opts) {\n let op\n const self = this\n const mapper = self._mapper()\n\n // Default values for arguments\n relations || (relations = [])\n if (utils.isString(relations)) {\n relations = [relations]\n }\n opts || (opts = {})\n opts.with = relations\n\n // Fill in \"opts\" with the Model's configuration\n utils._(opts, mapper)\n opts.adapter = mapper.getAdapterName(opts)\n\n // beforeLoadRelations lifecycle hook\n op = opts.op = 'beforeLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n // Now delegate to the adapter\n op = opts.op = 'loadRelations'\n mapper.dbg(op, self, relations, opts)\n let tasks = []\n let task\n utils.forEachRelation(mapper, opts, function (def, optsCopy) {\n const relatedMapper = def.getRelation()\n optsCopy.raw = false\n if (utils.isFunction(def.load)) {\n task = def.load(mapper, def, self, opts)\n } else if (def.type === 'hasMany' || def.type === 'hasOne') {\n if (def.foreignKey) {\n task = superMethod(relatedMapper, 'findAll')({\n [def.foreignKey]: utils.get(self, mapper.idAttribute)\n }, optsCopy).then(function (relatedData) {\n if (def.type === 'hasOne') {\n return relatedData.length ? relatedData[0] : undefined\n }\n return relatedData\n })\n } else if (def.localKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [relatedMapper.idAttribute]: {\n 'in': utils.get(self, def.localKeys)\n }\n }\n })\n } else if (def.foreignKeys) {\n task = superMethod(relatedMapper, 'findAll')({\n where: {\n [def.foreignKeys]: {\n 'contains': utils.get(self, mapper.idAttribute)\n }\n }\n }, opts)\n }\n } else if (def.type === 'belongsTo') {\n const key = utils.get(self, def.foreignKey)\n if (utils.isSorN(key)) {\n task = superMethod(relatedMapper, 'find')(key, optsCopy)\n }\n }\n if (task) {\n task = task.then(function (relatedData) {\n def.setLocalField(self, relatedData)\n })\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterLoadRelations lifecycle hook\n op = opts.op = 'afterLoadRelations'\n return utils.resolve(self[op](relations, opts)).then(function () {\n return self\n })\n })\n },\n\n /**\n * TODO\n *\n * @name Record#previous\n * @method\n * @param {string} [key] TODO\n */\n previous (key) {\n const self = this\n if (key) {\n return self._get(`previous.${key}`)\n }\n return self._get('previous')\n },\n\n /**\n * TODO\n *\n * @name Record#revert\n * @method\n * @param {Object} [opts] Configuration options.\n */\n revert (opts) {\n const self = this\n const previous = self._get('previous')\n opts || (opts = {})\n opts.preserve || (opts.preserve = [])\n utils.forOwn(self, (value, key) => {\n if (key !== self._mapper().idAttribute && !previous.hasOwnProperty(key) && self.hasOwnProperty(key) && opts.preserve.indexOf(key) === -1) {\n delete self[key]\n }\n })\n utils.forOwn(previous, (value, key) => {\n if (opts.preserve.indexOf(key) === -1) {\n self[key] = value\n }\n })\n self.commit()\n return self\n },\n\n /**\n * Delegates to {@link Mapper#create} or {@link Mapper#update}.\n *\n * @name Record#save\n * @method\n * @param {Object} [opts] Configuration options. See {@link Mapper#create}.\n * @param [opts] Configuration options.\n * @param {boolean} [opts.changesOnly] Equality function. Default uses `===`.\n * @param {Function} [opts.equalsFn] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @param {Array} [opts.ignore] Passed to {@link Record#changes} when\n * `changesOnly` is `true`.\n * @return {Promise} The result of calling {@link Mapper#create} or\n * {@link Mapper#update}.\n */\n save (opts) {\n const self = this\n opts || (opts = {})\n const mapper = self._mapper()\n const id = utils.get(self, mapper.idAttribute)\n let props = self\n if (utils.isUndefined(id)) {\n return superMethod(mapper, 'create')(props, opts)\n }\n if (opts.changesOnly) {\n const changes = self.changes(opts)\n props = {}\n utils.fillIn(props, changes.added)\n utils.fillIn(props, changes.changed)\n }\n return superMethod(mapper, 'update')(id, props, opts)\n },\n\n /**\n * Set the value for a given key, or the values for the given keys if \"key\" is\n * an object.\n *\n * @name Record#set\n * @method\n * @param {(string|Object)} key - Key to set or hash of key-value pairs to set.\n * @param {*} [value] - Value to set for the given key.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n 'set' (key, value, opts) {\n const self = this\n if (utils.isObject(key)) {\n opts = value\n }\n opts || (opts = {})\n if (opts.silent) {\n self._set('silent', true)\n }\n utils.set(self, key, value)\n if (!self._get('eventId')) {\n self._set('silent') // unset\n }\n },\n\n // TODO: move logic for single-item async operations onto the instance.\n\n /**\n * Return a plain object representation of this record. If the class from\n * which this record was created has a mapper, then {@link Mapper#toJSON} will\n * be called instead.\n *\n * @name Record#toJSON\n * @method\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation. Only available as an option if the class\n * from which this record was created has a mapper.\n * @return {Object} Plain object representation of this record.\n */\n toJSON (opts) {\n const mapper = this.constructor.mapper\n if (mapper) {\n return mapper.toJSON(this, opts)\n } else {\n const json = {}\n utils.forOwn(this, function (prop, key) {\n json[key] = utils.copy(prop)\n })\n return json\n }\n },\n\n /**\n * Unset the value for a given key.\n *\n * @name Record#unset\n * @method\n * @param {string} key - Key to unset.\n * @param {Object} [opts] - Optional configuration.\n * @param {boolean} [opts.silent=false] - Whether to trigger change events.\n */\n unset (key, opts) {\n this.set(key, undefined, opts)\n },\n\n validate (opts) {\n return this._mapper().validate(this, opts)\n }\n})\n\n/**\n * Allow records to emit events.\n *\n * An record's registered listeners are stored in the record's private data.\n */\nutils.eventify(\n Record.prototype,\n function () {\n return this._get('events')\n },\n function (value) {\n this._set('events', value)\n }\n)\n\nexport default Record\n","import utils from './utils'\nimport Component from './Component'\n\nconst DOMAIN = 'Schema'\n\n/**\n * TODO\n *\n * @name Schema.types\n * @type {Object}\n */\nconst types = {\n array: utils.isArray,\n boolean: utils.isBoolean,\n integer: utils.isInteger,\n 'null': utils.isNull,\n number: utils.isNumber,\n object: utils.isObject,\n string: utils.isString\n}\n\n/**\n * @ignore\n */\nconst segmentToString = function (segment, prev) {\n let str = ''\n if (segment) {\n if (utils.isNumber(segment)) {\n str += `[${segment}]`\n } else if (prev) {\n str += `.${segment}`\n } else {\n str += `${segment}`\n }\n }\n return str\n}\n\n/**\n * @ignore\n */\nconst makePath = function (opts) {\n opts || (opts = {})\n let path = ''\n const segments = opts.path || []\n segments.forEach(function (segment) {\n path += segmentToString(segment, path)\n })\n path += segmentToString(opts.prop, path)\n return path\n}\n\n/**\n * @ignore\n */\nconst makeError = function (actual, expected, opts) {\n return {\n expected,\n actual: '' + actual,\n path: makePath(opts)\n }\n}\n\n/**\n * @ignore\n */\nconst addError = function (actual, expected, opts, errors) {\n errors.push(makeError(actual, expected, opts))\n}\n\n/**\n * @ignore\n */\nconst maxLengthCommon = function (keyword, value, schema, opts) {\n const max = schema[keyword]\n if (value.length > max) {\n return makeError(value.length, `length no more than ${max}`, opts)\n }\n}\n\n/**\n * @ignore\n */\nconst minLengthCommon = function (keyword, value, schema, opts) {\n const min = schema[keyword]\n if (value.length < min) {\n return makeError(value.length, `length no less than ${min}`, opts)\n }\n}\n\n/**\n * TODO\n *\n * @name Schema.validationKeywords\n * @type {Object}\n */\nconst validationKeywords = {\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor82\n *\n * @name Schema.validationKeywords.allOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n allOf (value, schema, opts) {\n let allErrors = []\n schema.allOf.forEach(function (_schema) {\n allErrors = allErrors.concat(validate(value, _schema, opts) || [])\n })\n return allErrors.length ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor85\n *\n * @name Schema.validationKeywords.anyOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n anyOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.anyOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor70\n *\n * @name Schema.validationKeywords.dependencies\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n dependencies (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor76\n *\n * @name Schema.validationKeywords.enum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n enum (value, schema, opts) {\n const possibleValues = schema['enum']\n if (possibleValues.indexOf(value) === -1) {\n return makeError(value, `one of (${possibleValues.join(', ')})`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor37\n *\n * @name Schema.validationKeywords.items\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n items (value, schema, opts) {\n opts || (opts = {})\n // TODO: additionalItems\n let items = schema.items\n let errors = []\n const checkingTuple = utils.isArray(items)\n const length = value.length\n for (var prop = 0; prop < length; prop++) {\n if (checkingTuple) {\n // Validating a tuple, instead of just checking each item against the\n // same schema\n items = schema.items[prop]\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], items, opts) || [])\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor17\n *\n * @name Schema.validationKeywords.maximum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maximum (value, schema, opts) {\n // Must be a number\n const maximum = schema.maximum\n // Must be a boolean\n // Depends on maximum\n // default: false\n const exclusiveMaximum = schema.exclusiveMaximum\n if (typeof value === typeof maximum && (exclusiveMaximum ? maximum < value : maximum <= value)) {\n // TODO: Account for value of exclusiveMaximum in messaging\n return makeError(value, `no more than ${maximum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.maxItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxItems (value, schema, opts) {\n return maxLengthCommon('maxItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor26\n *\n * @name Schema.validationKeywords.maxLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxLength (value, schema, opts) {\n return maxLengthCommon('maxLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor54\n *\n * @name Schema.validationKeywords.maxProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n maxProperties (value, schema, opts) {\n const maxProperties = schema.maxProperties\n const length = Object.keys(value).length\n if (length > maxProperties) {\n return makeError(length, `no more than ${maxProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor21\n *\n * @name Schema.validationKeywords.minimum\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minimum (value, schema, opts) {\n // Must be a number\n const minimum = schema.minimum\n // Must be a boolean\n // Depends on minimum\n // default: false\n const exclusiveMinimum = schema.exclusiveMinimum\n if (typeof value === typeof minimum && (exclusiveMinimum ? minimum > value : minimum >= value)) {\n // TODO: Account for value of exclusiveMinimum in messaging\n return makeError(value, `no less than ${minimum}`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor42\n *\n * @name Schema.validationKeywords.minItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minItems (value, schema, opts) {\n return minLengthCommon('minItems', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor29\n *\n * @name Schema.validationKeywords.minLength\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minLength (value, schema, opts) {\n return minLengthCommon('minLength', value, schema, opts)\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor57\n *\n * @name Schema.validationKeywords.minProperties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n minProperties (value, schema, opts) {\n const minProperties = schema.minProperties\n const length = Object.keys(value).length\n if (length < minProperties) {\n return makeError(length, `no more than ${minProperties} properties`, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor14\n *\n * @name Schema.validationKeywords.multipleOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n multipleOf (value, schema, opts) {\n // TODO\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor91\n *\n * @name Schema.validationKeywords.not\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n not (value, schema, opts) {\n if (!validate(value, schema.not, opts)) {\n // TODO: better messaging\n return makeError('succeeded', 'should have failed', opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor88\n *\n * @name Schema.validationKeywords.oneOf\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n oneOf (value, schema, opts) {\n let validated = false\n let allErrors = []\n schema.oneOf.forEach(function (_schema) {\n const errors = validate(value, _schema, opts)\n if (errors) {\n allErrors = allErrors.concat(errors)\n } else if (validated) {\n allErrors = [makeError('valid against more than one', 'valid against only one', opts)]\n validated = false\n return false\n } else {\n validated = true\n }\n })\n return validated ? undefined : allErrors\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor33\n *\n * @name Schema.validationKeywords.pattern\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n pattern (value, schema, opts) {\n const pattern = schema.pattern\n if (utils.isString(value) && !value.match(pattern)) {\n return makeError(value, pattern, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor64\n *\n * @name Schema.validationKeywords.properties\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n properties (value, schema, opts) {\n opts || (opts = {})\n // Can be a boolean or an object\n // Technically the default is an \"empty schema\", but here \"true\" is\n // functionally the same\n const additionalProperties = utils.isUndefined(schema.additionalProperties) ? true : schema.additionalProperties\n // \"s\": The property set of the instance to validate.\n const toValidate = {}\n // \"p\": The property set from \"properties\".\n // Default is an object\n const properties = schema.properties || {}\n // \"pp\": The property set from \"patternProperties\".\n // Default is an object\n const patternProperties = schema.patternProperties || {}\n let errors = []\n\n // Collect set \"s\"\n utils.forOwn(value, function (_value, prop) {\n toValidate[prop] = undefined\n })\n // Remove from \"s\" all elements of \"p\", if any.\n utils.forOwn(properties || {}, function (_schema, prop) {\n if (utils.isUndefined(value[prop]) && !utils.isUndefined(_schema['default'])) {\n value[prop] = utils.copy(_schema['default'])\n }\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n })\n // For each regex in \"pp\", remove all elements of \"s\" which this regex\n // matches.\n utils.forOwn(patternProperties, function (_schema, pattern) {\n utils.forOwn(toValidate, function (undef, prop) {\n if (prop.match(pattern)) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], _schema, opts) || [])\n delete toValidate[prop]\n }\n })\n })\n const keys = Object.keys(toValidate)\n // If \"s\" is not empty, validation fails\n if (additionalProperties === false) {\n if (keys.length) {\n addError(`extra fields: ${keys.join(', ')}`, 'no extra fields', opts, errors)\n }\n } else if (utils.isObject(additionalProperties)) {\n // Otherwise, validate according to provided schema\n keys.forEach(function (prop) {\n opts.prop = prop\n errors = errors.concat(validate(value[prop], additionalProperties, opts) || [])\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor61\n *\n * @name Schema.validationKeywords.required\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n required (value, schema, opts) {\n const required = schema.required\n let errors = []\n if (!opts.existingOnly) {\n required.forEach(function (prop) {\n if (utils.isUndefined(utils.get(value, prop))) {\n const prevProp = opts.prop\n opts.prop = prop\n addError(undefined, 'a value', opts, errors)\n opts.prop = prevProp\n }\n })\n }\n return errors.length ? errors : undefined\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor79\n *\n * @name Schema.validationKeywords.type\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n type (value, schema, opts) {\n let type = schema.type\n let validType\n // Can be one of several types\n if (utils.isString(type)) {\n type = [type]\n }\n // Try to match the value against an expected type\n type.forEach(function (_type) {\n // TODO: throw an error if type is not defined\n if (types[_type](value, schema, opts)) {\n // Matched a type\n validType = _type\n return false\n }\n })\n // Value did not match any expected type\n if (!validType) {\n return makeError(value ? typeof value : '' + value, `one of (${type.join(', ')})`, opts)\n }\n // Run keyword validators for matched type\n // http://json-schema.org/latest/json-schema-validation.html#anchor12\n const validator = typeGroupValidators[validType]\n if (validator) {\n return validator(value, schema, opts)\n }\n },\n\n /**\n * http://json-schema.org/latest/json-schema-validation.html#anchor49\n *\n * @name Schema.validationKeywords.uniqueItems\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n uniqueItems (value, schema, opts) {\n if (value && value.length && schema.uniqueItems) {\n const length = value.length\n let item, i, j\n // Check n - 1 items\n for (i = length - 1; i > 0; i--) {\n item = value[i]\n // Only compare against unchecked items\n for (j = i - 1; j >= 0; j--) {\n // Found a duplicate\n if (item === value[j]) {\n return makeError(item, 'no duplicates', opts)\n }\n }\n }\n }\n }\n}\n\n/**\n * @ignore\n */\nconst validateKeyword = function (op, value, schema, opts) {\n return !utils.isUndefined(schema[op]) && validationKeywords[op](value, schema, opts)\n}\n\n/**\n * @ignore\n */\nconst runOps = function (ops, value, schema, opts) {\n let errors = []\n ops.forEach(function (op) {\n errors = errors.concat(validateKeyword(op, value, schema, opts) || [])\n })\n return errors.length ? errors : undefined\n}\n\nconst ANY_OPS = ['enum', 'type', 'allOf', 'anyOf', 'oneOf', 'not']\nconst ARRAY_OPS = ['items', 'maxItems', 'minItems', 'uniqueItems']\nconst NUMERIC_OPS = ['multipleOf', 'maximum', 'minimum']\nconst OBJECT_OPS = ['maxProperties', 'minProperties', 'required', 'properties', 'dependencies']\nconst STRING_OPS = ['maxLength', 'minLength', 'pattern']\n\n/**\n * http://json-schema.org/latest/json-schema-validation.html#anchor75\n * @ignore\n */\nconst validateAny = function (value, schema, opts) {\n return runOps(ANY_OPS, value, schema, opts)\n}\n\n/**\n * TODO\n *\n * @name Schema.validate\n * @method\n * @param {*} value TODO\n * @param {Object} [schema] TODO\n * @param {Object} [opts] Configuration options.\n */\nconst validate = function (value, schema, opts) {\n let errors = []\n opts || (opts = {})\n let shouldPop\n let prevProp = opts.prop\n if (utils.isUndefined(schema)) {\n return\n }\n if (!utils.isObject(schema)) {\n throw utils.err(`${DOMAIN}#validate`)(500, `Invalid schema at path: \"${opts.path}\"`)\n }\n if (utils.isUndefined(opts.path)) {\n opts.path = []\n }\n // Track our location as we recurse\n if (!utils.isUndefined(opts.prop)) {\n shouldPop = true\n opts.path.push(opts.prop)\n opts.prop = undefined\n }\n // Validate against parent schema\n if (schema['extends']) {\n // opts.path = path\n // opts.prop = prop\n if (utils.isFunction(schema['extends'].validate)) {\n errors = errors.concat(schema['extends'].validate(value, opts) || [])\n } else {\n errors = errors.concat(validate(value, schema['extends'], opts) || [])\n }\n }\n if (utils.isUndefined(value)) {\n // Check if property is required\n if (schema.required === true) {\n addError(value, 'a value', opts, errors)\n }\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n }\n errors = errors.concat(validateAny(value, schema, opts) || [])\n if (shouldPop) {\n opts.path.pop()\n opts.prop = prevProp\n }\n return errors.length ? errors : undefined\n}\n\n// These strings are cached for optimal performance of the change detection\n// boolean - Whether a Record is changing in the current execution frame\nconst changingPath = 'changing'\n// string[] - Properties that have changed in the current execution frame\nconst changedPath = 'changed'\n// boolean - Whether a Record is currently being instantiated\nconst creatingPath = 'creating'\n// number - The setTimeout change event id of a Record, if any\nconst eventIdPath = 'eventId'\n// boolean - Whether to skip validation for a Record's currently changing property\nconst noValidatePath = 'noValidate'\n// boolean - Whether to skip change notification for a Record's currently\n// changing property\nconst silentPath = 'silent'\nconst validationFailureMsg = 'validation failed'\n\n/**\n * Assemble a property descriptor which will be added to the prototype of\n * {@link Mapper#recordClass}. This method is called when\n * {@link Mapper#applySchema} is set to `true`.\n *\n * TODO: Make this more configurable, i.e. not so tied to the Record class.\n *\n * @ignore\n */\nconst makeDescriptor = function (prop, schema, opts) {\n const descriptor = {\n // These properties are enumerable by default, but regardless of their\n // enumerability, they won't be \"own\" properties of individual records\n enumerable: utils.isUndefined(schema.enumerable) ? true : !!schema.enumerable\n }\n // Cache a few strings for optimal performance\n const keyPath = `props.${prop}`\n const previousPath = `previous.${prop}`\n const getter = opts.getter\n const setter = opts.setter\n const unsetter = opts.unsetter\n\n descriptor.get = function () { return this._get(keyPath) }\n descriptor.set = function (value) {\n const self = this\n // These are accessed a lot\n const _get = self[getter]\n const _set = self[setter]\n const _unset = self[unsetter]\n\n // Optionally check that the new value passes validation\n if (!_get(noValidatePath)) {\n const errors = schema.validate(value)\n if (errors) {\n // Immediately throw an error, preventing the record from getting into\n // an invalid state\n const error = new Error(validationFailureMsg)\n error.errors = errors\n throw error\n }\n }\n // TODO: Make it so tracking can be turned on for all properties instead of\n // only per-property\n if (schema.track && !_get(creatingPath)) {\n const previous = _get(previousPath)\n const current = _get(keyPath)\n let changing = _get(changingPath)\n let changed = _get(changedPath)\n\n if (!changing) {\n // Track properties that are changing in the current event loop\n changed = []\n }\n\n // Add changing properties to this array once at most\n const index = changed.indexOf(prop)\n if (current !== value && index === -1) {\n changed.push(prop)\n }\n if (previous === value) {\n if (index >= 0) {\n changed.splice(index, 1)\n }\n }\n // No changes in current event loop\n if (!changed.length) {\n changing = false\n _unset(changingPath)\n _unset(changedPath)\n // Cancel pending change event\n if (_get(eventIdPath)) {\n clearTimeout(_get(eventIdPath))\n _unset(eventIdPath)\n }\n }\n // Changes detected in current event loop\n if (!changing && changed.length) {\n _set(changedPath, changed)\n _set(changingPath, true)\n // Saving the timeout id allows us to batch all changes in the same\n // event loop into a single \"change\"\n // TODO: Optimize\n _set(eventIdPath, setTimeout(() => {\n // Previous event loop where changes were gathered has ended, so\n // notify any listeners of those changes and prepare for any new\n // changes\n _unset(changedPath)\n _unset(eventIdPath)\n _unset(changingPath)\n // TODO: Optimize\n if (!_get(silentPath)) {\n let i\n for (i = 0; i < changed.length; i++) {\n self.emit('change:' + changed[i], self, utils.get(self, changed[i]))\n }\n self.emit('change', self, self.changes())\n }\n _unset(silentPath)\n }, 0))\n }\n }\n _set(keyPath, value)\n return value\n }\n\n return descriptor\n}\n\n/**\n * TODO\n *\n * @name Schema.typeGroupValidators\n * @type {Object}\n */\nconst typeGroupValidators = {\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.array\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n array: function (value, schema, opts) {\n return runOps(ARRAY_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.integer\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n integer: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * @name Schema.typeGroupValidators.number\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n number: function (value, schema, opts) {\n // Additional validations for numerics are the same\n return typeGroupValidators.numeric(value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor13.\n *\n * @name Schema.typeGroupValidators.numeric\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n numeric: function (value, schema, opts) {\n return runOps(NUMERIC_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor53.\n *\n * @name Schema.typeGroupValidators.object\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n object: function (value, schema, opts) {\n return runOps(OBJECT_OPS, value, schema, opts)\n },\n\n /**\n * TODO\n *\n * See http://json-schema.org/latest/json-schema-validation.html#anchor25.\n *\n * @name Schema.typeGroupValidators.string\n * @method\n * @param {*} value TODO\n * @param {Object} schema TODO\n * @param {Object} opts TODO\n */\n string: function (value, schema, opts) {\n return runOps(STRING_OPS, value, schema, opts)\n }\n}\n\n/**\n * js-data's Schema class.\n *\n * ```javascript\n * import {Schema} from 'js-data'\n * ```\n *\n * @class Schema\n * @extends Component\n * @param {Object} definition Schema definition according to json-schema.org\n */\nexport default Component.extend({\n constructor: function Schema (definition) {\n // const self = this\n definition || (definition = {})\n // TODO: schema validation\n utils.fillIn(this, definition)\n\n // TODO: rework this to make sure all possible keywords are converted\n if (definition.properties) {\n utils.forOwn(definition.properties, function (_definition, prop) {\n if (!(_definition instanceof Schema)) {\n definition.properties[prop] = new Schema(_definition)\n }\n })\n }\n },\n\n /**\n * This adds ES5 getters/setters to the target based on the \"properties\" in\n * this Schema, which makes possible change tracking and validation on\n * property assignment.\n *\n * @name Schema#validate\n * @method\n * @param {Object} target The prototype to which to apply this schema.\n */\n apply (target, opts) {\n opts || (opts = {})\n opts.getter = opts.getter || '_get'\n opts.setter = opts.setter || '_set'\n opts.unsetter = opts.unsetter || '_unset'\n const properties = this.properties || {}\n utils.forOwn(properties, function (schema, prop) {\n Object.defineProperty(\n target,\n prop,\n makeDescriptor(prop, schema, opts)\n )\n })\n },\n\n /**\n * Validate the provided value against this schema.\n *\n * @name Schema#validate\n * @method\n * @param {*} value Value to validate.\n * @param {Object} [opts] Configuration options.\n * @return {(array|undefined)} Array of errors or `undefined` if valid.\n */\n validate (value, opts) {\n return validate(value, this, opts)\n }\n}, {\n typeGroupValidators,\n types,\n validate,\n validationKeywords\n})\n","import utils from './utils'\nimport Component from './Component'\nimport Record from './Record'\nimport Schema from './Schema'\nimport {\n belongsTo,\n belongsToType,\n hasMany,\n hasManyType,\n hasOne,\n hasOneType\n} from './decorators'\n\nconst DOMAIN = 'Mapper'\n\nconst makeNotify = function (num) {\n return function (...args) {\n const self = this\n const opts = args[args.length - num]\n self.dbg(opts.op, ...args)\n if (opts.notify || (opts.notify === undefined && self.notify)) {\n setTimeout(() => {\n self.emit(opts.op, ...args)\n })\n }\n }\n}\n\n// These are the default implementations of all of the lifecycle hooks\nconst notify = makeNotify(1)\nconst notify2 = makeNotify(2)\n\n// This object provides meta information used by Mapper#crud to actually\n// execute each lifecycle method\nconst LIFECYCLE_METHODS = {\n count: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroy: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n destroyAll: {\n defaults: [{}, {}],\n skip: true,\n types: []\n },\n find: {\n defaults: [undefined, {}],\n types: []\n },\n findAll: {\n defaults: [{}, {}],\n types: []\n },\n sum: {\n defaults: [undefined, {}, {}],\n skip: true,\n types: []\n },\n update: {\n adapterArgs (mapper, id, props, opts) {\n return [id, mapper.toJSON(props, opts), opts]\n },\n beforeAssign: 1,\n defaults: [undefined, {}, {}],\n types: []\n },\n updateAll: {\n adapterArgs (mapper, props, query, opts) {\n return [mapper.toJSON(props, opts), query, opts]\n },\n beforeAssign: 0,\n defaults: [{}, {}, {}],\n types: []\n },\n updateMany: {\n adapterArgs (mapper, records, opts) {\n return [records.map(function (record) {\n return mapper.toJSON(record, opts)\n }), opts]\n },\n beforeAssign: 0,\n defaults: [[], {}],\n types: []\n }\n}\n\nconst MAPPER_DEFAULTS = {\n /**\n * Hash of registered adapters. Don't modify directly. Use {@link Mapper#registerAdapter}.\n *\n * @name Mapper#_adapters\n */\n _adapters: {},\n\n /**\n * Whether to augment {@link Mapper#recordClass} with getter/setter property\n * accessors according to the properties defined in {@link Mapper#schema}.\n * This makes possible validation and change tracking on individual properties\n * when using the dot (e.g. `user.name = \"Bob\"`) operator to modify a\n * property.\n *\n * @name Mapper#applySchema\n * @type {boolean}\n * @default true\n */\n applySchema: true,\n\n /**\n * Whether to enable debug-level logs.\n *\n * @name Mapper#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * The name of the registered adapter that this Mapper should used by default.\n *\n * @name Mapper#defaultAdapter\n * @type {string}\n * @default \"http\"\n */\n defaultAdapter: 'http',\n\n /**\n * The field used as the unique identifier on records handled by this Mapper.\n *\n * @name Mapper#idAttribute\n * @type {string}\n * @default id\n */\n idAttribute: 'id',\n\n /**\n * Whether this Mapper should emit operational events.\n *\n * Defaults to `true` in the browser and `false` in Node.js\n *\n * @name Mapper#notify\n * @type {boolean}\n */\n notify: utils.isBrowser,\n\n /**\n * Whether {@link Mapper#create}, {@link Mapper#createMany}, {@link Mapper#save},\n * {@link Mapper#update}, {@link Mapper#updateAll}, {@link Mapper#updateMany},\n * {@link Mapper#find}, {@link Mapper#findAll}, {@link Mapper#destroy}, and\n * {@link Mapper#destroyAll} should return a raw result object that contains\n * both the instance data returned by the adapter _and_ metadata about the\n * operation.\n *\n * The default is to NOT return the result object, and instead return just the\n * instance data.\n *\n * @name Mapper#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * ```javascript\n * import {Mapper} from 'js-data'\n * ```\n *\n * The core of JSData's [ORM/ODM][orm] implementation. Given a minimum amout of\n * meta information about a resource, a Mapper can perform generic CRUD\n * operations against that resource. Apart from its configuration, a Mapper is\n * stateless. The particulars of various persistence layers has been abstracted\n * into adapters, which a Mapper uses to perform its operations.\n *\n * The term \"Mapper\" comes from the [Data Mapper Pattern][pattern] described in\n * Martin Fowler's [Patterns of Enterprise Application Architecture][book]. A\n * Data Mapper moves data between [in-memory object instances][record] and a\n * relational or document-based database. JSData's Mapper can work with any\n * persistence layer you can write an adapter for.\n *\n * _(\"Model\" is a heavily overloaded term and is avoided in this documentation\n * to prevent confusion.)_\n *\n * [orm]: https://en.wikipedia.org/wiki/Object-relational_mapping\n * [pattern]: https://en.wikipedia.org/wiki/Data_mapper_pattern\n * [book]: http://martinfowler.com/books/eaa.html\n * [record]: Record.html\n *\n * @class Mapper\n * @extends Component\n * @param {Object} opts Configuration options.\n * @param {boolean} [opts.applySchema=true] Whether to apply this Mapper's\n * {@link Schema} to the prototype of this Mapper's Record class. The enables\n * features like active change detection, validation during use of the\n * assignment operator, etc.\n * @param {boolean} [opts.debug=false] Wether to log debugging information\n * during operation.\n * @param {string} [opts.defaultAdapter=http] The name of the adapter to use by\n * default.\n * @param {string} [opts.idAttribute=id] The field that uniquely identifies\n * Records that this Mapper will be dealing with. Typically called a primary\n * key.\n * @param {string} opts.name The name for this Mapper. This is the minimum\n * amount of meta information required for a Mapper to be able to execute CRUD\n * operations for a \"Resource\".\n * @param {boolean} [opts.notify] Whether to emit lifecycle events.\n * @param {boolean} [opts.raw=false] Whether lifecycle methods should return a\n * more detailed reponse object instead of just a Record instance or Record\n * instances.\n */\nexport default Component.extend({\n constructor: function Mapper (opts) {\n const self = this\n utils.classCallCheck(self, Mapper)\n Mapper.__super__.call(self)\n opts || (opts = {})\n\n // Prepare certain properties to be non-enumerable\n Object.defineProperties(self, {\n _adapters: {\n value: undefined,\n writable: true\n },\n\n /**\n * Set the `false` to force the Mapper to work with POJO objects only.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * const UserMapper = new Mapper({ recordClass: false })\n * UserMapper.recordClass // false\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * ```\n *\n * Set to a custom class to have records wrapped in your custom class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User {\n * constructor (props = {}) {\n * for (var key in props) {\n * if (props.hasOwnProperty(key)) {\n * this[key] = props[key]\n * }\n * }\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // false\n * user instanceof User // true\n * ```\n *\n * Extend the {@link Record} class.\n *\n * ```javascript\n * import {Mapper, Record} from 'js-data'\n * // Custom class\n * class User extends Record {\n * constructor () {\n * super(props)\n * }\n * }\n * const UserMapper = new Mapper({ recordClass: User })\n * UserMapper.recordClass // function User() {}\n * const user = UserMapper#createRecord()\n * user instanceof Record // true\n * user instanceof User // true\n * ```\n *\n * @name Mapper#recordClass\n * @default {@link Record}\n */\n recordClass: {\n value: undefined,\n writable: true\n },\n\n lifecycleMethods: {\n value: LIFECYCLE_METHODS\n },\n\n schema: {\n value: undefined,\n writable: true\n }\n })\n\n // Apply user-provided configuration\n utils.fillIn(self, opts)\n // Fill in any missing options with the defaults\n utils.fillIn(self, utils.copy(MAPPER_DEFAULTS))\n\n /**\n * Minimum amount of meta information required for a Mapper to be able to\n * execute CRUD operations for a \"Resource\".\n *\n * @name Mapper#name\n * @type {string}\n */\n if (!self.name) {\n throw utils.err(`new ${DOMAIN}`, 'opts.name')(400, 'string', self.name)\n }\n\n // Setup schema, with an empty default schema if necessary\n if (!(self.schema instanceof Schema)) {\n self.schema = new Schema(self.schema || {})\n }\n\n // Create a subclass of Record that's tied to this Mapper\n if (utils.isUndefined(self.recordClass)) {\n const superClass = Record\n self.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n\n if (self.recordClass) {\n self.recordClass.mapper = self\n\n // We can only apply the schema to the prototype of self.recordClass if the\n // class extends Record\n if (utils.getSuper(self.recordClass, true) === Record && self.schema && self.schema.apply && self.applySchema) {\n self.schema.apply(self.recordClass.prototype)\n }\n }\n },\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n * @param {*} result The result, if any.\n */\n afterCount: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n * @param {*} result The result, if any.\n */\n afterCreate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n * @param {*} result The result, if any.\n */\n afterCreateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n * @param {*} result The result, if any.\n */\n afterDestroy: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterDestroyAll\n * @method\n * @param {*} data The `data` returned by the adapter.\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n * @param {*} result The result, if any.\n */\n afterDestroyAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n * @param {*} result The result, if any.\n */\n afterFind: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n * @param {*} result The result, if any.\n */\n afterFindAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterSum\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n * @param {*} result The result, if any.\n */\n afterSum: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n * @param {*} result The result, if any.\n */\n afterUpdate: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n * @param {*} result The result, if any.\n */\n afterUpdateAll: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#afterUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n * @param {*} result The result, if any.\n */\n afterUpdateMany: notify2,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#create}. If this method\n * returns a promise then {@link Mapper#create} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreate\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#create}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#create}.\n */\n beforeCreate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#createMany}. If this method\n * returns a promise then {@link Mapper#createMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCreateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#createMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#createMany}.\n */\n beforeCreateMany: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#count}. If this method\n * returns a promise then {@link Mapper#count} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeCount\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#count}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#count}.\n */\n beforeCount: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroy}. If this method\n * returns a promise then {@link Mapper#destroy} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroy\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#destroy}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroy}.\n */\n beforeDestroy: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#destroyAll}. If this method\n * returns a promise then {@link Mapper#destroyAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeDestroyAll\n * @method\n * @param {query} query The `query` argument passed to {@link Mapper#destroyAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#destroyAll}.\n */\n beforeDestroyAll: notify,\n\n /**\n * Mappers lifecycle hook called by {@link Mapper#find}. If this method\n * returns a promise then {@link Mapper#find} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFind\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#find}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#find}.\n */\n beforeFind: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#findAll}. If this method\n * returns a promise then {@link Mapper#findAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeFindAll\n * @method\n * @param {Object} query The `query` argument passed to {@link Mapper#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#findAll}.\n */\n beforeFindAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#sum}. If this method\n * returns a promise then {@link Mapper#sum} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeSum\n * @method\n * @param {string} field The `field` argument passed to {@link Mapper#sum}.\n * @param {Object} query The `query` argument passed to {@link Mapper#sum}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#sum}.\n */\n beforeSum: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#update}. If this method\n * returns a promise then {@link Mapper#update} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdate\n * @method\n * @param {(string|number)} id The `id` argument passed to {@link Mapper#update}.\n * @param {props} props The `props` argument passed to {@link Mapper#update}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#update}.\n */\n beforeUpdate: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateAll}. If this method\n * returns a promise then {@link Mapper#updateAll} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateAll\n * @method\n * @param {Object} props The `props` argument passed to {@link Mapper#updateAll}.\n * @param {Object} query The `query` argument passed to {@link Mapper#updateAll}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateAll}.\n */\n beforeUpdateAll: notify,\n\n /**\n * Mapper lifecycle hook called by {@link Mapper#updateMany}. If this method\n * returns a promise then {@link Mapper#updateMany} will wait for the promise\n * to resolve before continuing.\n *\n * @name Mapper#beforeUpdateMany\n * @method\n * @param {Array} records The `records` argument passed to {@link Mapper#updateMany}.\n * @param {Object} opts The `opts` argument passed to {@link Mapper#updateMany}.\n */\n beforeUpdateMany: notify,\n\n /**\n * This method is called at the end of most lifecycle methods. It does the\n * following:\n *\n * 1. If `opts.raw` is `true`, add this Mapper's configuration to the `opts`\n * argument as metadata for the operation.\n * 2. Wrap the result data appropriately using {@link Mapper#wrap}, which\n * calls {@link Mapper#createRecord}.\n *\n * @name Mapper#_end\n * @method\n * @private\n */\n _end (result, opts, skip) {\n const self = this\n if (opts.raw) {\n utils._(result, opts)\n }\n if (skip) {\n return result\n }\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(self.wrap)) {\n _data = self.wrap(_data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Define a belongsTo relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * Post.belongsTo(User, {\n * localKey: 'myUserId'\n * })\n *\n * Comment.belongsTo(User)\n * Comment.belongsTo(Post, {\n * localField: '_post'\n * })\n * ```\n *\n * @name Mapper#belongsTo\n * @method\n */\n belongsTo (relatedMapper, opts) {\n return belongsTo(relatedMapper, opts)(this)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeCount} will be called before calling the adapter.\n * {@link Mapper#afterCount} will be called after calling the adapter.\n *\n * @name Mapper#count\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n count (query, opts) {\n return this.crud('count', query, opts)\n },\n\n /**\n * Create and save a new the record using the provided `props`.\n *\n * {@link Mapper#beforeCreate} will be called before calling the adapter.\n * {@link Mapper#afterCreate} will be called after calling the adapter.\n *\n * @name Mapper#create\n * @method\n * @param {Object} props The properties for the new record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * created data. If `true` return a response object that includes the created\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `props` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#create}\n * or {@link Mapper#createMany} call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n create (props, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n props || (props = {})\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n const relatedMapper = def.getRelation()\n const relatedIdAttribute = relatedMapper.idAttribute\n optsCopy.raw = false\n if (!relationData) {\n return\n }\n if (def.type === belongsToType) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(relatedMapper.create(relationData, optsCopy).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n def.setForeignKey(props, data)\n }))\n } else if (def.type === hasManyType && def.localKeys) {\n // Create his hasMany relation first because it uses localKeys\n tasks.push(relatedMapper.createMany(relationData, optsCopy).then(function (data) {\n def.setLocalField(belongsToRelationData, data)\n utils.set(props, def.localKeys, data.map(function (record) {\n return utils.get(record, relatedIdAttribute)\n }))\n }))\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter for the main create\n op = opts.op = 'create'\n self.dbg(op, props, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, self.toJSON(props, { with: opts.pass || [] }), opts))\n }).then(function (data) {\n const createdRecord = opts.raw ? data.data : data\n // Deep post-create hasMany and hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(props)\n if (!relationData) {\n return\n }\n optsCopy.raw = false\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType && def.foreignKey) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, data)\n })\n } else if (def.type === hasOneType) {\n def.setForeignKey(createdRecord, relationData)\n task = def.getRelation().create(relationData, optsCopy).then(function (data) {\n def.setLocalField(createdRecord, data)\n })\n } else if (def.type === belongsToType && def.getLocalField(belongsToRelationData)) {\n def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData))\n } else if (def.type === hasManyType && def.localKeys && def.getLocalField(belongsToRelationData)) {\n def.setLocalField(createdRecord, def.getLocalField(belongsToRelationData))\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](props, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n createInstance (props, opts) {\n return this.createRecord(props, opts)\n },\n\n /**\n * Given an array of records, batch create them via an adapter.\n *\n * {@link Mapper#beforeCreateMany} will be called before calling the adapter.\n * {@link Mapper#afterCreateMany} will be called after calling the adapter.\n *\n * @name Mapper#createMany\n * @method\n * @param {Array} records Array of records to be created in one batch.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to create in a cascading\n * create if `records` contains nested relations. NOT performed in a\n * transaction. Each nested create will result in another {@link Mapper#createMany}\n * call.\n * @param {string[]} [opts.pass=[]] Relations to send to the adapter as part\n * of the payload. Normally relations are not sent.\n * @return {Promise}\n */\n createMany (records, opts) {\n let op, adapter\n const self = this\n\n // Default values for arguments\n records || (records = [])\n opts || (opts = {})\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n\n // Deep pre-create belongsTo relations\n const belongsToRelationData = {}\n opts.with || (opts.with = [])\n let tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (def.type === belongsToType && relationData.length === records.length) {\n // Create belongsTo relation first because we need a generated id to\n // attach to the child\n tasks.push(def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedRecords = optsCopy.raw ? data.data : data\n def.setLocalField(belongsToRelationData, relatedRecords)\n records.forEach(function (record, i) {\n def.setForeignKey(record, relatedRecords[i])\n })\n }))\n }\n })\n return utils.Promise.all(tasks).then(function () {\n // Now delegate to the adapter\n op = opts.op = 'createMany'\n const json = records.map(function (record) {\n return self.toJSON(record, { with: opts.pass || [] })\n })\n self.dbg(op, records, opts)\n return utils.resolve(self.getAdapter(adapter)[op](self, json, opts))\n }).then(function (data) {\n const createdRecords = opts.raw ? data.data : data\n\n // Deep post-create hasOne relations\n tasks = []\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = records.map(function (record) {\n return def.getLocalField(record)\n }).filter(function (relatedRecord) {\n return relatedRecord\n })\n if (relationData.length !== records.length) {\n return\n }\n const belongsToData = def.getLocalField(belongsToRelationData)\n let task\n // Create hasMany and hasOne after the main create because we needed\n // a generated id to attach to these items\n if (def.type === hasManyType) {\n // Not supported\n self.log('warn', 'deep createMany of hasMany type not supported!')\n } else if (def.type === hasOneType) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setForeignKey(createdRecord, relationData[i])\n })\n task = def.getRelation().createMany(relationData, optsCopy).then(function (data) {\n const relatedData = opts.raw ? data.data : data\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, relatedData[i])\n })\n })\n } else if (def.type === belongsToType && belongsToData && belongsToData.length === createdRecords.length) {\n createdRecords.forEach(function (createdRecord, i) {\n def.setLocalField(createdRecord, belongsToData[i])\n })\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks).then(function () {\n return data\n })\n })\n }).then(function (result) {\n result = self._end(result, opts)\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](records, opts, result)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Create an unsaved, uncached instance of this Mapper's\n * {@link Mapper#recordClass}.\n *\n * Returns `props` if `props` is already an instance of\n * {@link Mapper#recordClass}.\n *\n * @name Mapper#createRecord\n * @method\n * @param {Object|Array} props The properties for the Record instance or an\n * array of property objects for the Record instances.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.noValidate=false] Whether to skip validation when\n * the Record instances are created.\n * @return {Object|Array} The Record instance or Record instances.\n */\n createRecord (props, opts) {\n props || (props = {})\n const self = this\n if (utils.isArray(props)) {\n return props.map(function (_props) {\n return self.createRecord(_props, opts)\n })\n }\n if (!utils.isObject(props)) {\n throw utils.err(`${DOMAIN}#createRecord`, 'props')(400, 'array or object', props)\n }\n const recordClass = self.recordClass\n const relationList = self.relationList || []\n relationList.forEach(function (def) {\n const relatedMapper = def.getRelation()\n const relationData = def.getLocalField(props)\n if (relationData && !relatedMapper.is(relationData)) {\n if (utils.isArray(relationData) && (!relationData.length || relatedMapper.is(relationData[0]))) {\n return\n }\n utils.set(props, def.localField, relatedMapper.createRecord(relationData, opts))\n }\n })\n // Check to make sure \"props\" is not already an instance of this Mapper.\n return recordClass ? (props instanceof recordClass ? props : new recordClass(props, opts)) : props // eslint-disable-line\n },\n\n /**\n * Lifecycle invocation method.\n *\n * @name Mapper#crud\n * @method\n * @param {string} method Name of the lifecycle method to invoke.\n * @param {...*} args Arguments to pass to the lifecycle method.\n * @return {Promise}\n */\n crud (method, ...args) {\n const self = this\n const config = self.lifecycleMethods[method]\n if (!config) {\n throw utils.err(`${DOMAIN}#crud`, method)(404, 'method')\n }\n\n const upper = `${method.charAt(0).toUpperCase()}${method.substr(1)}`\n const before = `before${upper}`\n const after = `after${upper}`\n\n let op, adapter\n\n // Default values for arguments\n config.defaults.forEach(function (value, i) {\n if (utils.isUndefined(args[i])) {\n args[i] = utils.copy(value)\n }\n })\n\n const opts = args[args.length - 1]\n\n // Fill in \"opts\" with the Mapper's configuration\n utils._(opts, self)\n adapter = opts.adapter = self.getAdapterName(opts)\n\n // before lifecycle hook\n op = opts.op = before\n return utils.resolve(self[op](...args)).then(function (_value) {\n if (!utils.isUndefined(config.beforeAssign)) {\n // Allow for re-assignment from lifecycle hook\n args[config.beforeAssign] = utils.isUndefined(_value) ? args[config.beforeAssign] : _value\n }\n // Now delegate to the adapter\n op = opts.op = method\n args = config.adapterArgs ? config.adapterArgs(self, ...args) : args\n self.dbg(op, ...args)\n return utils.resolve(self.getAdapter(adapter)[op](self, ...args))\n }).then(function (result) {\n result = self._end(result, opts, !!config.skip)\n args.push(result)\n // after lifecycle hook\n op = opts.op = after\n return utils.resolve(self[op](...args)).then(function (_result) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_result) ? result : _result\n })\n })\n },\n\n /**\n * Using an adapter, destroy the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeDestroy} will be called before destroying the record.\n * {@link Mapper#afterDestroy} will be called after destroying the record.\n *\n * @name Mapper#destroy\n * @method\n * @param {(string|number)} id The primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroy (id, opts) {\n return this.crud('destroy', id, opts)\n },\n\n /**\n * Using the `query` argument, destroy the selected records via an adapter.\n * If no `query` is provided then all records will be destroyed.\n *\n * {@link Mapper#beforeDestroyAll} will be called before destroying the records.\n * {@link Mapper#afterDestroyAll} will be called after destroying the records.\n *\n * @name Mapper#destroyAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * ejected data (if any). If `true` return a response object that includes the\n * ejected data (if any) and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to destroy in a cascading\n * delete. NOT performed in a transaction.\n * @return {Promise}\n */\n destroyAll (query, opts) {\n return this.crud('destroyAll', query, opts)\n },\n\n /**\n * Retrieve via an adapter the record with the given primary key.\n *\n * {@link Mapper#beforeFind} will be called before calling the adapter.\n * {@link Mapper#afterFind} will be called after calling the adapter.\n *\n * @name Mapper#find\n * @method\n * @param {(string|number)} id The primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n find (id, opts) {\n return this.crud('find', id, opts)\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeFindAll} will be called before calling the adapter.\n * {@link Mapper#afterFindAll} will be called after calling the adapter.\n *\n * @name Mapper#findAll\n * @method\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to eager load in the request.\n * @return {Promise}\n */\n findAll (query, opts) {\n return this.crud('findAll', query, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Mapper#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n self.dbg('getAdapter', 'name:', name)\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw utils.err(`${DOMAIN}#getAdapter`, 'name')(400, 'string', name)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Mapper#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || opts.defaultAdapter\n },\n\n /**\n * @name Mapper#getAdapters\n * @method\n * @return {Object} This Mapper's adapters\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Returns this Mapper's schema.\n *\n * @return {Schema} This Mapper's schema.\n */\n getSchema () {\n return this.schema\n },\n\n /**\n * Defines a hasMany relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasMany(Post, {\n * localField: 'my_posts'\n * })\n * ```\n *\n * @name Mapper#hasMany\n * @method\n */\n hasMany (relatedMapper, opts) {\n return hasMany(relatedMapper, opts)(this)\n },\n\n /**\n * Defines a hasOne relationship. Only useful if you're managing your\n * Mappers manually and not using a Container or DataStore component.\n *\n * ```\n * User.hasOne(Profile, {\n * localField: '_profile'\n * })\n * ```\n *\n * @name Mapper#hasOne\n * @method\n */\n hasOne (relatedMapper, opts) {\n return hasOne(relatedMapper, opts)(this)\n },\n\n /**\n * Return whether `record` is an instance of this Mapper's recordClass.\n *\n * @name Mapper#is\n * @method\n * @param {Object} record The record to check.\n * @return {boolean} Whether `record` is an instance of this Mapper's\n * {@link Mapper#recordClass}.\n */\n is (record) {\n const recordClass = this.recordClass\n return recordClass ? record instanceof recordClass : false\n },\n\n /**\n * Register an adapter on this mapper under the given name.\n *\n * @name Mapper#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for this Mapper.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.defaultAdapter = name\n }\n },\n\n /**\n * Using the `query` argument, select records to pull from an adapter.\n * Expects back from the adapter the array of selected records.\n *\n * {@link Mapper#beforeSum} will be called before calling the adapter.\n * {@link Mapper#afterSum} will be called after calling the adapter.\n *\n * @name Mapper#sum\n * @method\n * @param {string} field The field to sum.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * resulting data. If `true` return a response object that includes the\n * resulting data and metadata about the operation.\n * @return {Promise}\n */\n sum (field, query, opts) {\n return this.crud('sum', field, query, opts)\n },\n\n /**\n * Return a plain object representation of the given record.\n *\n * @name Mapper#toJSON\n * @method\n * @param {Object} record Record from which to create a plain object\n * representation.\n * @param {Object} [opts] Configuration options.\n * @param {string[]} [opts.with] Array of relation names or relation fields\n * to include in the representation.\n * @return {Object} Plain object representation of the record.\n */\n toJSON (record, opts) {\n const self = this\n opts || (opts = {})\n const relationFields = (self ? self.relationFields : []) || []\n let json = {}\n let properties\n if (self && self.schema) {\n properties = self.schema.properties || {}\n // TODO: Make this work recursively\n utils.forOwn(properties, function (opts, prop) {\n json[prop] = utils.plainCopy(record[prop])\n })\n }\n properties || (properties = {})\n if (!opts.strict) {\n for (var key in record) {\n if (!properties[key] && relationFields.indexOf(key) === -1) {\n json[key] = utils.plainCopy(record[key])\n }\n }\n }\n // The user wants to include relations in the resulting plain object\n // representation\n if (self && opts.withAll) {\n opts.with = relationFields.slice()\n }\n if (self && opts.with) {\n if (utils.isString(opts.with)) {\n opts.with = [opts.with]\n }\n utils.forEachRelation(self, opts, function (def, optsCopy) {\n const relationData = def.getLocalField(record)\n if (relationData) {\n // The actual recursion\n if (utils.isArray(relationData)) {\n def.setLocalField(json, relationData.map(function (item) {\n return def.getRelation().toJSON(item, optsCopy)\n }))\n } else {\n def.setLocalField(json, def.getRelation().toJSON(relationData, optsCopy))\n }\n }\n })\n }\n return json\n },\n\n /**\n * Using an adapter, update the record with the primary key specified by the\n * `id` argument.\n *\n * {@link Mapper#beforeUpdate} will be called before updating the record.\n * {@link Mapper#afterUpdate} will be called after updating the record.\n *\n * @name Mapper#update\n * @method\n * @param {(string|number)} id The primary key of the record to update.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n update (id, props, opts) {\n return this.crud('update', id, props, opts)\n },\n\n /**\n * Using the `query` argument, perform the a single updated to the selected\n * records. Expects back from the adapter an array of the updated records.\n *\n * {@link Mapper#beforeUpdateAll} will be called before making the update.\n * {@link Mapper#afterUpdateAll} will be called after making the update.\n *\n * @name Mapper#updateAll\n * @method\n * @param {Object} props Update to apply to selected records.\n * @param {Object} [query={}] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {number} [query.skip] Number to skip.\n * @param {number} [query.limit] Number to limit to.\n * @param {Array} [query.orderBy] Sorting criteria.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if `props` contains nested updates to relations. NOT performed in a\n * transaction.\n * @return {Promise}\n */\n updateAll (props, query, opts) {\n return this.crud('updateAll', props, query, opts)\n },\n\n /**\n * Given an array of updates, perform each of the updates via an adapter. Each\n * \"update\" is a hash of properties with which to update an record. Each\n * update must contain the primary key to be updated.\n *\n * {@link Mapper#beforeUpdateMany} will be called before making the update.\n * {@link Mapper#afterUpdateMany} will be called after making the update.\n *\n * @name Mapper#updateMany\n * @method\n * @param {Array} records Array up record updates.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.adapter={@link Mapper#defaultAdapter}] Name of the\n * adapter to use.\n * @param {boolean} [opts.notify={@link Mapper#notify}] Whether to emit\n * lifecycle events.\n * @param {boolean} [opts.raw={@link Mapper#raw}] If `false`, return the\n * updated data. If `true` return a response object that includes the updated\n * data and metadata about the operation.\n * @param {string[]} [opts.with=[]] Relations to update in a cascading\n * update if each record update contains nested updates for relations. NOT\n * performed in a transaction.\n * @return {Promise}\n */\n updateMany (records, opts) {\n return this.crud('updateMany', records, opts)\n },\n\n /**\n * Validate the given record or records according to this Mapper's\n * {@link Schema}. No return value means no errors.\n *\n * @name Mapper#validate\n * @method\n * @param {Object|Array} record The record or records to validate.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Schema#validate}.\n * @return {Array} Array of errors or undefined if no errors.\n */\n validate (record, opts) {\n const self = this\n const schema = self.getSchema()\n if (utils.isArray(record)) {\n const errors = record.map(function (_record) {\n return schema.validate(_record, opts)\n })\n let hasErrors = false\n errors.forEach(function (err) {\n if (err) {\n hasErrors = true\n }\n })\n if (hasErrors) {\n return errors\n }\n return undefined\n }\n return schema.validate(record, opts)\n },\n\n /**\n * Method used to wrap data returned by an adapter with this Mapper's Record\n * class.\n *\n * @name Mapper#wrap\n * @method\n * @param {Object|Array} data The data to be wrapped.\n * @param {Object} [opts] Configuration options. Passed to {@link Mapper#createRecord}.\n * @return {Object|Array}\n */\n wrap (data, opts) {\n return this.createRecord(data, opts)\n }\n})\n","import utils from './utils'\nimport Component from './Component'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Mapper from './Mapper'\n\nconst DOMAIN = 'Container'\n\nconst toProxy = [\n /**\n * Proxy for {@link Mapper#count}.\n *\n * @name Container#count\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.count}.\n * @param {Object} [opts] - Passed to {@link Model.count}.\n * @return {Promise}\n */\n 'count',\n\n /**\n * Proxy for {@link Mapper#create}.\n *\n * @name Container#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n 'create',\n\n /**\n * Proxy for {@link Mapper#createMany}.\n *\n * @name Container#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n 'createMany',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#createRecord\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} props Passed to {@link Mapper#createRecord}.\n * @param {Object} [opts] Passed to {@link Mapper#createRecord}. See\n * {@link Mapper#createRecord} for configuration options.\n * @return {Promise}\n */\n 'createRecord',\n\n /**\n * Proxy for {@link Mapper#dbg}.\n *\n * @name Container#dbg\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#dbg}.\n */\n 'dbg',\n\n /**\n * Proxy for {@link Mapper#destroy}.\n *\n * @name Container#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n 'destroy',\n\n /**\n * Proxy for {@link Mapper#destroyAll}.\n *\n * @name Container#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n 'destroyAll',\n\n /**\n * Proxy for {@link Mapper#find}.\n *\n * @name Container#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n 'find',\n\n /**\n * Proxy for {@link Mapper#createRecord}.\n *\n * @name Container#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n 'findAll',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#getSchema\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n */\n 'getSchema',\n\n /**\n * Proxy for {@link Mapper#is}.\n *\n * @name Container#is\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#is}.\n */\n 'is',\n\n /**\n * Proxy for {@link Mapper#log}.\n *\n * @name Container#log\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#log}.\n */\n 'log',\n\n /**\n * Proxy for {@link Mapper#sum}.\n *\n * @name Container#sum\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {string} field - Passed to {@link Model.sum}.\n * @param {Object} [query] - Passed to {@link Model.sum}.\n * @param {Object} [opts] - Passed to {@link Model.sum}.\n * @return {Promise}\n */\n 'sum',\n\n /**\n * Proxy for {@link Mapper#toJSON}.\n *\n * @name Container#toJSON\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {...*} args - Passed to {@link Mapper#toJSON}.\n */\n 'toJSON',\n\n /**\n * Proxy for {@link Mapper#update}.\n *\n * @name Container#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n 'update',\n\n /**\n * Proxy for {@link Mapper#updateAll}.\n *\n * @name Container#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object?} query - Passed to {@link Model.updateAll}.\n * @param {Object} props - Passed to {@link Model.updateAll}.\n * @param {Object} [opts] - Passed to {@link Model.updateAll}. See\n * {@link Model.updateAll} for more configuration options.\n * @return {Promise}\n */\n 'updateAll',\n\n /**\n * Proxy for {@link Mapper#updateMany}.\n *\n * @name Container#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n 'updateMany'\n]\n\nconst props = {\n constructor: function Container (opts) {\n const self = this\n utils.classCallCheck(self, Container)\n Container.__super__.call(self)\n opts || (opts = {})\n\n // Apply options provided by the user\n utils.fillIn(self, opts)\n /**\n * Defaults options to pass to {@link Container#mapperClass} when creating a\n * new mapper.\n *\n * @name Container#mapperDefaults\n * @type {Object}\n */\n self.mapperDefaults = self.mapperDefaults || {}\n /**\n * Constructor function to use in {@link Container#defineMapper} to create a\n * new mapper.\n *\n * @name Container#mapperClass\n * @type {Function}\n */\n self.mapperClass = self.mapperClass || Mapper\n\n // Initilize private data\n\n // Holds the adapters, shared by all mappers in this container\n self._adapters = {}\n // The the mappers in this container\n self._mappers = {}\n },\n\n /**\n * Register a new event listener on this Container.\n *\n * Proxy for {@link Component#on}. If an event was emitted by a Mapper in the\n * Container, then the name of the Mapper will be prepended to the arugments\n * passed to the listener.\n *\n * @name Container#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by mappers in this container.\n *\n * @name Container#_onMapperEvent\n * @method\n * @private\n * @param {string} name Name of the mapper that emitted the event.\n * @param {...*} [args] Args passed to {@link Mapper#emit}.\n */\n _onMapperEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * Create a new mapper and register it in this container.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container({\n * mapperDefaults: { foo: 'bar' }\n * })\n * const userMapper = container.defineMapper('user')\n * userMapper.foo // \"bar\"\n *\n * @name Container#defineMapper\n * @method\n * @param {string} name Name under which to register the new {@link Mapper}.\n * {@link Mapper#name} will be set to this value.\n * @param {Object} [opts] Configuration options. Passed to\n * {@link Container#mapperClass} when creating the new {@link Mapper}.\n * @return {Mapper}\n */\n defineMapper (name, opts) {\n const self = this\n\n // For backwards compatibility with defineResource\n if (utils.isObject(name)) {\n opts = name\n name = opts.name\n }\n if (!utils.isString(name)) {\n throw utils.err(`${DOMAIN}#defineMapper`, 'name')(400, 'string', name)\n }\n\n // Default values for arguments\n opts || (opts = {})\n // Set Mapper#name\n opts.name = name\n opts.relations || (opts.relations = {})\n\n // Check if the user is overriding the datastore's default mapperClass\n const mapperClass = opts.mapperClass || self.mapperClass\n delete opts.mapperClass\n\n // Apply the datastore's defaults to the options going into the mapper\n utils.fillIn(opts, self.mapperDefaults)\n\n // Instantiate a mapper\n const mapper = self._mappers[name] = new mapperClass(opts) // eslint-disable-line\n mapper.relations || (mapper.relations = {})\n // Make sure the mapper's name is set\n mapper.name = name\n // All mappers in this datastore will share adapters\n mapper._adapters = self.getAdapters()\n\n mapper.datastore = self\n\n mapper.on('all', function (...args) {\n self._onMapperEvent(name, ...args)\n })\n\n // Setup the mapper's relations, including generating Mapper#relationList\n // and Mapper#relationFields\n utils.forOwn(mapper.relations, function (group, type) {\n utils.forOwn(group, function (relations, _name) {\n if (utils.isObject(relations)) {\n relations = [relations]\n }\n relations.forEach(function (def) {\n def.getRelation = function () {\n return self.getMapper(_name)\n }\n const relatedMapper = self._mappers[_name] || _name\n if (type === belongsToType) {\n mapper.belongsTo(relatedMapper, def)\n } else if (type === hasOneType) {\n mapper.hasOne(relatedMapper, def)\n } else if (type === hasManyType) {\n mapper.hasMany(relatedMapper, def)\n }\n })\n })\n })\n\n return mapper\n },\n\n defineResource (name, opts) {\n return this.defineMapper(name, opts)\n },\n\n /**\n * Return the registered adapter with the given name or the default adapter if\n * no name is provided.\n *\n * @name Container#getAdapter\n * @method\n * @param {string} [name] The name of the adapter to retrieve.\n * @return {Adapter} The adapter.\n */\n getAdapter (name) {\n const self = this\n const adapter = self.getAdapterName(name)\n if (!adapter) {\n throw utils.err(`${DOMAIN}#getAdapter`, 'name')(400, 'string', name)\n }\n return self.getAdapters()[adapter]\n },\n\n /**\n * Return the name of a registered adapter based on the given name or options,\n * or the name of the default adapter if no name provided.\n *\n * @name Container#getAdapterName\n * @method\n * @param {(Object|string)} [opts] The name of an adapter or options, if any.\n * @return {string} The name of the adapter.\n */\n getAdapterName (opts) {\n opts || (opts = {})\n if (utils.isString(opts)) {\n opts = { adapter: opts }\n }\n return opts.adapter || this.mapperDefaults.defaultAdapter\n },\n\n /**\n * Return the registered adapters of this container.\n *\n * @name Container#getAdapters\n * @method\n * @return {Adapter}\n */\n getAdapters () {\n return this._adapters\n },\n\n /**\n * Return the mapper registered under the specified name.\n *\n * @example\n * import {Container} from 'js-data'\n * const container = new Container()\n * const userMapper = container.defineMapper('user')\n * userMapper === container.getMapper('user') // true\n *\n * @name Container#getMapper\n * @method\n * @param {string} name {@link Mapper#name}.\n * @return {Mapper}\n */\n getMapper (name) {\n const mapper = this._mappers[name]\n if (!mapper) {\n throw utils.err(`${DOMAIN}#getMapper`, name)(404, 'mapper')\n }\n return mapper\n },\n\n /**\n * Register an adapter on this container under the given name. Adapters\n * registered on a container are shared by all mappers in the container.\n *\n * @example\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * container.registerAdapter('http', new HttpAdapter, { default: true })\n *\n * @name Container#registerAdapter\n * @method\n * @param {string} name The name of the adapter to register.\n * @param {Adapter} adapter The adapter to register.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.default=false] Whether to make the adapter the\n * default adapter for all Mappers in this container.\n */\n registerAdapter (name, adapter, opts) {\n const self = this\n opts || (opts = {})\n self.getAdapters()[name] = adapter\n // Optionally make it the default adapter for the target.\n if (opts === true || opts.default) {\n self.mapperDefaults.defaultAdapter = name\n utils.forOwn(self._mappers, function (mapper) {\n mapper.defaultAdapter = name\n })\n }\n }\n}\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getMapper(name)[method](...args)\n }\n})\n\n/**\n * ```javascript\n * import {Container} from 'js-data'\n * ```\n *\n * The `Container` class is a place to store {@link Mapper} instances.\n *\n * Without a container, you need to manage mappers yourself, including resolving\n * circular dependencies among relations. All mappers in a container share the\n * same adapters, so you don't have to add each adapter to all of your mappers.\n *\n * @example Without Container\n * import {Mapper} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const adapter = new HttpAdapter()\n * const userMapper = new Mapper({ name: 'user' })\n * userMapper.registerAdapter('http', adapter, { default: true })\n * const commentMapper = new Mapper({ name: 'comment' })\n * commentMapper.registerAdapter('http', adapter, { default: true })\n *\n * // This might be more difficult if the mappers were defined in different\n * // modules.\n * userMapper.hasMany(commentMapper, {\n * localField: 'comments',\n * foreignKey: 'userId'\n * })\n * commentMapper.belongsTo(userMapper, {\n * localField: 'user',\n * foreignKey: 'userId'\n * })\n *\n * @example With Container\n * import {Container} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const container = new Container()\n * // All mappers in container share adapters\n * container.registerAdapter('http', new HttpAdapter(), { default: true })\n *\n * // These could be defined in separate modules without a problem.\n * container.defineMapper('user', {\n * relations: {\n * hasMany: {\n * comment: {\n * localField: 'comments',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n * container.defineMapper('comment', {\n * relations: {\n * belongsTo: {\n * user: {\n * localField: 'user',\n * foreignKey: 'userId'\n * }\n * }\n * }\n * })\n *\n * @class Container\n * @extends Component\n * @param {Object} [opts] Configuration options.\n * @param {Function} [opts.mapperClass] Constructor function to use in\n * {@link Container#defineMapper} to create a new mapper.\n * @param {Object} [opts.mapperDefaults] Defaults options to pass to\n * {@link Container#mapperClass} when creating a new mapper.\n * @return {Container}\n */\nexport default Component.extend(props)\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Collection from './Collection'\n\nconst DOMAIN = 'LinkedCollection'\n\n/**\n * TODO\n *\n * ```javascript\n * import {LinkedCollection} from 'js-data'\n * ```\n *\n * @class LinkedCollection\n * @extends Collection\n * @param {Array} [records] Initial set of records to insert into the\n * collection. See {@link Collection}.\n * @param {Object} [opts] Configuration options. See {@link Collection}.\n * @return {Mapper}\n */\nexport default Collection.extend({\n constructor: function LinkedCollection (records, opts) {\n const self = this\n utils.classCallCheck(self, LinkedCollection)\n LinkedCollection.__super__.call(self, records, opts)\n\n // Make sure this collection has somewhere to store \"added\" timestamps\n Object.defineProperty(self, '_added', {\n value: {}\n })\n\n // Make sure this collection has a reference to a datastore\n if (!self.datastore) {\n throw utils.err(`new ${DOMAIN}`, 'opts.datastore')(400, 'DataStore', self.datastore)\n }\n return self\n },\n\n _onRecordEvent (...args) {\n const self = this\n utils.getSuper(self).prototype._onRecordEvent.apply(self, args)\n const event = args[0]\n // This is a very brute force method\n // Lots of room for optimization\n if (utils.isString(event) && event.indexOf('change') === 0) {\n self.updateIndexes(args[1])\n }\n },\n\n add (records, opts) {\n const self = this\n const datastore = self.datastore\n const mapper = self.mapper\n const relationList = mapper.relationList\n const timestamp = new Date().getTime()\n const usesRecordClass = !!mapper.recordClass\n const idAttribute = mapper.idAttribute\n let singular\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n\n records = utils.getSuper(self).prototype.add.call(self, records, opts)\n\n if (relationList.length && records.length) {\n // Check the currently visited record for relations that need to be\n // inserted into their respective collections.\n mapper.relationList.forEach(function (def) {\n const relationName = def.relation\n // A reference to the Mapper that this Mapper is related to\n const relatedMapper = datastore.getMapper(relationName)\n // The field used by the related Mapper as the primary key\n const relationIdAttribute = relatedMapper.idAttribute\n // Grab the foreign key in this relationship, if there is one\n const foreignKey = def.foreignKey\n // A lot of this is an optimization for being able to insert a lot of\n // data as quickly as possible\n const relatedCollection = datastore.getCollection(relationName)\n const type = def.type\n const isHasMany = type === hasManyType\n const shouldAdd = utils.isUndefined(def.add) ? true : !!def.add\n let relatedData\n\n records.forEach(function (record) {\n // Grab a reference to the related data attached or linked to the\n // currently visited record\n relatedData = def.getLocalField(record)\n const id = utils.get(record, idAttribute)\n\n if (utils.isFunction(def.add)) {\n relatedData = def.add(datastore, def, record)\n } else if (relatedData) {\n // Otherwise, if there is something to be added, add it\n if (isHasMany) {\n // Handle inserting hasMany relations\n relatedData = relatedData.map(function (toInsertItem) {\n // Check that this item isn't the same item that is already in the\n // store\n if (toInsertItem !== relatedCollection.get(relatedCollection.recordId(toInsertItem))) {\n // Make sure this item has its foreignKey\n if (foreignKey) {\n // TODO: slow, could be optimized? But user loses hook\n def.setForeignKey(record, toInsertItem)\n }\n // Finally add this related item\n if (shouldAdd) {\n toInsertItem = relatedCollection.add(toInsertItem)\n }\n }\n return toInsertItem\n })\n } else {\n const relatedDataId = utils.get(relatedData, relationIdAttribute)\n // Handle inserting belongsTo and hasOne relations\n if (relatedData !== relatedCollection.get(relatedDataId)) {\n // Make sure foreignKey field is set\n def.setForeignKey(record, relatedData)\n // Finally insert this related item\n if (shouldAdd) {\n relatedData = relatedCollection.add(relatedData)\n }\n }\n }\n }\n\n if (!relatedData || (utils.isArray(relatedData) && !relatedData.length)) {\n if (type === belongsToType) {\n const relatedId = utils.get(record, foreignKey)\n if (!utils.isUndefined(relatedId)) {\n relatedData = relatedCollection.get(relatedId)\n }\n } else if (type === hasOneType) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records[0] : undefined\n } else if (type === hasManyType) {\n if (foreignKey) {\n const _records = relatedCollection.filter({\n [foreignKey]: id\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.localKeys && utils.get(record, def.localKeys)) {\n const _records = relatedCollection.filter({\n where: {\n [relationIdAttribute]: {\n 'in': utils.get(record, def.localKeys)\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n } else if (def.foreignKeys) {\n const _records = relatedCollection.filter({\n where: {\n [def.foreignKeys]: {\n 'contains': id\n }\n }\n })\n relatedData = _records.length ? _records : undefined\n }\n }\n }\n if (relatedData) {\n def.setLocalField(record, relatedData)\n } else {\n }\n })\n })\n }\n\n records.forEach(function (record) {\n // Track when this record was added\n self._added[self.recordId(record)] = timestamp\n\n if (usesRecordClass) {\n record._set('$', timestamp)\n }\n })\n\n return singular ? records[0] : records\n },\n\n remove (id, opts) {\n const self = this\n const mapper = self.mapper\n const record = utils.getSuper(self).prototype.remove.call(self, id, opts)\n if (record) {\n delete self._added[id]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n }\n return record\n },\n\n removeAll (query, opts) {\n const self = this\n const mapper = self.mapper\n const records = utils.getSuper(self).prototype.removeAll.call(self, query, opts)\n records.forEach(function (record) {\n delete self._added[self.recordId(record)]\n if (mapper.recordClass) {\n record._set('$') // unset\n }\n })\n return records\n }\n})\n","import utils from './utils'\nimport {\n belongsToType,\n hasManyType,\n hasOneType\n} from './decorators'\nimport Container from './Container'\nimport LinkedCollection from './LinkedCollection'\n\nconst DOMAIN = 'DataStore'\nconst DATASTORE_DEFAULTS = {}\n\nconst safeSet = function (record, field, value) {\n if (record && record._set) {\n record._set(field, value)\n } else {\n utils.set(record, field, value)\n }\n}\n\nconst cachedFn = function (name, hashOrId, opts) {\n const self = this\n const cached = self._completedQueries[name][hashOrId]\n if (utils.isFunction(cached)) {\n return cached(name, hashOrId, opts)\n }\n return cached\n}\n\nconst props = {\n constructor: function DataStore (opts) {\n const self = this\n utils.classCallCheck(self, DataStore)\n DataStore.__super__.call(self, opts)\n\n self.collectionClass = self.collectionClass || LinkedCollection\n self._collections = {}\n utils.fillIn(self, DATASTORE_DEFAULTS)\n self._pendingQueries = {}\n self._completedQueries = {}\n return self\n },\n\n _callSuper (method, ...args) {\n return this.constructor.__super__.prototype[method].apply(this, args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#_end\n * @method\n * @private\n * @param {string} name Name of the {@link LinkedCollection} to which to\n * add the data.\n * @param {Object} data TODO.\n * @param {Object} [opts] Configuration options.\n * @return {(Object|Array)} Result.\n */\n _end (name, result, opts) {\n let _data = opts.raw ? result.data : result\n if (_data && utils.isFunction(this.addToCache)) {\n _data = this.addToCache(name, _data, opts)\n if (opts.raw) {\n result.data = _data\n } else {\n result = _data\n }\n }\n return result\n },\n\n /**\n * Register a new event listener on this DataStore.\n *\n * Proxy for {@link Container#on}. If an event was emitted by a Mapper or\n * Collection in the DataStore, then the name of the Mapper or Collection will\n * be prepended to the arugments passed to the provided event handler.\n *\n * @name DataStore#on\n * @method\n * @param {string} event Name of event to subsribe to.\n * @param {Function} listener Listener function to handle the event.\n * @param {*} [ctx] Optional content in which to invoke the listener.\n */\n\n /**\n * Used to bind to events emitted by collections in this store.\n *\n * @name DataStore#_onCollectionEvent\n * @method\n * @private\n * @param {string} name Name of the collection that emitted the event.\n * @param {...*} [args] Args passed to {@link Collection#emit}.\n */\n _onCollectionEvent (name, ...args) {\n const type = args.shift()\n this.emit(type, name, ...args)\n },\n\n /**\n * TODO\n *\n * @name DataStore#addToCache\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {*} data - Data from which data should be selected for add.\n * @param {Object} [opts] - Configuration options.\n */\n addToCache (name, data, opts) {\n return this.getCollection(name).add(data, opts)\n },\n\n /**\n * Retrieve a cached `find` result, if any.\n *\n * @name DataStore#cachedFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cachedFind: cachedFn,\n\n /**\n * Retrieve a cached `findAll` result, if any.\n *\n * @name DataStore#cachedFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cachedFindAll: cachedFn,\n\n /**\n * Cache a `find` result. The default implementation does the following:\n *\n * ```\n * // Find and return the record from the data store\n * return this.get(name, id)\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFind\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#find}.\n * @param {*} data The result to cache.\n * @param {(string|number)} id The `id` argument passed to {@link DataStore#find}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#find}.\n */\n cacheFind (name, data, id, opts) {\n const self = this\n self._completedQueries[name][id] = function (name, id, opts) {\n return self.get(name, id)\n }\n },\n\n /**\n * Cache a `findAll` result. The default implementation does the following:\n *\n * ```\n * // Find and return the records from the data store\n * return this.filter(name, utils.fromJson(hash))\n * ```\n *\n * Override this method to customize.\n *\n * @name DataStore#cacheFindAll\n * @method\n * @param {string} name The `name` argument passed to {@link DataStore#findAll}.\n * @param {*} data The result to cache.\n * @param {string} hash The result of calling {@link DataStore#hashQuery} on\n * the `query` argument passed to {@link DataStore#findAll}.\n * @param {Object} opts The `opts` argument passed to {@link DataStore#findAll}.\n */\n cacheFindAll (name, data, hash, opts) {\n const self = this\n self._completedQueries[name][hash] = function (name, hash, opts) {\n return self.filter(name, utils.fromJson(hash))\n }\n },\n\n /**\n * TODO\n *\n * @name DataStore#create\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Object} record Passed to {@link Mapper#create}.\n * @param {Object} [opts] Passed to {@link Mapper#create}. See\n * {@link Mapper#create} for more configuration options.\n * @return {Promise}\n */\n create (name, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('create', name, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#createMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {Array} records Passed to {@link Mapper#createMany}.\n * @param {Object} [opts] Passed to {@link Mapper#createMany}. See\n * {@link Mapper#createMany} for more configuration options.\n * @return {Promise}\n */\n createMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('createMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n defineMapper (name, opts) {\n const self = this\n const mapper = utils.getSuper(self).prototype.defineMapper.call(self, name, opts)\n self._pendingQueries[name] = {}\n self._completedQueries[name] = {}\n mapper.relationList || Object.defineProperty(mapper, 'relationList', { value: [] })\n\n // The datastore uses a subclass of Collection that is \"datastore-aware\"\n const collection = self._collections[name] = new self.collectionClass(null, { // eslint-disable-line\n // Make sure the collection has somewhere to store \"added\" timestamps\n _added: {},\n // Give the collection a reference to this datastore\n datastore: self,\n // The mapper tied to the collection\n mapper\n })\n\n const schema = mapper.schema || {}\n const properties = schema.properties || {}\n // TODO: Make it possible index nested properties?\n utils.forOwn(properties, function (opts, prop) {\n if (opts.indexed) {\n collection.createIndex(prop)\n }\n })\n\n // Create a secondary index on the \"added\" timestamps of records in the\n // collection\n collection.createIndex('addedTimestamps', ['$'], {\n fieldGetter (obj) {\n return collection._added[collection.recordId(obj)]\n }\n })\n\n collection.on('all', function (...args) {\n self._onCollectionEvent(name, ...args)\n })\n\n const idAttribute = mapper.idAttribute\n\n mapper.relationList.forEach(function (def) {\n const relation = def.relation\n const localField = def.localField\n const path = `links.${localField}`\n const foreignKey = def.foreignKey\n const type = def.type\n const updateOpts = { index: foreignKey }\n let descriptor\n\n const getter = function () { return this._get(path) }\n\n if (type === belongsToType) {\n if (!collection.indexes[foreignKey]) {\n collection.createIndex(foreignKey)\n }\n\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const id = utils.get(_self, idAttribute)\n const inverseDef = def.getInverse(mapper)\n\n if (record) {\n const relatedIdAttribute = def.getRelation().idAttribute\n const relatedId = utils.get(record, relatedIdAttribute)\n\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n safeSet(_self, foreignKey, relatedId)\n collection.updateIndex(_self, updateOpts)\n\n // Update (set) inverse relation\n if (inverseDef.type === hasOneType) {\n utils.set(record, inverseDef.localField, _self)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(record, inverseDef.localField)\n utils.noDupeAdd(children, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n } else {\n // Unset locals\n _self._set(path, undefined)\n safeSet(_self, foreignKey, undefined)\n collection.updateIndex(_self, updateOpts)\n }\n if (current) {\n if (inverseDef.type === hasOneType) {\n utils.set(current, inverseDef.localField, undefined)\n } else if (inverseDef.type === hasManyType) {\n const children = utils.get(current, inverseDef.localField)\n utils.remove(children, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n }\n }\n return record\n }\n }\n\n if (mapper.recordClass.prototype.hasOwnProperty(foreignKey)) {\n const superClass = mapper.recordClass\n mapper.recordClass = superClass.extend({\n constructor: (function () {\n var subClass = function Record (props, opts) {\n utils.classCallCheck(this, subClass)\n superClass.call(this, props, opts)\n }\n return subClass\n })()\n })\n }\n Object.defineProperty(mapper.recordClass.prototype, foreignKey, {\n enumerable: true,\n get () { return this._get(foreignKey) },\n set (value) {\n const _self = this\n if (utils.isUndefined(value)) {\n // Unset locals\n utils.set(_self, localField, undefined)\n } else {\n safeSet(_self, foreignKey, value)\n let storeRecord = self.get(relation, value)\n if (storeRecord) {\n utils.set(_self, localField, storeRecord)\n }\n }\n }\n })\n } else if (type === hasManyType) {\n const localKeys = def.localKeys\n const foreignKeys = def.foreignKeys\n\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n\n descriptor = {\n get () {\n const _self = this\n let current = getter.call(_self)\n if (!current) {\n _self._set(path, [])\n }\n return getter.call(_self)\n },\n set (records) {\n const _self = this\n records || (records = [])\n if (records && !utils.isArray(records)) {\n records = [records]\n }\n const id = utils.get(_self, idAttribute)\n const relatedIdAttribute = def.getRelation().idAttribute\n const inverseDef = def.getInverse(mapper)\n const inverseLocalField = inverseDef.localField\n let linked = _self._get(path)\n if (!linked) {\n linked = []\n }\n\n const current = linked\n linked = []\n const toLink = {}\n records.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId)) {\n // Prefer store record\n record = self.get(relation, relatedId) || record\n toLink[relatedId] = record\n }\n linked.push(record)\n })\n if (foreignKey) {\n records.forEach(function (record) {\n // Update (set) inverse relation\n safeSet(record, foreignKey, id)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n })\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update (unset) inverse relation\n safeSet(record, foreignKey, undefined)\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (localKeys) {\n const _localKeys = []\n records.forEach(function (record) {\n // Update (set) inverse relation\n utils.set(record, inverseLocalField, _self)\n _localKeys.push(utils.get(record, relatedIdAttribute))\n })\n // Update locals\n utils.set(_self, localKeys, _localKeys)\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const relatedId = utils.get(record, relatedIdAttribute)\n if (!utils.isUndefined(relatedId) && !toLink.hasOwnProperty(relatedId)) {\n // Update inverse relation\n utils.set(record, inverseLocalField, undefined)\n }\n })\n } else if (foreignKeys) {\n // Update (unset) inverse relation\n current.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.remove(_localKeys, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.remove(_localField, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n // Update (set) inverse relation\n records.forEach(function (record) {\n const _localKeys = utils.get(record, foreignKeys) || []\n utils.noDupeAdd(_localKeys, id, function (_key) {\n return id === _key\n })\n const _localField = utils.get(record, inverseLocalField) || []\n utils.noDupeAdd(_localField, _self, function (_record) {\n return id === utils.get(_record, idAttribute)\n })\n })\n }\n\n _self._set(path, linked)\n return linked\n }\n }\n } else if (type === hasOneType) {\n // TODO: Handle case when belongsTo relation isn't ever defined\n if (self._collections[relation] && foreignKey && !self.getCollection(relation).indexes[foreignKey]) {\n self.getCollection(relation).createIndex(foreignKey)\n }\n descriptor = {\n get: getter,\n set (record) {\n const _self = this\n const current = this._get(path)\n if (record === current) {\n return current\n }\n const relatedId = utils.get(record, def.getRelation().idAttribute)\n const inverseLocalField = def.getInverse(mapper).localField\n // Update (unset) inverse relation\n if (current) {\n safeSet(current, foreignKey, undefined)\n self.getCollection(relation).updateIndex(current, updateOpts)\n utils.set(current, inverseLocalField, undefined)\n }\n if (record) {\n // Prefer store record\n if (!utils.isUndefined(relatedId)) {\n record = self.get(relation, relatedId) || record\n }\n\n // Set locals\n _self._set(path, record)\n\n // Update (set) inverse relation\n safeSet(record, foreignKey, utils.get(_self, idAttribute))\n self.getCollection(relation).updateIndex(record, updateOpts)\n utils.set(record, inverseLocalField, _self)\n } else {\n // Set locals\n _self._set(path, undefined)\n }\n return record\n }\n }\n }\n\n if (descriptor) {\n descriptor.enumerable = utils.isUndefined(def.enumerable) ? true : def.enumerable\n if (def.get) {\n let origGet = descriptor.get\n descriptor.get = function () {\n return def.get(def, this, (...args) => origGet.apply(this, args))\n }\n }\n if (def.set) {\n let origSet = descriptor.set\n descriptor.set = function (related) {\n return def.set(def, this, related, (value) => origSet.call(this, value === undefined ? related : value))\n }\n }\n Object.defineProperty(mapper.recordClass.prototype, localField, descriptor)\n }\n })\n\n return mapper\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroy\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#destroy}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroy}. See\n * {@link Mapper#destroy} for more configuration options.\n * @return {Promise}\n */\n destroy (name, id, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroy', name, id, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).remove(id, opts)\n } else {\n data = self.getCollection(name).remove(id, opts)\n }\n delete self._pendingQueries[name][id]\n delete self._completedQueries[name][id]\n return data\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#destroyAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Mapper#destroyAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#destroyAll}. See\n * {@link Mapper#destroyAll} for more configuration options.\n * @return {Promise}\n */\n destroyAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('destroyAll', name, query, opts).then(function (data) {\n if (opts.raw) {\n data.data = self.getCollection(name).removeAll(query, opts)\n } else {\n data = self.getCollection(name).removeAll(query, opts)\n }\n const hash = self.hashQuery(name, query, opts)\n delete self._pendingQueries[name][hash]\n delete self._completedQueries[name][hash]\n return data\n })\n },\n\n eject (id, opts) {\n return this.remove(id, opts)\n },\n\n ejectAll (query, opts) {\n return this.removeAll(query, opts)\n },\n\n /**\n * TODO\n *\n * @name DataStore#find\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#find}.\n * @param {Object} [opts] - Passed to {@link Mapper#find}.\n * @return {Promise}\n */\n find (name, id, opts) {\n const self = this\n opts || (opts = {})\n const pendingQuery = self._pendingQueries[name][id]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n const item = self.cachedFind(name, id, opts)\n let promise\n\n if (opts.force || !item) {\n promise = self._pendingQueries[name][id] = self._callSuper('find', name, id, opts).then(function (data) {\n delete self._pendingQueries[name][id]\n const result = self._end(name, data, opts)\n self.cacheFind(name, result, id, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][id]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(item)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#findAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} [query] - Passed to {@link Model.findAll}.\n * @param {Object} [opts] - Passed to {@link Model.findAll}.\n * @return {Promise}\n */\n findAll (name, query, opts) {\n const self = this\n opts || (opts = {})\n const hash = self.hashQuery(name, query, opts)\n const pendingQuery = self._pendingQueries[name][hash]\n\n utils.fillIn(opts, self.getMapper(name))\n\n if (pendingQuery) {\n return pendingQuery\n }\n\n const items = self.cachedFindAll(name, hash, opts)\n let promise\n\n if (opts.force || !items) {\n promise = self._pendingQueries[name][hash] = self._callSuper('findAll', name, query, opts).then(function (data) {\n delete self._pendingQueries[name][hash]\n const result = self._end(name, data, opts)\n self.cacheFindAll(name, result, hash, opts)\n return result\n }, function (err) {\n delete self._pendingQueries[name][hash]\n return utils.reject(err)\n })\n } else {\n promise = utils.resolve(items)\n }\n return promise\n },\n\n /**\n * TODO\n *\n * @name DataStore#getCollection\n * @method\n * @param {string} name Name of the {@link LinkedCollection} to retrieve.\n * @return {LinkedCollection}\n */\n getCollection (name) {\n const collection = this._collections[name]\n if (!collection) {\n throw utils.err(`${DOMAIN}#getCollection`, name)(404, 'collection')\n }\n return collection\n },\n\n hashQuery (name, query, opts) {\n return utils.toJson(query)\n },\n\n inject (records, opts) {\n return this.add(records, opts)\n },\n\n remove (name, id, opts) {\n const self = this\n const record = self.getCollection(name).remove(id, opts)\n if (record) {\n self.removeRelated(name, [record], opts)\n }\n return record\n },\n\n removeAll (name, query, opts) {\n const self = this\n const records = self.getCollection(name).removeAll(query, opts)\n if (records.length) {\n self.removeRelated(name, records, opts)\n }\n return records\n },\n\n removeRelated (name, records, opts) {\n const self = this\n utils.forEachRelation(self.getMapper(name), opts, function (def, optsCopy) {\n records.forEach(function (record) {\n let relatedData\n let query\n if (def.foreignKey && (def.type === hasOneType || def.type === hasManyType)) {\n query = { [def.foreignKey]: def.getForeignKey(record) }\n } else if (def.type === hasManyType && def.localKeys) {\n query = {\n where: {\n [def.getRelation().idAttribute]: {\n 'in': utils.get(record, def.localKeys)\n }\n }\n }\n } else if (def.type === hasManyType && def.foreignKeys) {\n query = {\n where: {\n [def.foreignKeys]: {\n 'contains': def.getForeignKey(record)\n }\n }\n }\n } else if (def.type === belongsToType) {\n relatedData = self.remove(def.relation, def.getForeignKey(record), optsCopy)\n }\n if (query) {\n relatedData = self.removeAll(def.relation, query, optsCopy)\n }\n if (relatedData) {\n if (utils.isArray(relatedData) && !relatedData.length) {\n return\n }\n if (def.type === hasOneType) {\n relatedData = relatedData[0]\n }\n def.setLocalField(record, relatedData)\n }\n })\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#update\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {(string|number)} id - Passed to {@link Mapper#update}.\n * @param {Object} record - Passed to {@link Mapper#update}.\n * @param {Object} [opts] - Passed to {@link Mapper#update}. See\n * {@link Mapper#update} for more configuration options.\n * @return {Promise}\n */\n update (name, id, record, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('update', name, id, record, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateAll\n * @method\n * @param {string} name - Name of the {@link Mapper} to target.\n * @param {Object} props - Passed to {@link Mapper#updateAll}.\n * @param {Object} [query] - Passed to {@link Mapper#updateAll}.\n * @param {Object} [opts] - Passed to {@link Mapper#updateAll}. See\n * {@link Mapper#updateAll} for more configuration options.\n * @return {Promise}\n */\n updateAll (name, props, query, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateAll', name, query, props, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n },\n\n /**\n * TODO\n *\n * @name DataStore#updateMany\n * @method\n * @param {string} name Name of the {@link Mapper} to target.\n * @param {(Object[]|Record[])} records Passed to {@link Mapper#updateMany}.\n * @param {Object} [opts] Passed to {@link Mapper#updateMany}. See\n * {@link Mapper#updateMany} for more configuration options.\n * @return {Promise}\n */\n updateMany (name, records, opts) {\n const self = this\n opts || (opts = {})\n return self._callSuper('updateMany', name, records, opts).then(function (data) {\n return self._end(name, data, opts)\n })\n }\n}\n\nconst toProxy = [\n 'add',\n 'between',\n 'createIndex',\n 'filter',\n 'get',\n 'getAll',\n 'query',\n 'toJson'\n]\n\ntoProxy.forEach(function (method) {\n props[method] = function (name, ...args) {\n return this.getCollection(name)[method](...args)\n }\n})\n\n/**\n * The `DataStore` class is an extension of {@link Container}. Not only does\n * `DataStore` manage mappers, but also collections. `DataStore` implements the\n * asynchronous {@link Mapper} methods, such as {@link Mapper#find} and\n * {@link Mapper#create}. If you use the asynchronous `DataStore` methods\n * instead of calling them directly on the mappers, then the results of the\n * method calls will be inserted into the store's collections. You can think of\n * a `DataStore` as an [Identity Map](https://en.wikipedia.org/wiki/Identity_map_pattern)\n * for the [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)\n * (the Mappers).\n *\n * ```javascript\n * import {DataStore} from 'js-data'\n * ```\n *\n * @example\n * import {DataStore} from 'js-data'\n * import HttpAdapter from 'js-data-http'\n * const store = new DataStore()\n * const UserMapper = store.defineMapper('user')\n *\n * // Call \"find\" on \"UserMapper\" (Stateless ORM)\n * UserMapper.find(1).then(function (user) {\n * // retrieved a \"user\" record via the http adapter, but that's it\n *\n * // Call \"find\" on \"store\" for the \"user\" mapper (Stateful DataStore)\n * return store.find('user', 1)\n * }).then(function (user) {\n * // not only was a \"user\" record retrieved, but it was added to the\n * // store's \"user\" collection\n * const cachedUser = store.getCollection('user').get(1)\n * user === cachedUser // true\n * })\n *\n * @class DataStore\n * @extends Container\n * @param {Object} [opts] Configuration options. See {@link Container}.\n * @return {DataStore}\n */\nexport default Container.extend(props)\n","/**\n * Registered as `js-data` in NPM and Bower.\n * #### Script tag\n * ```js\n * window.JSData\n * ```\n * #### CommonJS\n * ```js\n * var JSData = require('js-data')\n * ```\n * #### ES6 Modules\n * ```js\n * import JSData from 'js-data'\n * ```\n * #### AMD\n * ```js\n * define('myApp', ['js-data'], function (JSData) { ... })\n * ```\n *\n * @module js-data\n */\n\n/**\n * Details of the current version of the `js-data` module.\n *\n * @name version\n * @memberof module:js-data\n * @type {Object}\n * @property {string} full The full semver value.\n * @property {number} major The major version number.\n * @property {number} minor The minor version number.\n * @property {number} patch The patch version number.\n * @property {(string|boolean)} alpha The alpha version value, otherwise `false`\n * if the current version is not alpha.\n * @property {(string|boolean)} beta The beta version value, otherwise `false`\n * if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\nimport utils from './utils'\n\n/**\n * {@link Collection} class.\n * @name module:js-data.Collection\n */\nimport Collection from './Collection'\n\n/**\n * {@link Component} class.\n * @name module:js-data.Component\n */\nimport Component from './Component'\n\n/**\n * {@link Container} class.\n * @name module:js-data.Container\n */\nimport Container from './Container'\n\n/**\n * {@link DataStore} class.\n * @name module:js-data.DataStore\n */\nimport DataStore from './DataStore'\n\n/**\n * {@link Index} class.\n * @name module:js-data.Index\n */\nimport Index from '../lib/mindex/index'\n\n/**\n * {@link LinkedCollection} class.\n * @name module:js-data.LinkedCollection\n */\nimport LinkedCollection from './LinkedCollection'\n\n/**\n * {@link Mapper} class.\n * @name module:js-data.Mapper\n */\nimport Mapper from './Mapper'\n\n/**\n * {@link Query} class.\n * @name module:js-data.Query\n */\nimport Query from './Query'\n\n/**\n * {@link Record} class.\n * @name module:js-data.Record\n */\nimport Record from './Record'\n\n/**\n * {@link Schema} class.\n * @name module:js-data.Schema\n */\nimport Schema from './Schema'\n\nexport * from './decorators'\n\nexport {\n Collection,\n Component,\n Container,\n DataStore,\n Index,\n LinkedCollection,\n Mapper,\n Query,\n Record,\n Schema,\n utils\n}\n"],"names":["utils","DOMAIN","belongsTo","hasMany","hasOne","props","toProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,EAAA,IAAM,SAAS,OAAT;;AAEN,EAAA,IAAM,WAAW,IAAI,CAAJ;AACjB,EAAA,IAAM,cAAc,uBAAd;AACN,EAAA,IAAM,WAAW,kBAAX;AACN,EAAA,IAAM,WAAW,eAAX;AACN,EAAA,IAAM,WAAW,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AAU,IAAV,EAAgB;AAC7E,EAAA,aAAO,KAAK,IAAL,CAAU,IAAV,EAAgB,IAAhB,EAAsB,IAAtB,CAAP,CAD6E;OAAhB,CAA/D,CAH+B;KA7wBrB;GAAR;;AAsxBN,EAAA,IAAMM,YAAU,CACd,KADc,EAEd,SAFc,EAGd,aAHc,EAId,QAJc,EAKd,KALc,EAMd,QANc,EAOd,OAPc,EAQd,QARc,CAAV;;AAWNA,YAAQ,OAAR,CAAgB,UAAU,MAAV,EAAkB;AAChC,EAAA,UAAM,MAAN,IAAgB,UAAU,IAAV,EAAyB;;;yCAAN;;OAAM;;AACvC,EAAA,WAAO,uBAAK,aAAL,CAAmB,IAAnB,GAAyB,OAAzB,uBAAoC,IAApC,CAAP,CADuC;KAAzB,CADgB;GAAlB,CAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,kBAAe,UAAU,MAAV,CAAiBD,OAAjB,CAAf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACt0BA,EAAO,IAAM,UAAU,gBAAV,CAAb;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/js-data.min.js b/dist/js-data.min.js index d61ee935..2c46af78 100644 --- a/dist/js-data.min.js +++ b/dist/js-data.min.js @@ -1,12 +1,12 @@ /*! * js-data -* @version 3.0.0-alpha.29 - Homepage +* @version 3.0.0-beta.1 - Homepage * @author js-data project authors * @copyright (c) 2014-2016 js-data project authors * @license MIT * * @overview js-data is a framework-agnostic, datastore-agnostic ORM/ODM for Node.js and the Browser. */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("js-data",["exports"],t):t(e.JSData=e.JSData||{})}(this,function(e){"use strict";function t(){Object.defineProperty(this,"_listeners",{value:{}})}function n(e,t,n){return e===t?0:(n&&(e=n(e),t=n(t)),null===e&&null===t?0:null===e?-1:null===t?1:t>e?-1:e>t?1:0)}function r(e,t,n){return e.splice(t,0,n),e}function i(e,t){return e.splice(t,1),e}function o(e,t,r){for(var i=0,o=e.length,a=void 0,u=void 0;o>i;){if(u=(i+o)/2|0,a=n(t,e[u],r),0===a)return{found:!0,index:u};0>a?o=u:i=u+1}return{found:!1,index:o}}function a(e,t){if(C.classCallCheck(this,a),e||(e=[]),!C.isArray(e))throw new Error("fieldList must be an array.");t||(t={}),this.fieldList=e,this.fieldGetter=t.fieldGetter,this.hashCode=t.hashCode,this.isIndex=!0,this.keys=[],this.values=[]}function u(e,t){var n=this;t||(t={});var r=t.localField;if(!r)throw new Error("localField is required!");var i=t.foreignKey=t.foreignKey||t.localKey;if(!i&&(t.type===K||t.type===L))throw new Error("foreignKey is required!");var o=t.localKeys,a=t.foreignKeys;if(!i&&!o&&!a&&t.type===M)throw new Error("one of (foreignKey, localKeys, foreignKeys) is required!");if(C.isString(e)){if(t.relation=e,!C.isFunction(t.getRelation))throw new Error("you must provide a reference to the related mapper!")}else{if(!e)throw new Error("no relation provided!");t.relation=e.name,Object.defineProperty(n,"relatedMapper",{value:e})}Object.defineProperty(n,"inverse",{value:void 0,writable:!0}),C.fillIn(n,t)}var s={};s.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},s.toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);te?-1:1;return t*f}var n=e%1;return e===e?n?e-n:e:0},A=function(e){return m.call(e)},_=function(e){return!!e&&"object"===("undefined"==typeof e?"undefined":s.typeof(e))&&e.constructor===Object},O=function(e,t){if(!t)return e;var n=t.split(".");return n.forEach(function(t){e[t]||(e[t]={}),e=e[t]}),e},x={Promise:Promise,_:function(e,t){x.forOwn(t,function(t,n){n&&x.isUndefined(e[n])&&!x.isFunction(t)&&0!==n.indexOf("_")&&(e[n]=t)})},_forRelation:function(e,t,n,r){var i=t.relation,o=null,a=void 0;if(e||(e={}),e.with||(e.with=[]),(a=x._getIndex(e.with,i))>=0?o=i:(a=x._getIndex(e.with,t.localField))>=0&&(o=t.localField),e.withAll)return void n.call(r,t,{});if(o){var u={};x.fillIn(u,t.getRelation()),x.fillIn(u,e),u.with=e.with.slice(),u._activeWith=u.with.splice(a,1)[0],u.with.forEach(function(e,t){e&&0===e.indexOf(o)&&e.length>=o.length&&"."===e[o.length]?u.with[t]=e.substr(o.length+1):u.with[t]=""}),n.call(r,t,u)}},_getIndex:function(e,t){var n=-1;return e.forEach(function(e,r){return e===t?(n=r,!1):x.isObject(e)&&e.relation===t?(n=r,!1):void 0}),n},addHiddenPropsToTarget:function(e,t){var n={};x.forOwn(t,function(e,t){n[t]={writable:!0,value:e}}),Object.defineProperties(e,n)},areDifferent:function(e,t,n){n||(n={});var r=x.diffObjects(e,t,n),i=Object.keys(r.added).length+Object.keys(r.removed).length+Object.keys(r.changed).length;return i>0},classCallCheck:function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},copy:function(e,t,n,r,i,o){if(t){if(e===t)throw new Error("Cannot copy! Source and destination are identical.");if(n=n||[],r=r||[],x.isObject(e)){var a=n.indexOf(e);if(-1!==a)return r[a];n.push(e),r.push(t)}var u=void 0;if(x.isArray(e)){var s=void 0;for(t.length=0,s=0;si;i++)r[i]=arguments[i];var o=r.shift(),a=e[o]||[],u=void 0;for(u=0;un;n++)t[n]=arguments[n];var i=x.possibleConstructorReturn(this,(r.__super__||Object.getPrototypeOf(r)).apply(this,t));return i},r.prototype=Object.create(n&&n.prototype,{constructor:{configurable:!0,enumerable:!1,value:r,writable:!0}});var i=Object;return i.setPrototypeOf?i.setPrototypeOf(r,n):t.strictEs6Class?r.__proto__=n:x.forOwn(n,function(e,t){r[t]=e}),Object.defineProperty(r,"__super__",{configurable:!0,value:n}),x.addHiddenPropsToTarget(r.prototype,e),x.fillIn(r,t),r},fillIn:function(e,t){return x.forOwn(t,function(t,n){e.hasOwnProperty(n)&&void 0!==e[n]||(e[n]=t)}),e},findIndex:function(e,t){var n=-1;return e.forEach(function(e,r){return t(e)?(n=r,!1):void 0}),n},forEachRelation:function(e,t,n,r){var i=e.relationList||[];i.length&&i.forEach(function(e){x._forRelation(t,e,n,r)})},forOwn:function(e,t,n){var r=Object.keys(e),i=r.length,o=void 0;for(o=0;i>o;o++)t.call(n,e[r[o]],r[o],e)},fromJson:function(e){return x.isString(e)?JSON.parse(e):e},get:function(e,t){if(t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;return e[r]}},getSuper:function(e,t){var n=t?e:e.constructor;return n.__super__||Object.getPrototypeOf(n)||n.__proto__},intersection:function(e,t){if(!e||!t)return[];var n=[],r=void 0,i=void 0,o=e.length;for(i=0;o>i;i++)r=e[i],-1===n.indexOf(r)&&-1!==t.indexOf(r)&&n.push(r);return n},isArray:Array.isArray,isBlacklisted:function(e,t){if(!t||!t.length)return!1;for(var n=void 0,r=0;rn;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": ("+(this.name||this.constructor.name)+")";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var a;(a=console).log.apply(a,[i].concat(n))}}}})},noDupeAdd:function(e,t,n){var r=this.findIndex(e,n);0>r&&e.push(t)},omit:function(e,t){var n={};return x.forOwn(e,function(e,r){-1===t.indexOf(r)&&(n[r]=e)}),n},plainCopy:function(e){return x.copy(e,void 0,void 0,void 0,void 0,!0)},possibleConstructorReturn:function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s.typeof(t))&&"function"!=typeof t?e:t},reject:function(e){return x.Promise.reject(e)},remove:function(e,t){var n=this.findIndex(e,t);n>=0&&e.splice(n,1)},resolve:function(e){return x.Promise.resolve(e)},set:function(e,t,n){if(x.isObject(t))x.forOwn(t,function(t,n){x.set(e,n,t)});else{var r=b.exec(t);r?O(e,r[1])[r[2]]=n:e[t]=n}},strictEqual:function(e,t){var n=e===t;return n||(x.isObject(e)&&x.isObject(t)?(x.forOwn(e,function(e,r){n=n&&x.strictEqual(e,t[r])}),x.forOwn(t,function(t,r){n=n&&x.strictEqual(t,e[r])})):x.isArray(e)&&x.isArray(t)&&e.forEach(function(e,r){n=n&&x.strictEqual(e,t[r])})),n},toJson:JSON.stringify,unset:function(e,t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;e[r]=void 0}};try{x.isBrowser=!!window}catch(e){x.isBrowser=!1}var C=x;t.extend=C.extend,C.logify(t.prototype),C.eventify(t.prototype,function(){return this._listeners},function(e){this._listeners=e});var E={limit:"",offset:"",orderBy:"",skip:"",sort:"",where:""},I=/([.*+?^=!:${}()|[\]\/\\])/g,R=/%/g,j=/_/g,F=function(e){return e.replace(I,"\\$1")},S=t.extend({constructor:function e(t){var n=this;C.classCallCheck(n,e),n.collection=t,n.data=null},between:function(e,t,n){var r=this;if(n||(n={}),r.data)throw new Error("Cannot access index after first operation!");return r.data=r.collection.getIndex(n.index).between(e,t,n),r},compare:function(e,t,n,r){var i=e[t],o=C.get(n,i[0]),a=C.get(r,i[0]);if(o&&C.isString(o)&&(o=o.toUpperCase()),a&&C.isString(a)&&(a=a.toUpperCase()),void 0===n&&(n=null),void 0===r&&(r=null),"DESC"===i[1].toUpperCase()){var u=a;a=o,o=u}return a>o?-1:o>a?1:te;e++){var c=i[e],f="|"===c.charAt(0);c=f?c.substr(1):c;var l=n.evaluate(C.get(a,r[e]),c,o[e]);void 0!==l&&(s=u?l:f?s||l:s&&l),u=!1}return s})}();var a=e.orderBy||e.sort;C.isString(a)&&(a=[[a,"ASC"]]),C.isArray(a)||(a=null),a&&!function(){var e=0;a.forEach(function(e,t){C.isString(e)&&(a[t]=[e,"ASC"])}),n.data.sort(function(t,r){return n.compare(a,e,t,r)})}(),C.isNumber(e.skip)?n.skip(e.skip):C.isNumber(e.offset)&&n.skip(e.offset),C.isNumber(e.limit)&&n.limit(e.limit)}():C.isFunction(e)&&(n.data=n.data.filter(e,t)),n},forEach:function(e,t){return this.getData().forEach(e,t),this},get:function(e,t){var n=this;if(e||(e=[]),t||(t={}),n.data)throw new Error("Cannot access index after first operation!");return e&&!C.isArray(e)&&(e=[e]),e.length?(n.data=n.collection.getIndex(t.index).get(e),n):(n.getData(),n)},getAll:function(){var e=this,t={};if(e.data)throw new Error("Cannot access index after first operation!");for(var n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];if(!r.length||1===r.length&&C.isObject(r[0]))return e.getData(),e;r.length&&C.isObject(r[r.length-1])&&(t=r[r.length-1],r.pop());var o=e.collection,a=o.getIndex(t.index);return e.data=[],r.forEach(function(t){e.data=e.data.concat(a.get(t))}),e},getData:function(){var e=this;return e.data||(e.data=e.collection.index.getAll()),e.data},like:function(e,t){return new RegExp("^"+F(e).replace(R,".*").replace(j,".")+"$",t)},limit:function(e){if(!C.isNumber(e))throw new TypeError("limit: Expected number but found "+("undefined"==typeof e?"undefined":s.typeof(e))+"!");var t=this.getData();return this.data=t.slice(0,Math.min(t.length,e)),this},map:function(e,t){return this.data=this.getData().map(e,t),this},mapCall:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return this.data=this.getData().map(function(t){return t[e].apply(t,n)}),this},run:function(){var e=this.data;return this.data=null,e},skip:function(e){if(!C.isNumber(e))throw new TypeError("skip: Expected number but found "+("undefined"==typeof e?"undefined":s.typeof(e))+"!");var t=this.getData();return e":function(e,t){return e>t},">=":function(e,t){return e>=t},"<":function(e,t){return t>e},"<=":function(e,t){return t>=e},isectEmpty:function(e,t){return!C.intersection(e||[],t||[]).length},isectNotEmpty:function(e,t){return C.intersection(e||[],t||[]).length},in:function(e,t){return-1!==t.indexOf(e)},notIn:function(e,t){return-1===t.indexOf(e)},contains:function(e,t){return-1!==(e||[]).indexOf(t)},notContains:function(e,t){return-1===(e||[]).indexOf(t)}}});C.addHiddenPropsToTarget(a.prototype,{set:function(e,t){C.isArray(e)||(e=[e]);var n=e.shift()||null,i=o(this.keys,n);if(0===e.length)if(i.found){var u=o(this.values[i.index],t,this.hashCode);u.found||r(this.values[i.index],u.index,t)}else r(this.keys,i.index,n),r(this.values,i.index,[t]);else if(i.found)this.values[i.index].set(e,t);else{r(this.keys,i.index,n);var s=new a([],{hashCode:this.hashCode});s.set(e,t),r(this.values,i.index,s)}},get:function(e){C.isArray(e)||(e=[e]);var t=e.shift()||null,n=o(this.keys,t);return 0===e.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(e):[]},getAll:function(){var e=[];return this.values.forEach(function(t){e=t.isIndex?e.concat(t.getAll()):e.concat(t)}),e},visitAll:function(e,t){this.values.forEach(function(n){n.isIndex?n.visitAll(e,t):n.forEach(e,t)})},between:function(e,t,n){n||(n={}),C.isArray(e)||(e=[e]),C.isArray(t)||(t=[t]),C.fillIn(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var r=this._between(e,t,n);return n.limit?r.slice(n.offset,n.limit+n.offset):r.slice(n.offset)},_between:function(e,t,n){var r=[],i=e.shift(),a=t.shift(),u=void 0;if(u=void 0!==i?o(this.keys,i):{found:!1,index:0},0===e.length){u.found&&n.leftInclusive===!1&&(u.index+=1);for(var s=u.index;sa)break}else if(this.keys[s]>=a)break;if(r=this.values[s].isIndex?r.concat(this.values[s].getAll()):r.concat(this.values[s]),n.limit&&r.length>=n.limit+n.offset)break}}else for(var c=u.index;ca)break;if(r=this.values[c].isIndex?f===i?r.concat(this.values[c]._between(C.copy(e),t.map(function(){}),n)):f===a?r.concat(this.values[c]._between(e.map(function(){}),C.copy(t),n)):r.concat(this.values[c].getAll()):r.concat(this.values[c]),n.limit&&r.length>=n.limit+n.offset)break}return n.limit?r.slice(0,n.limit+n.offset):r},peek:function(){return this.values.length?this.values[0].isIndex?this.values[0].peek():this.values[0]:[]},clear:function(){this.keys=[],this.values=[]},insertRecord:function(e){var t=this.fieldList.map(function(t){return C.isFunction(t)?t(e)||null:e[t]||null});this.set(t,e)},removeRecord:function(e){var t=this,n=void 0;return this.values.forEach(function(r,a){if(r.isIndex){if(r.removeRecord(e))return 0===r.keys.length&&(i(t.keys,a),i(t.values,a)),n=!0,!1}else{var u=o(r,e,t.hashCode);if(u.found)return i(r,u.index),0===r.length&&(i(t.keys,a),i(t.values,a)),n=!0,!1}}),n?e:void 0},updateRecord:function(e){this.removeRecord(e),this.insertRecord(e)}});var k={idAttribute:"id",onConflict:"merge"},P=t.extend({constructor:function e(t,n){var r=this;C.classCallCheck(r,e),e.__super__.call(r),C.isObject(t)&&!C.isArray(t)&&(n=t,t=[]),C.isString(n)&&(n={idAttribute:n}),t||(t=[]),n||(n={}),Object.defineProperty(r,"mapper",{value:void 0,writable:!0}),C.fillIn(r,n),C.fillIn(r,C.copy(k));var i=r.recordId();Object.defineProperties(r,{index:{value:new a([i],{hashCode:function(e){return C.get(e,i)}})},indexes:{value:{}}});var o=r.mapper;t.forEach(function(e){e=o?o.createRecord(e,n):e,r.index.insertRecord(e),e&&C.isFunction(e.on)&&e.on("all",r._onRecordEvent,r)})},_onRecordEvent:function(){this.emit.apply(this,arguments)},add:function(e,t){var n=this;t||(t={}),C._(t,n),e=n.beforeAdd(e,t)||e;var r=!1,i=n.recordId();C.isObject(e)&&!C.isArray(e)&&(e=[e],r=!0),e=e.map(function(e){var r=n.recordId(e);if(!C.isSorN(r))throw new TypeError("Collection#add: Expected string or number for "+i+", found "+("undefined"==typeof r?"undefined":s.typeof(r))+"!");var o=n.get(r);if(e===o)return o;if(o){var a=t.onConflict||n.onConflict;"merge"===a?C.deepMixIn(o,e):"replace"===a&&(C.forOwn(o,function(t,n){n===i||e.hasOwnProperty(n)||delete o[n]}),o.set(e)),e=o,n.updateIndexes(e)}else e=n.mapper?n.mapper.createRecord(e,t):e,n.index.insertRecord(e),C.forOwn(n.indexes,function(t,n){t.insertRecord(e)}),e&&C.isFunction(e.on)&&e.on("all",n._onRecordEvent,n);return e});var o=r?e.length?e[0]:void 0:e;return n.emit("add",o),n.afterAdd(e,t,o)||o},afterAdd:function(){},afterRemove:function(){},afterRemoveAll:function(){},beforeAdd:function(){},beforeRemove:function(){},beforeRemoveAll:function(){},between:function(e,t,n){return this.query().between(e,t,n).run()},createIndex:function(e,t,n){var r=this;C.isString(e)&&void 0===t&&(t=[e]),n||(n={}),n.hashCode=n.hashCode||function(e){return r.recordId(e)};var i=r.indexes[e]=new a(t,n);return r.index.visitAll(i.insertRecord,i),r},filter:function(e,t){return this.query().filter(e,t).run()},forEach:function(e,t){this.index.visitAll(e,t)},get:function(e){var t=this.query().get(e).run();return t.length?t[0]:void 0},getAll:function(){var e;return(e=this.query()).getAll.apply(e,arguments).run()},getIndex:function(e){var t=e?this.indexes[e]:this.index;if(!t)throw new Error("Index "+e+" does not exist!");return t},limit:function(e){return this.query().limit(e).run()},map:function(e,t){var n=[];return this.index.visitAll(function(r){n.push(e.call(t,r))}),n},mapCall:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=[];return this.index.visitAll(function(t){i.push(t[e].apply(t,n))}),i},recordId:function(e){var t=this;return e?C.get(e,t.recordId()):t.mapper?t.mapper.idAttribute:t.idAttribute||"id"},query:function(){return new S(this)},reduce:function(e,t){var n=this.getAll();return n.reduce(e,t)},remove:function(e,t){var n=this;t||(t={}),n.beforeRemove(e,t);var r=n.get(e);return r&&(n.index.removeRecord(r),C.forOwn(n.indexes,function(e,t){e.removeRecord(r)}),r&&C.isFunction(r.off)&&(r.off("all",n._onRecordEvent,n),n.emit("remove",r))),n.afterRemove(e,t,r)||r},removeAll:function(e,t){var n=this;t||(t={}),n.beforeRemoveAll(e,t);var r=n.filter(e);return r.forEach(function(e){n.remove(n.recordId(e),t)}),n.afterRemoveAll(e,t,r)||r},skip:function(e){return this.query().skip(e).run()},toJSON:function(e){return this.mapCall("toJSON",e)},updateIndex:function(e,t){t||(t={}),this.getIndex(t.index).updateRecord(e)},updateIndexes:function(e){var t=this;t.index.updateRecord(e),C.forOwn(t.indexes,function(t,n){t.updateRecord(e)})}}),K="belongsTo",M="hasMany",L="hasOne";C.addHiddenPropsToTarget(u.prototype,{getRelation:function(){return this.relatedMapper},getLocalKeys:function(e){},getForeignKey:function(e){return this.type===K?C.get(e,this.foreignKey):C.get(e,this.mapper.idAttribute)},setForeignKey:function(e,t){var n=this;e&&t&&(n.type===K?C.set(e,n.foreignKey,C.get(t,n.getRelation().idAttribute)):!function(){var r=n.mapper.idAttribute;C.isArray(t)?t.forEach(function(t){C.set(t,n.foreignKey,C.get(e,r))}):C.set(t,n.foreignKey,C.get(e,r))}())},getLocalField:function(e){return C.get(e,this.localField)},setLocalField:function(e,t){return C.set(e,this.localField,t)},getInverse:function(e){var t=this;return t.inverse?t.inverse:(t.getRelation().relationList.forEach(function(n){if(n.getRelation()===e){if(n.foreignKey&&n.foreignKey!==t.foreignKey)return;return t.inverse=n,!1}}),t.inverse)}});var U=function(e,t,n){n.name=e.name;var r=new u(t,n);Object.defineProperty(r,"mapper",{value:e}),e.relationList||Object.defineProperty(e,"relationList",{value:[]}),e.relationFields||Object.defineProperty(e,"relationFields",{value:[]}),e.relationList.push(r),e.relationFields.push(r.localField)},N=function(e,t){return t||(t={}),t.type=K,function(n){U(n,e,t)}},D=function(e,t){return t||(t={}),t.type=M,function(n){U(n,e,t)}},T=function(e,t){return t||(t={}),t.type=L,function(n){U(n,e,t)}},q=function(e,t){var n=e.datastore;return n&&n[t]?function(){for(var r=arguments.length,i=Array(r),o=0;r>o;o++)i[o]=arguments[o];return n[t].apply(n,[e.name].concat(i))}:e[t].bind(e)},Q=t.extend({constructor:function e(t,n){var r=this;C.classCallCheck(r,e),t||(t={}),n||(n={});var i={};Object.defineProperties(r,{_get:{value:function(e){return C.get(i,e)}},_set:{value:function(e,t){return C.set(i,e,t)}},_unset:{value:function(e){return C.unset(i,e)}}});var o=r._set;o("creating",!0),n.noValidate&&o("noValidate",!0),C.fillIn(r,t),o("creating",!1),o("noValidate",!1),o("previous",C.copy(t))},_mapper:function(){if(!this.constructor.mapper)throw new Error("This recordClass has no Mapper!");return this.constructor.mapper},afterLoadRelations:function(){},beforeLoadRelations:function(){},changes:function(e){var t=this;return e||(e={}),C.diffObjects(t,t._get("previous"),e)},commit:function(){var e=this;return e._set("changed"),e._set("previous",C.copy(e)),e},destroy:function(e){var t=this;e||(e={});var n=t._mapper();return q(n,"destroy")(C.get(t,n.idAttribute),e)},get:function(e){return C.get(this,e)},hasChanges:function(e){var t=this,n=!!(t._get("changed")||[]).length;return n||C.areDifferent(t,t._get("previous"),e)},hashCode:function(){var e=this;return C.get(e,e._mapper().idAttribute)},isValid:function(e){var t=this;return!t._mapper().validate(t,e)},loadRelations:function(e,t){var n=void 0,r=this,i=r._mapper();return e||(e=[]),C.isString(e)&&(e=[e]),t||(t={}),t.with=e,C._(t,i),t.adapter=i.getAdapterName(t),n=t.op="beforeLoadRelations",C.resolve(r[n](e,t)).then(function(){C.isString(e)&&(e=[e]),n=t.op="loadRelations",i.dbg(n,r,e,t);var o=[],a=void 0;return C.forEachRelation(i,t,function(e,n){var u=e.getRelation();if(n.raw=!1,C.isFunction(e.load))a=e.load(i,e,r,t);else if("hasMany"===e.type)e.foreignKey?a=q(u,"findAll")(s.defineProperty({},e.foreignKey,C.get(r,i.idAttribute)),n):e.localKeys?a=q(u,"findAll")({where:s.defineProperty({},u.idAttribute,{in:C.get(r,e.localKeys)})}):e.foreignKeys&&(a=q(u,"findAll")({where:s.defineProperty({},e.foreignKeys,{contains:C.get(r,i.idAttribute)})},t));else if("belongsTo"===e.type||"hasOne"===e.type){var c=C.get(r,e.foreignKey);C.isSorN(c)&&(a=q(u,"find")(c,n))}a&&(a=a.then(function(t){e.setLocalField(r,t)}),o.push(a))}),Promise.all(o)}).then(function(){return n=t.op="afterLoadRelations",C.resolve(r[n](e,t)).then(function(){return r})})},previous:function(e){var t=this;return e?t._get("previous."+e):t._get("previous")},revert:function(e){var t=this,n=t._get("previous");return e||(e={}),e.preserve||(e.preserve=[]),C.forOwn(t,function(r,i){i!==t._mapper().idAttribute&&!n.hasOwnProperty(i)&&t.hasOwnProperty(i)&&-1===e.preserve.indexOf(i)&&delete t[i]}),C.forOwn(n,function(n,r){-1===e.preserve.indexOf(r)&&(t[r]=n)}),t.commit(),t},save:function(e){var t=this;e||(e={});var n=t._mapper(),r=C.get(t,n.idAttribute),i=t;if(C.isUndefined(r))return q(n,"create")(i,e);if(e.changesOnly){var o=t.changes(e);i={},C.fillIn(i,o.added),C.fillIn(i,o.changed)}return q(n,"update")(r,i,e)},set:function(e,t,n){var r=this;C.isObject(e)&&(n=t),n||(n={}),n.silent&&r._set("silent",!0),C.set(r,e,t),r._get("eventId")||r._set("silent")},toJSON:function(e){var t=this,n=this.constructor.mapper;if(n)return n.toJSON(this,e);var r=function(){var e={};return C.forOwn(t,function(t,n){e[n]=C.copy(t)}),{v:e}}();return"object"===("undefined"==typeof r?"undefined":s.typeof(r))?r.v:void 0},unset:function(e,t){this.set(e,void 0,t)},validate:function(e){return this._mapper().validate(this,e)}});C.eventify(Q.prototype,function(){return this._get("events")},function(e){this._set("events",e)});var J={array:C.isArray,boolean:C.isBoolean,integer:C.isInteger,null:C.isNull,number:C.isNumber,object:C.isObject,string:C.isString},B=function(e,t){var n="";return e&&(n+=C.isNumber(e)?"["+e+"]":t?"."+e:""+e),n},$=function(e){e||(e={});var t="",n=e.path||[];return n.forEach(function(e){t+=B(e,t)}),t+=B(e.prop,t)},V=function(e,t,n){return{expected:t,actual:""+e,path:$(n)}},H=function(e,t,n,r){r.push(V(e,t,n))},G=function(e,t,n,r){var i=n[e];return t.length>i?V(t.length,"length no more than "+i,r):void 0},W=function(e,t,n,r){var i=n[e];return t.lengthu;u++)o&&(e=n.items[u]),r.prop=u,i=i.concat(oe(t[u],e,r)||[]);return i.length?i:void 0},maximum:function e(t,n,r){var e=n.maximum,i=n.exclusiveMaximum;return("undefined"==typeof t?"undefined":s.typeof(t))===("undefined"==typeof e?"undefined":s.typeof(e))&&(i?t>e:t>=e)?V(t,"no more than "+e,r):void 0},maxItems:function(e,t,n){return G("maxItems",e,t,n)},maxLength:function(e,t,n){return G("maxLength",e,t,n)},maxProperties:function e(t,n,r){var e=n.maxProperties,i=Object.keys(t).length;return i>e?V(i,"no more than "+e+" properties",r):void 0},minimum:function e(t,n,r){var e=n.minimum,i=n.exclusiveMinimum;return("undefined"==typeof t?"undefined":s.typeof(t))===("undefined"==typeof e?"undefined":s.typeof(e))&&(i?e>t:e>=t)?V(t,"no less than "+e,r):void 0},minItems:function(e,t,n){return W("minItems",e,t,n)},minLength:function(e,t,n){return W("minLength",e,t,n)},minProperties:function e(t,n,r){var e=n.minProperties,i=Object.keys(t).length;return e>i?V(i,"no more than "+e+" properties",r):void 0},multipleOf:function(e,t,n){},not:function(e,t,n){return oe(e,t.not,n)?void 0:V("succeeded","should have failed",n)},oneOf:function(e,t,n){var r=!1,i=[];return t.oneOf.forEach(function(t){var o=oe(e,t,n);if(o)i=i.concat(o);else{if(r)return i=[V("valid against more than one","valid against only one",n)],r=!1,!1;r=!0}}),r?void 0:i},pattern:function e(t,n,r){var e=n.pattern;return C.isString(t)&&!t.match(e)?V(t,e,r):void 0},properties:function e(t,n,r){r||(r={});var i=C.isUndefined(n.additionalProperties)?!0:n.additionalProperties,o={},e=n.properties||{},a=n.patternProperties||{},u=[];C.forOwn(t,function(e,t){o[t]=void 0}),C.forOwn(e||{},function(e,n){C.isUndefined(t[n])&&!C.isUndefined(e.default)&&(t[n]=C.copy(e.default)),r.prop=n,u=u.concat(oe(t[n],e,r)||[]),delete o[n]}),C.forOwn(a,function(e,n){C.forOwn(o,function(i,a){a.match(n)&&(r.prop=a,u=u.concat(oe(t[a],e,r)||[]),delete o[a])})});var s=Object.keys(o);return i===!1?s.length&&H("extra fields: "+s.join(", "),"no extra fields",r,u):C.isObject(i)&&s.forEach(function(e){r.prop=e,u=u.concat(oe(t[e],i,r)||[])}),u.length?u:void 0},required:function e(t,n,r){var e=n.required,i=[];return r.existingOnly||e.forEach(function(e){if(C.isUndefined(C.get(t,e))){var n=r.prop;r.prop=e,H(void 0,"a value",r,i),r.prop=n}}),i.length?i:void 0},type:function e(t,n,r){var e=n.type,i=void 0;if(C.isString(e)&&(e=[e]),e.forEach(function(e){return J[e](t,n,r)?(i=e,!1):void 0}),!i)return V(t?"undefined"==typeof t?"undefined":s.typeof(t):""+t,"one of ("+e.join(", ")+")",r);var o=he[i];return o?o(t,n,r):void 0},uniqueItems:function(e,t,n){if(e&&e.length&&t.uniqueItems){var r=e.length,i=void 0,o=void 0,a=void 0;for(o=r-1;o>0;o--)for(i=e[o],a=o-1;a>=0;a--)if(i===e[a])return V(i,"no duplicates",n)}}},X=function(e,t,n,r){return!C.isUndefined(n[e])&&z[e](t,n,r)},Y=function(e,t,n,r){var i=[];return e.forEach(function(e){i=i.concat(X(e,t,n,r)||[])}),i.length?i:void 0},Z=["enum","type","allOf","anyOf","oneOf","not"],ee=["items","maxItems","minItems","uniqueItems"],te=["multipleOf","maximum","minimum"],ne=["maxProperties","minProperties","required","properties","dependencies"],re=["maxLength","minLength","pattern"],ie=function(e,t,n){return Y(Z,e,t,n)},oe=function e(t,n,r){var i=[];r||(r={});var o=void 0,a=r.prop;if(!C.isUndefined(n)){if(!C.isObject(n))throw new Error('Invalid schema at path: "'+r.path+'"');return C.isUndefined(r.path)&&(r.path=[]),C.isUndefined(r.prop)||(o=!0,r.path.push(r.prop),r.prop=void 0),n.extends&&(i=C.isFunction(n.extends.validate)?i.concat(n.extends.validate(t,r)||[]):i.concat(e(t,n.extends,r)||[])),C.isUndefined(t)?(n.required===!0&&H(t,"a value",r,i),o&&(r.path.pop(),r.prop=a),i.length?i:void 0):(i=i.concat(ie(t,n,r)||[]),o&&(r.path.pop(),r.prop=a),i.length?i:void 0)}},ae="changing",ue="changed",se="creating",ce="eventId",fe="noValidate",le="silent",de="validation failed",pe=function(e,t,n){var r={enumerable:C.isUndefined(t.enumerable)?!0:!!t.enumerable},i="props."+e,o="previous."+e,a=n.getter,u=n.setter,s=n.unsetter;return r.get=function(){return this._get(i)},r.set=function(n){var r=this,c=r[a],f=r[u],l=r[s];if(!c(fe)){var d=t.validate(n);if(d){var p=new Error(de);throw p.errors=d,p}}return t.track&&!c(se)&&!function(){var t=c(o),a=c(i),u=c(ae),s=c(ue);u||(s=[]);var d=s.indexOf(e);a!==n&&-1===d&&s.push(e),t===n&&d>=0&&s.splice(d,1),s.length||(u=!1,l(ae),l(ue),c(ce)&&(clearTimeout(c(ce)),l(ce))),!u&&s.length&&(f(ue,s),f(ae,!0),f(ce,setTimeout(function(){if(l(ue),l(ce),l(ae),!c(le)){var e=void 0;for(e=0;er;r++)n[r]=arguments[r];var i=this,o=n[n.length-e];i.dbg.apply(i,[o.op].concat(n)),(o.notify||void 0===o.notify&&i.notify)&&setTimeout(function(){i.emit.apply(i,[o.op].concat(n))})}},ye=ge(1),me=ge(2),be={count:{defaults:[{},{}],skip:!0,types:[]},destroy:{defaults:[{},{}],skip:!0,types:[]},destroyAll:{defaults:[{},{}],skip:!0,types:[]},find:{defaults:[void 0,{}],types:[]},findAll:{defaults:[{},{}],types:[]},sum:{defaults:[void 0,{},{}],skip:!0,types:[]},update:{adapterArgs:function(e,t,n,r){return[t,e.toJSON(n,r),r]},beforeAssign:1,defaults:[void 0,{},{}],types:[]},updateAll:{adapterArgs:function(e,t,n,r){return[e.toJSON(t,r),n,r]},beforeAssign:0,defaults:[{},{},{}],types:[]},updateMany:{adapterArgs:function(e,t,n){return[t.map(function(t){return e.toJSON(t,n)}),n]},beforeAssign:0,defaults:[[],{}],types:[]}},we={_adapters:{},applySchema:!0,debug:!1,defaultAdapter:"http",idAttribute:"id",notify:C.isBrowser,raw:!1},Ae=t.extend({constructor:function e(t){var n=this;if(C.classCallCheck(n,e),e.__super__.call(n),t||(t={}),Object.defineProperties(n,{_adapters:{value:void 0,writable:!0},recordClass:{value:void 0,writable:!0},lifecycleMethods:{value:be},schema:{value:void 0,writable:!0}}),C.fillIn(n,t),C.fillIn(n,C.copy(we)),!n.name)throw new Error("name is required!");n.schema instanceof ve||(n.schema=new ve(n.schema||{})),C.isUndefined(n.recordClass)&&!function(){var e=Q;n.recordClass=e.extend({constructor:function(){var t=function(n,r){C.classCallCheck(this,t),e.call(this,n,r)};return t}()})}(),n.recordClass&&(n.recordClass.mapper=n,C.getSuper(n.recordClass,!0)===Q&&n.schema&&n.schema.apply&&n.applySchema&&n.schema.apply(n.recordClass.prototype))},afterCount:me,afterCreate:me,afterCreateMany:me,afterDestroy:me,afterDestroyAll:me,afterFind:me,afterFindAll:me,afterSum:me,afterUpdate:me,afterUpdateAll:me,afterUpdateMany:me,beforeCreate:ye,beforeCreateMany:ye,beforeCount:ye,beforeDestroy:ye,beforeDestroyAll:ye,beforeFind:ye,beforeFindAll:ye,beforeSum:ye,beforeUpdate:ye,beforeUpdateAll:ye,beforeUpdateMany:ye,_end:function(e,t,n){var r=this;if(t.raw&&C._(e,t),n)return e;var i=t.raw?e.data:e;return i&&C.isFunction(r.wrap)&&(i=r.wrap(i,t),t.raw?e.data=i:e=i),e},belongsTo:function(e,t){return N(e,t)(this)},count:function(e,t){return this.crud("count",e,t)},create:function(e,t){var n=void 0,r=void 0,i=this;return e||(e={}),t||(t={}),C._(t,i),r=t.adapter=i.getAdapterName(t),n=t.op="beforeCreate",C.resolve(i[n](e,t)).then(function(o){e=C.isUndefined(o)?e:o;var a={};t.with||(t.with=[]);var u=[];return C.forEachRelation(i,t,function(t,n){var r=t.getLocalField(e),i=t.getRelation(),o=i.idAttribute;n.raw=!1,r&&(t.type===K?u.push(i.create(r,n).then(function(n){t.setLocalField(a,n),t.setForeignKey(e,n)})):t.type===M&&t.localKeys&&u.push(i.createMany(r,n)).then(function(n){t.setLocalField(a,n),C.set(e,t.localKeys,n.map(function(e){return C.get(e,o)}))}))}),C.Promise.all(u).then(function(){return n=t.op="create",i.dbg(n,e,t),C.resolve(i.getAdapter(r)[n](i,i.toJSON(e,{with:t.pass||[]}),t))}).then(function(n){var r=t.raw?n.data:n;return u=[],C.forEachRelation(i,t,function(n,i){var o=n.getLocalField(e);if(o){var s=void 0;n.type===M&&n.foreignKey?(n.setForeignKey(r,o),s=n.getRelation().createMany(o,i).then(function(e){n.setLocalField(r,t.raw?e.data:e)})):n.type===L?(n.setForeignKey(r,o),s=n.getRelation().create(o,i).then(function(e){n.setLocalField(r,t.raw?e.data:e)})):n.type===K&&n.getLocalField(a)&&n.setLocalField(r,n.getLocalField(a)),s&&u.push(s)}}),C.Promise.all(u).then(function(){return n})})}).then(function(r){return r=i._end(r,t),n=t.op="afterCreate",C.resolve(i[n](e,t,r)).then(function(e){return C.isUndefined(e)?r:e})})},createInstance:function(e,t){return this.createRecord(e,t)},createMany:function(e,t){var n=void 0,r=void 0,i=this;return e||(e=[]),t||(t={}),C._(t,i),r=t.adapter=i.getAdapterName(t),n=t.op="beforeCreateMany",C.resolve(i[n](e,t)).then(function(o){e=C.isUndefined(o)?e:o;var a={};t.with||(t.with=[]);var u=[];return C.forEachRelation(i,t,function(t,n){var r=e.map(function(e){return t.getLocalField(e)}).filter(function(e){return e});t.type===K&&r.length===e.length&&u.push(t.getRelation().createMany(r,n).then(function(r){var i=n.raw?r.data:r;t.setLocalField(a,i),e.forEach(function(e,n){t.setForeignKey(e,i[n])})}))}),C.Promise.all(u).then(function(){n=t.op="createMany";var o=e.map(function(e){return i.toJSON(e,{with:t.pass||[]})});return i.dbg(n,e,t),C.resolve(i.getAdapter(r)[n](i,o,t))}).then(function(n){var r=t.raw?n.data:n;return u=[],C.forEachRelation(i,t,function(n,o){var s=e.map(function(e){return n.getLocalField(e)}).filter(function(e){return e});if(s.length===e.length){var c=n.getLocalField(a),f=void 0;n.type===M?i.log("warn","deep createMany of hasMany type not supported!"):n.type===L?(r.forEach(function(e,t){n.setForeignKey(e,s[t])}),f=n.getRelation().createMany(s,o).then(function(e){var i=t.raw?e.data:e;r.forEach(function(e,t){n.setLocalField(e,i[t])})})):n.type===K&&c&&c.length===r.length&&r.forEach(function(e,t){n.setLocalField(e,c[t])}),f&&u.push(f)}}),C.Promise.all(u).then(function(){return n})})}).then(function(r){return r=i._end(r,t),n=t.op="afterCreateMany",C.resolve(i[n](e,t,r)).then(function(e){return C.isUndefined(e)?r:e})})},createRecord:function(e,t){e||(e={});var n=this;if(C.isArray(e))return e.map(function(e){return n.createRecord(e,t)});if(!C.isObject(e))throw new Error("Cannot create a record from "+e+"!");var r=n.recordClass,i=n.relationList||[];return i.forEach(function(n){var r=n.getRelation(),i=n.getLocalField(e);if(i&&!r.is(i)){if(C.isArray(i)&&(!i.length||r.is(i[0])))return;C.set(e,n.localField,r.createRecord(i,t))}}),r?e instanceof r?e:new r(e,t):e},crud:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=this,o=i.lifecycleMethods[e];if(!o)throw new Error(e+": No such CRUD method!");var a=""+e.charAt(0).toUpperCase()+e.substr(1),u="before"+a,c="after"+a,f=void 0,l=void 0;o.defaults.forEach(function(e,t){C.isUndefined(n[t])&&(n[t]=C.copy(e))});var d=n[n.length-1];return C._(d,i),l=d.adapter=i.getAdapterName(d),f=d.op=u,C.resolve(i[f].apply(i,s.toConsumableArray(n))).then(function(t){var r;return C.isUndefined(o.beforeAssign)||(n[o.beforeAssign]=C.isUndefined(t)?n[o.beforeAssign]:t),f=d.op=e,n=o.adapterArgs?o.adapterArgs.apply(o,[i].concat(s.toConsumableArray(n))):n,i.dbg.apply(i,[f].concat(s.toConsumableArray(n))),C.resolve((r=i.getAdapter(l))[f].apply(r,[i].concat(s.toConsumableArray(n))))}).then(function(e){return e=i._end(e,d,!!o.skip),n.push(e),f=d.op=c,C.resolve(i[f].apply(i,s.toConsumableArray(n))).then(function(t){return C.isUndefined(t)?e:t})})},destroy:function(e,t){return this.crud("destroy",e,t)},destroyAll:function(e,t){return this.crud("destroyAll",e,t)},find:function(e,t){return this.crud("find",e,t)},findAll:function(e,t){return this.crud("findAll",e,t)},getAdapter:function(e){var t=this;t.dbg("getAdapter","name:",e);var n=t.getAdapterName(e);if(!n)throw new ReferenceError(n+" not found!");return t.getAdapters()[n]},getAdapterName:function(e){return e||(e={}),C.isString(e)&&(e={adapter:e}),e.adapter||e.defaultAdapter},getAdapters:function(){return this._adapters},getSchema:function(){return this.schema},hasMany:function(e,t){return D(e,t)(this)},hasOne:function(e,t){return T(e,t)(this)},is:function(e){var t=this.recordClass;return t?e instanceof t:!1},registerAdapter:function(e,t,n){var r=this;n||(n={}),r.getAdapters()[e]=t,(n===!0||n.default)&&(r.defaultAdapter=e)},sum:function(e,t,n){return this.crud("sum",e,t,n)},toJSON:function(e,t){var n=this;t||(t={});var r=(n?n.relationFields:[])||[],i={},o=void 0;if(n&&n.schema&&(o=n.schema.properties||{},C.forOwn(o,function(t,n){i[n]=C.plainCopy(e[n])})),o||(o={}),!t.strict)for(var a in e)o[a]||-1!==r.indexOf(a)||(i[a]=C.plainCopy(e[a]));return n&&t.withAll&&(t.with=r.slice()),n&&t.with&&(C.isString(t.with)&&(t.with=[t.with]),C.forEachRelation(n,t,function(t,n){var r=t.getLocalField(e);r&&(C.isArray(r)?t.setLocalField(i,r.map(function(e){return t.getRelation().toJSON(e,n)})):t.setLocalField(i,t.getRelation().toJSON(r,n)))})),i},update:function(e,t,n){return this.crud("update",e,t,n)},updateAll:function(e,t,n){return this.crud("updateAll",e,t,n)},updateMany:function(e,t){return this.crud("updateMany",e,t)},validate:function(e,t){var n=this,r=n.getSchema();if(!r)throw new Error(n.name+" mapper has no schema!");if(C.isArray(e))return e.map(function(e){return r.validate(e,t)});if(C.isObject(e))return r.validate(e,t);throw new Error("not a record!")},wrap:function(e,t){return this.createRecord(e,t)}}),_e=["count","create","createMany","createRecord","dbg","destroy","destroyAll","find","findAll","getSchema","is","log","sum","toJSON","update","updateAll","updateMany"],Oe={constructor:function e(t){var n=this;C.classCallCheck(n,e),e.__super__.call(n),t||(t={}),C.fillIn(n,t),n.mapperDefaults=n.mapperDefaults||{},n.mapperClass=n.mapperClass||Ae,n._adapters={},n._mappers={}},_onMapperEvent:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=n.shift();this.emit.apply(this,[i,e].concat(n))},defineMapper:function(e,t){var n=this;if(C.isObject(e)){if(t=e,!t.name)throw new Error("name is required!");e=t.name}else if(!C.isString(e))throw new Error("name is required!");t||(t={}),t.name=e,t.relations||(t.relations={});var r=t.mapperClass||n.mapperClass;delete t.mapperClass,C.fillIn(t,n.mapperDefaults);var i=n._mappers[e]=new r(t);return i.name=e,i._adapters=n.getAdapters(),i.datastore=n,i.on("all",function(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];n._onMapperEvent.apply(n,[e].concat(r))}),C.forOwn(i.relations,function(e,t){C.forOwn(e,function(e,r){C.isObject(e)&&(e=[e]),e.forEach(function(e){e.getRelation=function(){return n.getMapper(r)};var o=n._mappers[r]||r;t===K?i.belongsTo(o,e):t===L?i.hasOne(o,e):t===M&&i.hasMany(o,e)})})}),i},defineResource:function(e,t){return this.defineMapper(e,t)},getAdapter:function(e){var t=this,n=t.getAdapterName(e);if(!n)throw new ReferenceError(n+" not found!");return t.getAdapters()[n]},getAdapterName:function(e){return e||(e={}),C.isString(e)&&(e={adapter:e}),e.adapter||this.mapperDefaults.defaultAdapter},getAdapters:function(){return this._adapters},getMapper:function(e){var t=this._mappers[e];if(!t)throw new ReferenceError(e+" is not a registered mapper!");return t},registerAdapter:function(e,t,n){var r=this;n||(n={}),r.getAdapters()[e]=t,(n===!0||n.default)&&(r.mapperDefaults.defaultAdapter=e,C.forOwn(r._mappers,function(t){t.defaultAdapter=e}))}};_e.forEach(function(e){Oe[e]=function(t){for(var n,r=arguments.length,i=Array(r>1?r-1:0),o=1;r>o;o++)i[o-1]=arguments[o];return(n=this.getMapper(t))[e].apply(n,i)}});var xe=t.extend(Oe),Ce=P.extend({constructor:function e(t,n){var r=this;if(C.classCallCheck(r,e),e.__super__.call(r,t,n),r._added={},!r.datastore)throw new Error("This collection must have a datastore!");return r},_onRecordEvent:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];C.getSuper(e).prototype._onRecordEvent.apply(e,n);var i=n[0];C.isString(i)&&0===i.indexOf("change")&&e.updateIndexes(n[1])},add:function(e,t){var n=this,r=n.datastore,i=n.mapper,o=i.relationList||[],a=(new Date).getTime(),u=!!i.recordClass,c=i.idAttribute,f=void 0;return C.isObject(e)&&!C.isArray(e)&&(f=!0,e=[e]),e=C.getSuper(n).prototype.add.call(n,e,t),o.length&&e.length&&i.relationList.forEach(function(t){var n=t.relation,i=r.getMapper(n),o=i.idAttribute,a=t.foreignKey,u=r.getCollection(n),f=t.type,l=f===M,d=C.isUndefined(t.add)?!0:!!t.add,p=void 0;e.forEach(function(e){p=t.getLocalField(e);var n=C.get(e,c);if(C.isFunction(t.add))p=t.add(r,t,e);else if(p)if(l)p=p.map(function(n){return n!==u.get(u.recordId(n))&&(a&&t.setForeignKey(e,n),d&&(n=u.add(n))),n}),t.localKeys&&!C.get(e,t.localKeys)&&C.set(e,t.localKeys,p.map(function(e){return C.get(e,o)}));else{var i=C.get(p,o);p!==u.get(i)&&(t.setForeignKey(e,p),d&&(p=u.add(p)))}if(!p||C.isArray(p)&&!p.length)if(f===K){var h=C.get(e,a);C.isUndefined(h)||(p=u.get(h))}else if(f===L){var v=u.filter(s.defineProperty({},a,n));p=v.length?v[0]:void 0}else if(f===M)if(a){var g=u.filter(s.defineProperty({},a,n));p=g.length?g:void 0}else if(t.localKeys){var y=u.filter({where:s.defineProperty({},o,{in:C.get(e,t.localKeys||[])})});p=y.length?y:void 0}else if(t.foreignKeys){var m=u.filter({where:s.defineProperty({},t.foreignKeys,{contains:n})});p=m.length?m:void 0}p&&t.setLocalField(e,p)})}),e.forEach(function(e){n._added[n.recordId(e)]=a,u&&e._set("$",a)}),f?e[0]:e},remove:function(e,t){var n=this,r=n.mapper,i=C.getSuper(n).prototype.remove.call(n,e,t);return i&&(delete n._added[e],r.recordClass&&i._set("$")),i},removeAll:function(e,t){var n=this,r=n.mapper,i=C.getSuper(n).prototype.removeAll.call(n,e,t);return i.forEach(function(e){delete n._added[n.recordId(e)],r.recordClass&&e._set("$")}),i}}),Ee={},Ie=function(e,t,n){e&&e._set?e._set(t,n):C.set(e,t,n)},Re=function(e,t,n){var r=this,i=r._completedQueries[e][t];return C.isFunction(i)?i(e,t,n):i},je={constructor:function e(t){var n=this;return C.classCallCheck(n,e),e.__super__.call(n,t),n.collectionClass=n.collectionClass||Ce,n._collections={},C.fillIn(n,Ee),n._pendingQueries={},n._completedQueries={},n},_callSuper:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return this.constructor.__super__.prototype[e].apply(this,n)},_end:function(e,t,n){var r=n.raw?t.data:t;return r&&C.isFunction(this.addToCache)&&(r=this.addToCache(e,r,n),n.raw?t.data=r:t=r),t},_onCollectionEvent:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=n.shift();this.emit.apply(this,[i,e].concat(n))},addToCache:function(e,t,n){return this.getCollection(e).add(t,n)},cachedFind:Re,cachedFindAll:Re,cacheFind:function(e,t,n,r){var i=this;i._completedQueries[e][n]=function(e,t,n){return i.get(e,t)}},cacheFindAll:function(e,t,n,r){var i=this;i._completedQueries[e][n]=function(e,t,n){return i.filter(e,C.fromJson(t))}},create:function(e,t,n){var r=this;return n||(n={}),r._callSuper("create",e,t,n).then(function(t){return r._end(e,t,n)})},createMany:function(e,t,n){var r=this;return n||(n={}),r._callSuper("createMany",e,t,n).then(function(t){return r._end(e,t,n)})},defineMapper:function(e,t){var n=this,r=C.getSuper(n).prototype.defineMapper.call(n,e,t);n._pendingQueries[e]={},n._completedQueries[e]={},r.relationList||Object.defineProperty(r,"relationList",{value:[]});var i=n._collections[e]=new n.collectionClass(null,{_added:{},datastore:n,mapper:r}),o=r.schema||{},a=o.properties||{};C.forOwn(a,function(e,t){e.indexed&&i.createIndex(t)}),i.createIndex("addedTimestamps",["$"],{fieldGetter:function(e){return i._added[i.recordId(e)]}}),i.on("all",function(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];n._onCollectionEvent.apply(n,[e].concat(r))});var u=r.idAttribute;return r.relationList.forEach(function(e){var t=e.relation,o=e.localField,a="links."+o,s=e.foreignKey,c=e.type,f={index:s},l=void 0,d=function(){return this._get(a)};c===K?(i.indexes[s]||i.createIndex(s),l={get:d,set:function(o){var c=this,l=this._get(a);if(o===l)return l;var d=C.get(c,u),p=e.getInverse(r);if(o){var h=e.getRelation().idAttribute,v=C.get(o,h);if(C.isUndefined(v)||(o=n.get(t,v)||o),c._set(a,o),Ie(c,s,v),i.updateIndex(c,f),p.type===L)C.set(o,p.localField,c);else if(p.type===M){var g=C.get(o,p.localField);C.noDupeAdd(g,c,function(e){return d===C.get(e,u)})}}else c._set(a,void 0),Ie(c,s,void 0),i.updateIndex(c,f);if(l)if(p.type===L)C.set(l,p.localField,void 0);else if(p.type===M){var y=C.get(l,p.localField);C.remove(y,function(e){return d===C.get(e,u)})}return o}},r.recordClass.prototype.hasOwnProperty(s)&&!function(){var e=r.recordClass;r.recordClass=e.extend({constructor:function(){var t=function(n,r){C.classCallCheck(this,t),e.call(this,n,r)};return t}()})}(),Object.defineProperty(r.recordClass.prototype,s,{enumerable:!0,get:function(){return this._get(s)},set:function(e){var r=this;if(C.isUndefined(e))C.set(r,o,void 0);else{Ie(r,s,e);var i=n.get(t,e);i&&C.set(r,o,i)}}})):c===M?!function(){var i=e.localKeys,o=e.foreignKeys;n._collections[t]&&s&&!n.getCollection(t).indexes[s]&&n.getCollection(t).createIndex(s),l={get:function(){var e=this,t=d.call(e);return t||e._set(a,[]),d.call(e)},set:function(c){var l=this;c||(c=[]),c&&!C.isArray(c)&&(c=[c]);var d=C.get(l,u),p=e.getRelation().idAttribute,h=e.getInverse(r),v=h.localField,g=l._get(a);g||(g=[]);var y=g;g=[];var m={};return c.forEach(function(e){var r=C.get(e,p);C.isUndefined(r)||(e=n.get(t,r)||e,m[r]=e),g.push(e)}),s?(c.forEach(function(e){Ie(e,s,d),n.getCollection(t).updateIndex(e,f),C.set(e,v,l)}),y.forEach(function(e){var r=C.get(e,p);C.isUndefined(r)||m.hasOwnProperty(r)||(Ie(e,s,void 0),n.getCollection(t).updateIndex(e,f),C.set(e,v,void 0))})):i?!function(){var e=[];c.forEach(function(t){C.set(t,v,l),e.push(C.get(t,p))}),C.set(l,i,e),y.forEach(function(e){var t=C.get(e,p);C.isUndefined(t)||m.hasOwnProperty(t)||C.set(e,v,void 0)})}():o&&(y.forEach(function(e){var t=C.get(e,o)||[];C.remove(t,function(e){return d===e});var n=C.get(e,v)||[];C.remove(n,function(e){return d===C.get(e,u)})}),c.forEach(function(e){var t=C.get(e,o)||[];C.noDupeAdd(t,d,function(e){return d===e});var n=C.get(e,v)||[];C.noDupeAdd(n,l,function(e){return d===C.get(e,u)})})),l._set(a,g),g}}}():c===L&&(n._collections[t]&&s&&!n.getCollection(t).indexes[s]&&n.getCollection(t).createIndex(s),l={get:d,set:function(i){var o=this,c=this._get(a);if(i===c)return c;var l=C.get(i,e.getRelation().idAttribute),d=e.getInverse(r).localField;return c&&(Ie(c,s,void 0),n.getCollection(t).updateIndex(c,f),C.set(c,d,void 0)),i?(C.isUndefined(l)||(i=n.get(t,l)||i),o._set(a,i),Ie(i,s,C.get(o,u)),n.getCollection(t).updateIndex(i,f),C.set(i,d,o)):o._set(a,void 0),i}}),l&&(l.enumerable=C.isUndefined(e.enumerable)?!0:e.enumerable,e.get&&!function(){var t=l.get;l.get=function(){var n=this;return e.get(e,this,function(){for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];return t.apply(n,r)})}}(),e.set&&!function(){var t=l.set;l.set=function(n){var r=this;return e.set(e,this,n,function(e){return t.call(r,void 0===e?n:e)})}}(),Object.defineProperty(r.recordClass.prototype,o,l))}),r},destroy:function(e,t,n){var r=this;return n||(n={}),r._callSuper("destroy",e,t,n).then(function(i){return n.raw?i.data=r.getCollection(e).remove(t,n):i=r.getCollection(e).remove(t,n),delete r._pendingQueries[e][t],delete r._completedQueries[e][t],i})},destroyAll:function(e,t,n){var r=this;return n||(n={}),r._callSuper("destroyAll",e,t,n).then(function(i){n.raw?i.data=r.getCollection(e).removeAll(t,n):i=r.getCollection(e).removeAll(t,n);var o=r.hashQuery(e,t,n);return delete r._pendingQueries[e][o],delete r._completedQueries[e][o],i})},eject:function(e,t){return this.remove(e,t)},ejectAll:function(e,t){return this.removeAll(e,t)},find:function(e,t,n){var r=this;n||(n={});var i=r._pendingQueries[e][t];if(C.fillIn(n,r.getMapper(e)),i)return i;var o=r.cachedFind(e,t,n),a=void 0;return a=n.force||!o?r._pendingQueries[e][t]=r._callSuper("find",e,t,n).then(function(i){delete r._pendingQueries[e][t];var o=r._end(e,i,n);return r.cacheFind(e,o,t,n),o},function(n){return delete r._pendingQueries[e][t],C.reject(n)}):C.resolve(o)},findAll:function(e,t,n){var r=this;n||(n={});var i=r.hashQuery(e,t,n),o=r._pendingQueries[e][i];if(C.fillIn(n,r.getMapper(e)),o)return o;var a=r.cachedFindAll(e,i,n),u=void 0;return u=n.force||!a?r._pendingQueries[e][i]=r._callSuper("findAll",e,t,n).then(function(t){delete r._pendingQueries[e][i];var o=r._end(e,t,n);return r.cacheFindAll(e,o,i,n),o},function(t){return delete r._pendingQueries[e][i],C.reject(t)}):C.resolve(a)},getCollection:function(e){var t=this._collections[e];if(!t)throw new ReferenceError(e+" is not a registered collection!");return t},hashQuery:function(e,t,n){return C.toJson(t)},inject:function(e,t){return this.add(e,t)},remove:function(e,t,n){var r=this,i=r.getCollection(e).remove(t,n);return i&&r.removeRelated(e,[i],n),i},removeAll:function(e,t,n){var r=this,i=r.getCollection(e).removeAll(t,n);return i.length&&r.removeRelated(e,i,n),i},removeRelated:function(e,t,n){var r=this;C.forEachRelation(r.getMapper(e),n,function(e,n){t.forEach(function(t){var i=void 0,o=void 0;if(!e.foreignKey||e.type!==L&&e.type!==M?e.type===M&&e.localKeys?o={where:s.defineProperty({},e.getRelation().idAttribute,{in:C.get(t,e.localKeys)})}:e.type===M&&e.foreignKeys?o={where:s.defineProperty({},e.foreignKeys,{contains:e.getForeignKey(t)})}:e.type===K&&(i=r.remove(e.relation,e.getForeignKey(t),n)):o=s.defineProperty({},e.foreignKey,e.getForeignKey(t)),o&&(i=r.removeAll(e.relation,o,n)),i){if(C.isArray(i)&&!i.length)return;e.type===L&&(i=i[0]),e.setLocalField(t,i)}})})},update:function(e,t,n,r){var i=this;return r||(r={}),i._callSuper("update",e,t,n,r).then(function(t){return i._end(e,t,r)})},updateAll:function(e,t,n,r){var i=this;return r||(r={}),i._callSuper("updateAll",e,n,t,r).then(function(t){return i._end(e,t,r)})},updateMany:function(e,t,n){var r=this;return n||(n={}),r._callSuper("updateMany",e,t,n).then(function(t){return r._end(e,t,n)})}},Fe=["add","between","createIndex","filter","get","getAll","query","toJson"];Fe.forEach(function(e){je[e]=function(t){for(var n,r=arguments.length,i=Array(r>1?r-1:0),o=1;r>o;o++)i[o-1]=arguments[o];return(n=this.getCollection(t))[e].apply(n,i)}});var Se=xe.extend(je),ke={alpha:"29",beta:"false",full:"3.0.0-alpha.29",major:parseInt("3",10),minor:parseInt("0",10),patch:parseInt("0",10)};e.version=ke,e.Collection=P,e.Component=t,e.Container=xe,e.DataStore=Se,e.LinkedCollection=Ce,e.Mapper=Ae,e.Query=S,e.Record=Q,e.Schema=ve,e.utils=C,e.belongsToType=K,e.hasManyType=M,e.hasOneType=L,e.belongsTo=N,e.hasMany=D,e.hasOne=T}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("js-data",["exports"],t):t(e.JSData=e.JSData||{})}(this,function(e){"use strict";function t(){Object.defineProperty(this,"_listeners",{value:{}})}function n(e,t,n){return e===t?0:(n&&(e=n(e),t=n(t)),null===e&&null===t?0:null===e?-1:null===t?1:t>e?-1:e>t?1:0)}function r(e,t,n){return e.splice(t,0,n),e}function i(e,t){return e.splice(t,1),e}function o(e,t,r){for(var i=0,o=e.length,a=void 0,u=void 0;o>i;){if(u=(i+o)/2|0,a=n(t,e[u],r),0===a)return{found:!0,index:u};0>a?o=u:i=u+1}return{found:!1,index:o}}function a(e,t){if(j.classCallCheck(this,a),e||(e=[]),!j.isArray(e))throw new Error("fieldList must be an array.");t||(t={}),this.fieldList=e,this.fieldGetter=t.fieldGetter,this.hashCode=t.hashCode,this.isIndex=!0,this.keys=[],this.values=[]}function u(e,t){var n=this,r="new "+q;t||(t={});var i=t.localField;if(!i)throw j.err(r,"opts.localField")(400,"string",i);var o=t.foreignKey=t.foreignKey||t.localKey;if(!o&&(t.type===D||t.type===Q))throw j.err(r,"opts.foreignKey")(400,"string",o);var a=t.localKeys,u=t.foreignKeys;if(!o&&!a&&!u&&t.type===T)throw j.err(r,"opts.")(400,"string",o);if(j.isString(e)){if(t.relation=e,!j.isFunction(t.getRelation))throw j.err(r,"opts.getRelation")(400,"function",t.getRelation)}else{if(!e)throw j.err(r,"related")(400,"Mapper or string",e);t.relation=e.name,Object.defineProperty(n,"relatedMapper",{value:e})}Object.defineProperty(n,"inverse",{value:void 0,writable:!0}),j.fillIn(n,t)}var s={};s.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},s.toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);te?-1:1;return t*f}var n=e%1;return e===e?n?e-n:e:0},O=function(e){return b.call(e)},x=function(e){return!!e&&"object"===("undefined"==typeof e?"undefined":s.typeof(e))&&e.constructor===Object},C=function(e,t){if(!t)return e;var n=t.split(".");return n.forEach(function(t){e[t]||(e[t]={}),e=e[t]}),e},I={Promise:Promise,_:function(e,t){I.forOwn(t,function(t,n){n&&I.isUndefined(e[n])&&!I.isFunction(t)&&0!==n.indexOf("_")&&(e[n]=t)})},_forRelation:function(e,t,n,r){var i=t.relation,o=null,a=void 0;if(e||(e={}),e.with||(e.with=[]),(a=I._getIndex(e.with,i))>=0?o=i:(a=I._getIndex(e.with,t.localField))>=0&&(o=t.localField),e.withAll)return void n.call(r,t,{});if(o){var u={};I.fillIn(u,t.getRelation()),I.fillIn(u,e),u.with=e.with.slice(),u._activeWith=u.with.splice(a,1)[0],u.with.forEach(function(e,t){e&&0===e.indexOf(o)&&e.length>=o.length&&"."===e[o.length]?u.with[t]=e.substr(o.length+1):u.with[t]=""}),n.call(r,t,u)}},_getIndex:function(e,t){var n=-1;return e.forEach(function(e,r){return e===t?(n=r,!1):I.isObject(e)&&e.relation===t?(n=r,!1):void 0}),n},addHiddenPropsToTarget:function(e,t){var n={};I.forOwn(t,function(e,t){n[t]={writable:!0,value:e}}),Object.defineProperties(e,n)},areDifferent:function(e,t,n){n||(n={});var r=I.diffObjects(e,t,n),i=Object.keys(r.added).length+Object.keys(r.removed).length+Object.keys(r.changed).length;return i>0},classCallCheck:function(e,t){if(!(e instanceof t))throw I.err(""+t.name)(500,"Cannot call a class as a function")},copy:function(e,t,n,r,i,o){if(t){if(e===t)throw I.err(c+".copy")(500,"Cannot copy! Source and destination are identical.");if(n=n||[],r=r||[],I.isObject(e)){var a=n.indexOf(e);if(-1!==a)return r[a];n.push(e),r.push(t)}var u=void 0;if(I.isArray(e)){var s=void 0;for(t.length=0,s=0;si;i++)r[i]=arguments[i];var o=r.shift(),a=e[o]||[],u=void 0;for(u=0;ui;i++)t[i]=arguments[i];n.apply(this,t)},r.prototype=Object.create(n&&n.prototype,{constructor:{configurable:!0,enumerable:!1,value:r,writable:!0}});var i=Object;return i.setPrototypeOf?i.setPrototypeOf(r,n):t.strictEs6Class?r.__proto__=n:I.forOwn(n,function(e,t){r[t]=e}),Object.defineProperty(r,"__super__",{configurable:!0,value:n}),I.addHiddenPropsToTarget(r.prototype,e),I.fillIn(r,t),r},fillIn:function(e,t){return I.forOwn(t,function(t,n){e.hasOwnProperty(n)&&void 0!==e[n]||(e[n]=t)}),e},findIndex:function(e,t){var n=-1;return e?(e.forEach(function(e,r){return t(e)?(n=r,!1):void 0}),n):n},forEachRelation:function(e,t,n,r){var i=e.relationList||[];i.length&&i.forEach(function(e){I._forRelation(t,e,n,r)})},forOwn:function(e,t,n){var r=Object.keys(e),i=r.length,o=void 0;for(o=0;i>o;o++)t.call(n,e[r[o]],r[o],e)},fromJson:function(e){return I.isString(e)?JSON.parse(e):e},get:function(e,t){if(t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;return e[r]}},getSuper:function(e,t){var n=t?e:e.constructor;return n.__super__||Object.getPrototypeOf(n)||n.__proto__},intersection:function(e,t){if(!e||!t)return[];var n=[],r=void 0,i=void 0,o=e.length;for(i=0;o>i;i++)r=e[i],-1===n.indexOf(r)&&-1!==t.indexOf(r)&&n.push(r);return n},isArray:Array.isArray,isBlacklisted:function(e,t){if(!t||!t.length)return!1;for(var n=void 0,r=0;rn;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": ("+(this.name||this.constructor.name)+")";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var a;(a=console).log.apply(a,[i].concat(n))}}}})},noDupeAdd:function(e,t,n){if(e){var r=this.findIndex(e,n);0>r&&e.push(t)}},omit:function(e,t){var n={};return I.forOwn(e,function(e,r){-1===t.indexOf(r)&&(n[r]=e)}),n},plainCopy:function(e){return I.copy(e,void 0,void 0,void 0,void 0,!0)},reject:function(e){return I.Promise.reject(e)},remove:function(e,t){if(e&&e.length){var n=this.findIndex(e,t);n>=0&&e.splice(n,1)}},resolve:function(e){return I.Promise.resolve(e)},set:function(e,t,n){if(I.isObject(t))I.forOwn(t,function(t,n){I.set(e,n,t)});else{var r=A.exec(t);r?C(e,r[1])[r[2]]=n:e[t]=n}},strictEqual:function(e,t){var n=e===t;return n||(I.isObject(e)&&I.isObject(t)?(I.forOwn(e,function(e,r){n=n&&I.strictEqual(e,t[r])}),I.forOwn(t,function(t,r){n=n&&I.strictEqual(t,e[r])})):I.isArray(e)&&I.isArray(t)&&e.forEach(function(e,r){n=n&&I.strictEqual(e,t[r])})),n},toJson:JSON.stringify,unset:function(e,t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;e[r]=void 0}};try{I.isBrowser=!!window}catch(e){I.isBrowser=!1}var j=I;t.extend=j.extend,j.logify(t.prototype),j.eventify(t.prototype,function(){return this._listeners},function(e){this._listeners=e});var F="Query",R="Index inaccessible after first operation",E={limit:"",offset:"",orderBy:"",skip:"",sort:"",where:""},S=/([.*+?^=!:${}()|[\]\/\\])/g,k=/%/g,P=/_/g,M=function(e){return e.replace(S,"\\$1")},K=t.extend({constructor:function e(t){var n=this;j.classCallCheck(n,e),n.collection=t,n.data=null},between:function(e,t,n){var r=this;if(n||(n={}),r.data)throw j.err(F+"#between")(500,"Cannot access index");return r.data=r.collection.getIndex(n.index).between(e,t,n),r},compare:function(e,t,n,r){var i=e[t],o=j.get(n,i[0]),a=j.get(r,i[0]);if(o&&j.isString(o)&&(o=o.toUpperCase()),a&&j.isString(a)&&(a=a.toUpperCase()),void 0===n&&(n=null),void 0===r&&(r=null),"DESC"===i[1].toUpperCase()){var u=a;a=o,o=u}return a>o?-1:o>a?1:te;e++){var c=i[e],l="|"===c.charAt(0);c=l?c.substr(1):c;var f=n.evaluate(j.get(a,r[e]),c,o[e]);void 0!==f&&(s=u?f:l?s||f:s&&f),u=!1}return s})}();var a=e.orderBy||e.sort;j.isString(a)&&(a=[[a,"ASC"]]),j.isArray(a)||(a=null),a&&!function(){var e=0;a.forEach(function(e,t){j.isString(e)&&(a[t]=[e,"ASC"])}),n.data.sort(function(t,r){return n.compare(a,e,t,r)})}(),j.isNumber(e.skip)?n.skip(e.skip):j.isNumber(e.offset)&&n.skip(e.offset),j.isNumber(e.limit)&&n.limit(e.limit)}():j.isFunction(e)&&(n.data=n.data.filter(e,t)),n},forEach:function(e,t){return this.getData().forEach(e,t),this},get:function(e,t){var n=this;if(e||(e=[]),t||(t={}),n.data)throw j.err(F+"#get")(500,R);return e&&!j.isArray(e)&&(e=[e]),e.length?(n.data=n.collection.getIndex(t.index).get(e),n):(n.getData(),n)},getAll:function(){var e=this,t={};if(e.data)throw j.err(F+"#getAll")(500,R);for(var n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];if(!r.length||1===r.length&&j.isObject(r[0]))return e.getData(),e;r.length&&j.isObject(r[r.length-1])&&(t=r[r.length-1],r.pop());var o=e.collection,a=o.getIndex(t.index);return e.data=[],r.forEach(function(t){e.data=e.data.concat(a.get(t))}),e},getData:function(){var e=this;return e.data||(e.data=e.collection.index.getAll()),e.data},like:function(e,t){return new RegExp("^"+M(e).replace(k,".*").replace(P,".")+"$",t)},limit:function(e){if(!j.isNumber(e))throw j.err(F+"#limit","num")(400,"number",e);var t=this.getData();return this.data=t.slice(0,Math.min(t.length,e)),this},map:function(e,t){return this.data=this.getData().map(e,t),this},mapCall:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return this.data=this.getData().map(function(t){return t[e].apply(t,n)}),this},run:function(){var e=this.data;return this.data=null,e},skip:function(e){if(!j.isNumber(e))throw j.err(F+"#skip","num")(400,"number",e);var t=this.getData();return e":function(e,t){return e>t},">=":function(e,t){return e>=t},"<":function(e,t){return t>e},"<=":function(e,t){return t>=e},isectEmpty:function(e,t){return!j.intersection(e||[],t||[]).length},isectNotEmpty:function(e,t){return j.intersection(e||[],t||[]).length},in:function(e,t){return-1!==t.indexOf(e)},notIn:function(e,t){return-1===t.indexOf(e)},contains:function(e,t){return-1!==(e||[]).indexOf(t)},notContains:function(e,t){return-1===(e||[]).indexOf(t)}}});j.addHiddenPropsToTarget(a.prototype,{set:function(e,t){j.isArray(e)||(e=[e]);var n=e.shift()||null,i=o(this.keys,n);if(0===e.length)if(i.found){var u=o(this.values[i.index],t,this.hashCode);u.found||r(this.values[i.index],u.index,t)}else r(this.keys,i.index,n),r(this.values,i.index,[t]);else if(i.found)this.values[i.index].set(e,t);else{r(this.keys,i.index,n);var s=new a([],{hashCode:this.hashCode});s.set(e,t),r(this.values,i.index,s)}},get:function(e){j.isArray(e)||(e=[e]);var t=e.shift()||null,n=o(this.keys,t);return 0===e.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(e):[]},getAll:function(){var e=[];return this.values.forEach(function(t){e=t.isIndex?e.concat(t.getAll()):e.concat(t)}),e},visitAll:function(e,t){this.values.forEach(function(n){n.isIndex?n.visitAll(e,t):n.forEach(e,t)})},between:function(e,t,n){n||(n={}),j.isArray(e)||(e=[e]),j.isArray(t)||(t=[t]),j.fillIn(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var r=this._between(e,t,n);return n.limit?r.slice(n.offset,n.limit+n.offset):r.slice(n.offset)},_between:function(e,t,n){var r=[],i=e.shift(),a=t.shift(),u=void 0;if(u=void 0!==i?o(this.keys,i):{found:!1,index:0},0===e.length){u.found&&n.leftInclusive===!1&&(u.index+=1);for(var s=u.index;sa)break}else if(this.keys[s]>=a)break;if(r=this.values[s].isIndex?r.concat(this.values[s].getAll()):r.concat(this.values[s]),n.limit&&r.length>=n.limit+n.offset)break}}else for(var c=u.index;ca)break;if(r=this.values[c].isIndex?l===i?r.concat(this.values[c]._between(j.copy(e),t.map(function(){}),n)):l===a?r.concat(this.values[c]._between(e.map(function(){}),j.copy(t),n)):r.concat(this.values[c].getAll()):r.concat(this.values[c]),n.limit&&r.length>=n.limit+n.offset)break}return n.limit?r.slice(0,n.limit+n.offset):r},peek:function(){return this.values.length?this.values[0].isIndex?this.values[0].peek():this.values[0]:[]},clear:function(){this.keys=[],this.values=[]},insertRecord:function(e){var t=this.fieldList.map(function(t){return j.isFunction(t)?t(e)||null:e[t]||null});this.set(t,e)},removeRecord:function(e){var t=this,n=void 0;return this.values.forEach(function(r,a){if(r.isIndex){if(r.removeRecord(e))return 0===r.keys.length&&(i(t.keys,a),i(t.values,a)),n=!0,!1}else{var u=o(r,e,t.hashCode);if(u.found)return i(r,u.index),0===r.length&&(i(t.keys,a),i(t.values,a)),n=!0,!1}}),n?e:void 0},updateRecord:function(e){this.removeRecord(e),this.insertRecord(e)}});var L="Collection",U={idAttribute:"id",onConflict:"merge"},N=t.extend({constructor:function e(t,n){var r=this;j.classCallCheck(r,e),e.__super__.call(r),t&&!j.isArray(t)&&(n=t,t=[]),j.isString(n)&&(n={idAttribute:n}),t||(t=[]),n||(n={}),Object.defineProperty(r,"mapper",{value:void 0,writable:!0}),j.fillIn(r,n),j.fillIn(r,j.copy(U));var i=r.recordId();Object.defineProperties(r,{index:{value:new a([i],{hashCode:function(e){return j.get(e,i)}})},indexes:{value:{}}}),t&&r.add(t)},_onRecordEvent:function(){this.emit.apply(this,arguments)},add:function(e,t){var n=this;t||(t={}),j._(t,n),e=n.beforeAdd(e,t)||e;var r=!1,i=n.recordId();if(!j.isArray(e)){if(!j.isObject(e))throw j.err(L+"#add","records")(400,"object or array",e);e=[e],r=!0}e=e.map(function(e){var r=n.recordId(e);if(!j.isSorN(r))throw j.err(L+"#add","record."+i)(400,"string or number",r);var o=n.get(r);if(e===o)return o;if(o){var a=t.onConflict||n.onConflict;if("merge"===a)j.deepMixIn(o,e);else{if("replace"!==a)throw j.err(L+"#add","opts.onConflict")(400,"one of (merge, replace)",a,!0);j.forOwn(o,function(t,n){n===i||e.hasOwnProperty(n)||delete o[n]}),o.set(e)}e=o,n.updateIndexes(e)}else e=n.mapper?n.mapper.createRecord(e,t):e,n.index.insertRecord(e),j.forOwn(n.indexes,function(t,n){t.insertRecord(e)}),e&&j.isFunction(e.on)&&e.on("all",n._onRecordEvent,n);return e});var o=r?e[0]:e;return n.emit("add",o),n.afterAdd(e,t,o)||o},afterAdd:function(){},afterRemove:function(){},afterRemoveAll:function(){},beforeAdd:function(){},beforeRemove:function(){},beforeRemoveAll:function(){},between:function(e,t,n){return this.query().between(e,t,n).run()},createIndex:function(e,t,n){var r=this;j.isString(e)&&void 0===t&&(t=[e]),n||(n={}),n.hashCode=n.hashCode||function(e){return r.recordId(e)};var i=r.indexes[e]=new a(t,n);return r.index.visitAll(i.insertRecord,i),r},filter:function(e,t){return this.query().filter(e,t).run()},forEach:function(e,t){this.index.visitAll(e,t)},get:function(e){var t=this.query().get(e).run();return t.length?t[0]:void 0},getAll:function(){var e;return(e=this.query()).getAll.apply(e,arguments).run()},getIndex:function(e){var t=e?this.indexes[e]:this.index;if(!t)throw j.err(L+"#getIndex",e)(404,"index");return t},limit:function(e){return this.query().limit(e).run()},map:function(e,t){var n=[];return this.index.visitAll(function(r){n.push(e.call(t,r))}),n},mapCall:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=[];return this.index.visitAll(function(t){i.push(t[e].apply(t,n))}),i},recordId:function(e){var t=this;return e?j.get(e,t.recordId()):t.mapper?t.mapper.idAttribute:t.idAttribute},query:function(){return new K(this)},reduce:function(e,t){var n=this.getAll();return n.reduce(e,t)},remove:function(e,t){var n=this;t||(t={}),n.beforeRemove(e,t);var r=n.get(e);return r&&(n.index.removeRecord(r),j.forOwn(n.indexes,function(e,t){e.removeRecord(r)}),r&&j.isFunction(r.off)&&(r.off("all",n._onRecordEvent,n),n.emit("remove",r))),n.afterRemove(e,t,r)||r},removeAll:function(e,t){var n=this;t||(t={}),n.beforeRemoveAll(e,t);var r=n.filter(e);return r.forEach(function(e){n.remove(n.recordId(e),t)}),n.afterRemoveAll(e,t,r)||r},skip:function(e){return this.query().skip(e).run()},toJSON:function(e){return this.mapCall("toJSON",e)},updateIndex:function(e,t){t||(t={}),this.getIndex(t.index).updateRecord(e)},updateIndexes:function(e){var t=this;t.index.updateRecord(e),j.forOwn(t.indexes,function(t,n){t.updateRecord(e)})}}),D="belongsTo",T="hasMany",Q="hasOne",q="Relation";j.addHiddenPropsToTarget(u.prototype,{getRelation:function(){return this.relatedMapper},getForeignKey:function(e){return this.type===D?j.get(e,this.foreignKey):j.get(e,this.mapper.idAttribute)},setForeignKey:function(e,t){var n=this;e&&t&&(n.type===D?j.set(e,n.foreignKey,j.get(t,n.getRelation().idAttribute)):!function(){var r=n.mapper.idAttribute;j.isArray(t)?t.forEach(function(t){j.set(t,n.foreignKey,j.get(e,r))}):j.set(t,n.foreignKey,j.get(e,r))}())},getLocalField:function(e){return j.get(e,this.localField)},setLocalField:function(e,t){return j.set(e,this.localField,t)},getInverse:function(e){var t=this;return t.inverse?t.inverse:(t.getRelation().relationList.forEach(function(n){if(n.getRelation()===e){if(n.foreignKey&&n.foreignKey!==t.foreignKey)return;return t.inverse=n,!1}}),t.inverse)}});var J=function(e,t,n){n.name=e.name;var r=new u(t,n);Object.defineProperty(r,"mapper",{value:e}),e.relationList||Object.defineProperty(e,"relationList",{value:[]}),e.relationFields||Object.defineProperty(e,"relationFields",{value:[]}),e.relationList.push(r),e.relationFields.push(r.localField)},B=function(e,t){return t||(t={}),t.type=D,function(n){J(n,e,t)}},$=function(e,t){return t||(t={}),t.type=T,function(n){J(n,e,t)}},V=function(e,t){return t||(t={}),t.type=Q,function(n){J(n,e,t)}},H="Record",G=function(e,t){var n=e.datastore;return n&&n[t]?function(){for(var r=arguments.length,i=Array(r),o=0;r>o;o++)i[o]=arguments[o];return n[t].apply(n,[e.name].concat(i))}:e[t].bind(e)},W=t.extend({constructor:function e(t,n){var r=this;j.classCallCheck(r,e),t||(t={}),n||(n={});var i={};Object.defineProperties(r,{_get:{value:function(e){return j.get(i,e)}},_set:{value:function(e,t){return j.set(i,e,t)}},_unset:{value:function(e){return j.unset(i,e)}}});var o=r._set;o("creating",!0),n.noValidate&&o("noValidate",!0),j.fillIn(r,t),o("creating",!1),o("noValidate",!1),o("previous",j.copy(t))},_mapper:function(){var e=this,t=e.constructor.mapper;if(!t)throw j.err(H+"#_mapper","")(404,"mapper");return t},afterLoadRelations:function(){},beforeLoadRelations:function(){},changes:function(e){var t=this;return e||(e={}),j.diffObjects(t,t._get("previous"),e)},commit:function(){var e=this;return e._set("changed"),e._set("previous",j.copy(e)),e},destroy:function(e){var t=this;e||(e={});var n=t._mapper();return G(n,"destroy")(j.get(t,n.idAttribute),e)},get:function(e){return j.get(this,e)},hasChanges:function(e){var t=this,n=!!(t._get("changed")||[]).length;return n||j.areDifferent(t,t._get("previous"),e)},hashCode:function(){var e=this;return j.get(e,e._mapper().idAttribute)},isValid:function(e){var t=this;return!t._mapper().validate(t,e)},loadRelations:function(e,t){var n=void 0,r=this,i=r._mapper();return e||(e=[]),j.isString(e)&&(e=[e]),t||(t={}),t.with=e,j._(t,i),t.adapter=i.getAdapterName(t),n=t.op="beforeLoadRelations",j.resolve(r[n](e,t)).then(function(){n=t.op="loadRelations",i.dbg(n,r,e,t);var o=[],a=void 0;return j.forEachRelation(i,t,function(e,n){var u=e.getRelation();if(n.raw=!1,j.isFunction(e.load))a=e.load(i,e,r,t);else if("hasMany"===e.type||"hasOne"===e.type)e.foreignKey?a=G(u,"findAll")(s.defineProperty({},e.foreignKey,j.get(r,i.idAttribute)),n).then(function(t){return"hasOne"===e.type?t.length?t[0]:void 0:t}):e.localKeys?a=G(u,"findAll")({where:s.defineProperty({},u.idAttribute,{in:j.get(r,e.localKeys)})}):e.foreignKeys&&(a=G(u,"findAll")({where:s.defineProperty({},e.foreignKeys,{contains:j.get(r,i.idAttribute)})},t));else if("belongsTo"===e.type){var c=j.get(r,e.foreignKey);j.isSorN(c)&&(a=G(u,"find")(c,n))}a&&(a=a.then(function(t){e.setLocalField(r,t)}),o.push(a))}),Promise.all(o)}).then(function(){return n=t.op="afterLoadRelations",j.resolve(r[n](e,t)).then(function(){return r})})},previous:function(e){var t=this;return e?t._get("previous."+e):t._get("previous")},revert:function(e){var t=this,n=t._get("previous");return e||(e={}),e.preserve||(e.preserve=[]),j.forOwn(t,function(r,i){i!==t._mapper().idAttribute&&!n.hasOwnProperty(i)&&t.hasOwnProperty(i)&&-1===e.preserve.indexOf(i)&&delete t[i]}),j.forOwn(n,function(n,r){-1===e.preserve.indexOf(r)&&(t[r]=n)}),t.commit(),t},save:function(e){var t=this;e||(e={});var n=t._mapper(),r=j.get(t,n.idAttribute),i=t;if(j.isUndefined(r))return G(n,"create")(i,e);if(e.changesOnly){var o=t.changes(e);i={},j.fillIn(i,o.added),j.fillIn(i,o.changed)}return G(n,"update")(r,i,e)},set:function(e,t,n){var r=this;j.isObject(e)&&(n=t),n||(n={}),n.silent&&r._set("silent",!0),j.set(r,e,t),r._get("eventId")||r._set("silent")},toJSON:function(e){var t=this,n=this.constructor.mapper;if(n)return n.toJSON(this,e);var r=function(){var e={};return j.forOwn(t,function(t,n){e[n]=j.copy(t)}),{v:e}}();return"object"===("undefined"==typeof r?"undefined":s.typeof(r))?r.v:void 0},unset:function(e,t){this.set(e,void 0,t)},validate:function(e){return this._mapper().validate(this,e)}});j.eventify(W.prototype,function(){return this._get("events")},function(e){this._set("events",e)});var z="Schema",X={array:j.isArray,boolean:j.isBoolean,integer:j.isInteger,null:j.isNull,number:j.isNumber,object:j.isObject,string:j.isString},Y=function(e,t){var n="";return e&&(n+=j.isNumber(e)?"["+e+"]":t?"."+e:""+e),n},Z=function(e){e||(e={});var t="",n=e.path||[];return n.forEach(function(e){t+=Y(e,t)}),t+=Y(e.prop,t)},ee=function(e,t,n){return{expected:t,actual:""+e,path:Z(n)}},te=function(e,t,n,r){r.push(ee(e,t,n))},ne=function(e,t,n,r){var i=n[e];return t.length>i?ee(t.length,"length no more than "+i,r):void 0},re=function(e,t,n,r){var i=n[e];return t.lengthu;u++)o&&(e=n.items[u]),r.prop=u,i=i.concat(pe(t[u],e,r)||[]);return i.length?i:void 0},maximum:function e(t,n,r){var e=n.maximum,i=n.exclusiveMaximum;return("undefined"==typeof t?"undefined":s.typeof(t))===("undefined"==typeof e?"undefined":s.typeof(e))&&(i?t>e:t>=e)?ee(t,"no more than "+e,r):void 0},maxItems:function(e,t,n){return ne("maxItems",e,t,n)},maxLength:function(e,t,n){return ne("maxLength",e,t,n)},maxProperties:function e(t,n,r){var e=n.maxProperties,i=Object.keys(t).length;return i>e?ee(i,"no more than "+e+" properties",r):void 0},minimum:function e(t,n,r){var e=n.minimum,i=n.exclusiveMinimum;return("undefined"==typeof t?"undefined":s.typeof(t))===("undefined"==typeof e?"undefined":s.typeof(e))&&(i?e>t:e>=t)?ee(t,"no less than "+e,r):void 0},minItems:function(e,t,n){return re("minItems",e,t,n)},minLength:function(e,t,n){return re("minLength",e,t,n)},minProperties:function e(t,n,r){var e=n.minProperties,i=Object.keys(t).length;return e>i?ee(i,"no more than "+e+" properties",r):void 0},multipleOf:function(e,t,n){},not:function(e,t,n){return pe(e,t.not,n)?void 0:ee("succeeded","should have failed",n)},oneOf:function(e,t,n){var r=!1,i=[];return t.oneOf.forEach(function(t){var o=pe(e,t,n);if(o)i=i.concat(o);else{if(r)return i=[ee("valid against more than one","valid against only one",n)],r=!1,!1;r=!0}}),r?void 0:i},pattern:function e(t,n,r){var e=n.pattern;return j.isString(t)&&!t.match(e)?ee(t,e,r):void 0},properties:function e(t,n,r){r||(r={});var i=j.isUndefined(n.additionalProperties)?!0:n.additionalProperties,o={},e=n.properties||{},a=n.patternProperties||{},u=[];j.forOwn(t,function(e,t){o[t]=void 0}),j.forOwn(e||{},function(e,n){j.isUndefined(t[n])&&!j.isUndefined(e.default)&&(t[n]=j.copy(e.default)),r.prop=n,u=u.concat(pe(t[n],e,r)||[]),delete o[n]}),j.forOwn(a,function(e,n){j.forOwn(o,function(i,a){a.match(n)&&(r.prop=a,u=u.concat(pe(t[a],e,r)||[]),delete o[a])})});var s=Object.keys(o);return i===!1?s.length&&te("extra fields: "+s.join(", "),"no extra fields",r,u):j.isObject(i)&&s.forEach(function(e){r.prop=e,u=u.concat(pe(t[e],i,r)||[])}),u.length?u:void 0},required:function e(t,n,r){var e=n.required,i=[];return r.existingOnly||e.forEach(function(e){if(j.isUndefined(j.get(t,e))){var n=r.prop;r.prop=e,te(void 0,"a value",r,i),r.prop=n}}),i.length?i:void 0},type:function e(t,n,r){var e=n.type,i=void 0;if(j.isString(e)&&(e=[e]),e.forEach(function(e){return X[e](t,n,r)?(i=e,!1):void 0}),!i)return ee(t?"undefined"==typeof t?"undefined":s.typeof(t):""+t,"one of ("+e.join(", ")+")",r);var o=we[i];return o?o(t,n,r):void 0},uniqueItems:function(e,t,n){if(e&&e.length&&t.uniqueItems){var r=e.length,i=void 0,o=void 0,a=void 0;for(o=r-1;o>0;o--)for(i=e[o],a=o-1;a>=0;a--)if(i===e[a])return ee(i,"no duplicates",n)}}},oe=function(e,t,n,r){return!j.isUndefined(n[e])&&ie[e](t,n,r)},ae=function(e,t,n,r){var i=[];return e.forEach(function(e){i=i.concat(oe(e,t,n,r)||[])}),i.length?i:void 0},ue=["enum","type","allOf","anyOf","oneOf","not"],se=["items","maxItems","minItems","uniqueItems"],ce=["multipleOf","maximum","minimum"],le=["maxProperties","minProperties","required","properties","dependencies"],fe=["maxLength","minLength","pattern"],de=function(e,t,n){return ae(ue,e,t,n)},pe=function e(t,n,r){var i=[];r||(r={});var o=void 0,a=r.prop;if(!j.isUndefined(n)){if(!j.isObject(n))throw j.err(z+"#validate")(500,'Invalid schema at path: "'+r.path+'"');return j.isUndefined(r.path)&&(r.path=[]),j.isUndefined(r.prop)||(o=!0,r.path.push(r.prop),r.prop=void 0),n.extends&&(i=j.isFunction(n.extends.validate)?i.concat(n.extends.validate(t,r)||[]):i.concat(e(t,n.extends,r)||[])),j.isUndefined(t)?(n.required===!0&&te(t,"a value",r,i),o&&(r.path.pop(),r.prop=a),i.length?i:void 0):(i=i.concat(de(t,n,r)||[]),o&&(r.path.pop(),r.prop=a),i.length?i:void 0)}},he="changing",ve="changed",ge="creating",ye="eventId",me="noValidate",be="silent",Ae="validation failed",_e=function(e,t,n){var r={enumerable:j.isUndefined(t.enumerable)?!0:!!t.enumerable},i="props."+e,o="previous."+e,a=n.getter,u=n.setter,s=n.unsetter;return r.get=function(){return this._get(i)},r.set=function(n){var r=this,c=r[a],l=r[u],f=r[s];if(!c(me)){var d=t.validate(n);if(d){var p=new Error(Ae);throw p.errors=d,p}}return t.track&&!c(ge)&&!function(){var t=c(o),a=c(i),u=c(he),s=c(ve);u||(s=[]);var d=s.indexOf(e);a!==n&&-1===d&&s.push(e),t===n&&d>=0&&s.splice(d,1),s.length||(u=!1,f(he),f(ve),c(ye)&&(clearTimeout(c(ye)),f(ye))),!u&&s.length&&(l(ve,s),l(he,!0),l(ye,setTimeout(function(){if(f(ve),f(ye),f(he),!c(be)){var e=void 0;for(e=0;er;r++)n[r]=arguments[r];var i=this,o=n[n.length-e];i.dbg.apply(i,[o.op].concat(n)),(o.notify||void 0===o.notify&&i.notify)&&setTimeout(function(){i.emit.apply(i,[o.op].concat(n))})}},Ie=Ce(1),je=Ce(2),Fe={count:{defaults:[{},{}],skip:!0,types:[]},destroy:{defaults:[{},{}],skip:!0,types:[]},destroyAll:{defaults:[{},{}],skip:!0,types:[]},find:{defaults:[void 0,{}],types:[]},findAll:{defaults:[{},{}],types:[]},sum:{defaults:[void 0,{},{}],skip:!0,types:[]},update:{adapterArgs:function(e,t,n,r){return[t,e.toJSON(n,r),r]},beforeAssign:1,defaults:[void 0,{},{}],types:[]},updateAll:{adapterArgs:function(e,t,n,r){return[e.toJSON(t,r),n,r]},beforeAssign:0,defaults:[{},{},{}],types:[]},updateMany:{adapterArgs:function(e,t,n){return[t.map(function(t){return e.toJSON(t,n)}),n]},beforeAssign:0,defaults:[[],{}],types:[]}},Re={_adapters:{},applySchema:!0,debug:!1,defaultAdapter:"http",idAttribute:"id",notify:j.isBrowser,raw:!1},Ee=t.extend({constructor:function e(t){var n=this;if(j.classCallCheck(n,e),e.__super__.call(n),t||(t={}),Object.defineProperties(n,{_adapters:{value:void 0,writable:!0},recordClass:{value:void 0,writable:!0},lifecycleMethods:{value:Fe},schema:{value:void 0,writable:!0}}),j.fillIn(n,t),j.fillIn(n,j.copy(Re)),!n.name)throw j.err("new "+xe,"opts.name")(400,"string",n.name);n.schema instanceof Oe||(n.schema=new Oe(n.schema||{})),j.isUndefined(n.recordClass)&&!function(){var e=W;n.recordClass=e.extend({constructor:function(){var t=function(n,r){j.classCallCheck(this,t),e.call(this,n,r)};return t}()})}(),n.recordClass&&(n.recordClass.mapper=n,j.getSuper(n.recordClass,!0)===W&&n.schema&&n.schema.apply&&n.applySchema&&n.schema.apply(n.recordClass.prototype))},afterCount:je,afterCreate:je,afterCreateMany:je,afterDestroy:je,afterDestroyAll:je,afterFind:je,afterFindAll:je,afterSum:je,afterUpdate:je,afterUpdateAll:je,afterUpdateMany:je,beforeCreate:Ie,beforeCreateMany:Ie,beforeCount:Ie,beforeDestroy:Ie,beforeDestroyAll:Ie,beforeFind:Ie,beforeFindAll:Ie,beforeSum:Ie,beforeUpdate:Ie,beforeUpdateAll:Ie,beforeUpdateMany:Ie,_end:function(e,t,n){var r=this;if(t.raw&&j._(e,t),n)return e;var i=t.raw?e.data:e;return i&&j.isFunction(r.wrap)&&(i=r.wrap(i,t),t.raw?e.data=i:e=i),e},belongsTo:function(e,t){return B(e,t)(this)},count:function(e,t){return this.crud("count",e,t)},create:function(e,t){var n=void 0,r=void 0,i=this;return e||(e={}),t||(t={}),j._(t,i),r=t.adapter=i.getAdapterName(t),n=t.op="beforeCreate",j.resolve(i[n](e,t)).then(function(o){e=j.isUndefined(o)?e:o;var a={};t.with||(t.with=[]);var u=[];return j.forEachRelation(i,t,function(t,n){var r=t.getLocalField(e),i=t.getRelation(),o=i.idAttribute;n.raw=!1,r&&(t.type===D?u.push(i.create(r,n).then(function(n){t.setLocalField(a,n),t.setForeignKey(e,n)})):t.type===T&&t.localKeys&&u.push(i.createMany(r,n).then(function(n){t.setLocalField(a,n),j.set(e,t.localKeys,n.map(function(e){return j.get(e,o)}))})))}),j.Promise.all(u).then(function(){return n=t.op="create",i.dbg(n,e,t),j.resolve(i.getAdapter(r)[n](i,i.toJSON(e,{with:t.pass||[]}),t))}).then(function(n){var r=t.raw?n.data:n;return u=[],j.forEachRelation(i,t,function(t,n){var i=t.getLocalField(e);if(i){n.raw=!1;var o=void 0;t.type===T&&t.foreignKey?(t.setForeignKey(r,i),o=t.getRelation().createMany(i,n).then(function(e){t.setLocalField(r,e)})):t.type===Q?(t.setForeignKey(r,i),o=t.getRelation().create(i,n).then(function(e){t.setLocalField(r,e)})):t.type===D&&t.getLocalField(a)?t.setLocalField(r,t.getLocalField(a)):t.type===T&&t.localKeys&&t.getLocalField(a)&&t.setLocalField(r,t.getLocalField(a)),o&&u.push(o)}}),j.Promise.all(u).then(function(){return n})})}).then(function(r){return r=i._end(r,t),n=t.op="afterCreate",j.resolve(i[n](e,t,r)).then(function(e){return j.isUndefined(e)?r:e})})},createInstance:function(e,t){return this.createRecord(e,t)},createMany:function(e,t){var n=void 0,r=void 0,i=this;return e||(e=[]),t||(t={}),j._(t,i),r=t.adapter=i.getAdapterName(t),n=t.op="beforeCreateMany",j.resolve(i[n](e,t)).then(function(o){e=j.isUndefined(o)?e:o;var a={};t.with||(t.with=[]);var u=[];return j.forEachRelation(i,t,function(t,n){var r=e.map(function(e){return t.getLocalField(e)}).filter(function(e){return e});t.type===D&&r.length===e.length&&u.push(t.getRelation().createMany(r,n).then(function(r){var i=n.raw?r.data:r;t.setLocalField(a,i),e.forEach(function(e,n){t.setForeignKey(e,i[n])})}))}),j.Promise.all(u).then(function(){n=t.op="createMany";var o=e.map(function(e){return i.toJSON(e,{with:t.pass||[]})});return i.dbg(n,e,t),j.resolve(i.getAdapter(r)[n](i,o,t))}).then(function(n){var r=t.raw?n.data:n;return u=[],j.forEachRelation(i,t,function(n,o){var s=e.map(function(e){return n.getLocalField(e)}).filter(function(e){return e});if(s.length===e.length){var c=n.getLocalField(a),l=void 0;n.type===T?i.log("warn","deep createMany of hasMany type not supported!"):n.type===Q?(r.forEach(function(e,t){n.setForeignKey(e,s[t])}),l=n.getRelation().createMany(s,o).then(function(e){var i=t.raw?e.data:e;r.forEach(function(e,t){n.setLocalField(e,i[t])})})):n.type===D&&c&&c.length===r.length&&r.forEach(function(e,t){n.setLocalField(e,c[t])}),l&&u.push(l)}}),j.Promise.all(u).then(function(){return n})})}).then(function(r){return r=i._end(r,t),n=t.op="afterCreateMany",j.resolve(i[n](e,t,r)).then(function(e){return j.isUndefined(e)?r:e})})},createRecord:function(e,t){e||(e={});var n=this;if(j.isArray(e))return e.map(function(e){return n.createRecord(e,t)});if(!j.isObject(e))throw j.err(xe+"#createRecord","props")(400,"array or object",e);var r=n.recordClass,i=n.relationList||[];return i.forEach(function(n){var r=n.getRelation(),i=n.getLocalField(e);if(i&&!r.is(i)){if(j.isArray(i)&&(!i.length||r.is(i[0])))return;j.set(e,n.localField,r.createRecord(i,t))}}),r?e instanceof r?e:new r(e,t):e},crud:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=this,o=i.lifecycleMethods[e];if(!o)throw j.err(xe+"#crud",e)(404,"method");var a=""+e.charAt(0).toUpperCase()+e.substr(1),u="before"+a,c="after"+a,l=void 0,f=void 0;o.defaults.forEach(function(e,t){j.isUndefined(n[t])&&(n[t]=j.copy(e))});var d=n[n.length-1];return j._(d,i),f=d.adapter=i.getAdapterName(d),l=d.op=u,j.resolve(i[l].apply(i,s.toConsumableArray(n))).then(function(t){var r;return j.isUndefined(o.beforeAssign)||(n[o.beforeAssign]=j.isUndefined(t)?n[o.beforeAssign]:t),l=d.op=e,n=o.adapterArgs?o.adapterArgs.apply(o,[i].concat(s.toConsumableArray(n))):n,i.dbg.apply(i,[l].concat(s.toConsumableArray(n))),j.resolve((r=i.getAdapter(f))[l].apply(r,[i].concat(s.toConsumableArray(n))))}).then(function(e){return e=i._end(e,d,!!o.skip),n.push(e),l=d.op=c,j.resolve(i[l].apply(i,s.toConsumableArray(n))).then(function(t){return j.isUndefined(t)?e:t})})},destroy:function(e,t){return this.crud("destroy",e,t)},destroyAll:function(e,t){return this.crud("destroyAll",e,t)},find:function(e,t){return this.crud("find",e,t)},findAll:function(e,t){return this.crud("findAll",e,t)},getAdapter:function(e){var t=this;t.dbg("getAdapter","name:",e);var n=t.getAdapterName(e);if(!n)throw j.err(xe+"#getAdapter","name")(400,"string",e);return t.getAdapters()[n]},getAdapterName:function(e){return e||(e={}),j.isString(e)&&(e={adapter:e}),e.adapter||e.defaultAdapter},getAdapters:function(){return this._adapters},getSchema:function(){return this.schema},hasMany:function(e,t){return $(e,t)(this)},hasOne:function(e,t){return V(e,t)(this)},is:function(e){var t=this.recordClass;return t?e instanceof t:!1},registerAdapter:function(e,t,n){var r=this;n||(n={}),r.getAdapters()[e]=t,(n===!0||n.default)&&(r.defaultAdapter=e)},sum:function(e,t,n){return this.crud("sum",e,t,n)},toJSON:function(e,t){var n=this;t||(t={});var r=(n?n.relationFields:[])||[],i={},o=void 0;if(n&&n.schema&&(o=n.schema.properties||{},j.forOwn(o,function(t,n){i[n]=j.plainCopy(e[n])})),o||(o={}),!t.strict)for(var a in e)o[a]||-1!==r.indexOf(a)||(i[a]=j.plainCopy(e[a]));return n&&t.withAll&&(t.with=r.slice()),n&&t.with&&(j.isString(t.with)&&(t.with=[t.with]),j.forEachRelation(n,t,function(t,n){var r=t.getLocalField(e);r&&(j.isArray(r)?t.setLocalField(i,r.map(function(e){return t.getRelation().toJSON(e,n)})):t.setLocalField(i,t.getRelation().toJSON(r,n)))})),i},update:function(e,t,n){return this.crud("update",e,t,n)},updateAll:function(e,t,n){return this.crud("updateAll",e,t,n)},updateMany:function(e,t){return this.crud("updateMany",e,t)},validate:function(e,t){var n=this,r=n.getSchema();if(!j.isArray(e))return r.validate(e,t);var i=e.map(function(e){return r.validate(e,t)}),o=!1;return i.forEach(function(e){e&&(o=!0)}),o?i:void 0},wrap:function(e,t){return this.createRecord(e,t)}}),Se="Container",ke=["count","create","createMany","createRecord","dbg","destroy","destroyAll","find","findAll","getSchema","is","log","sum","toJSON","update","updateAll","updateMany"],Pe={constructor:function e(t){var n=this;j.classCallCheck(n,e),e.__super__.call(n),t||(t={}),j.fillIn(n,t),n.mapperDefaults=n.mapperDefaults||{},n.mapperClass=n.mapperClass||Ee,n._adapters={},n._mappers={}},_onMapperEvent:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=n.shift();this.emit.apply(this,[i,e].concat(n))},defineMapper:function(e,t){var n=this;if(j.isObject(e)&&(t=e,e=t.name),!j.isString(e))throw j.err(Se+"#defineMapper","name")(400,"string",e);t||(t={}),t.name=e,t.relations||(t.relations={});var r=t.mapperClass||n.mapperClass;delete t.mapperClass,j.fillIn(t,n.mapperDefaults);var i=n._mappers[e]=new r(t);return i.relations||(i.relations={}),i.name=e,i._adapters=n.getAdapters(),i.datastore=n,i.on("all",function(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];n._onMapperEvent.apply(n,[e].concat(r))}),j.forOwn(i.relations,function(e,t){j.forOwn(e,function(e,r){j.isObject(e)&&(e=[e]),e.forEach(function(e){e.getRelation=function(){return n.getMapper(r)};var o=n._mappers[r]||r;t===D?i.belongsTo(o,e):t===Q?i.hasOne(o,e):t===T&&i.hasMany(o,e)})})}),i},defineResource:function(e,t){return this.defineMapper(e,t)},getAdapter:function(e){var t=this,n=t.getAdapterName(e);if(!n)throw j.err(Se+"#getAdapter","name")(400,"string",e);return t.getAdapters()[n]},getAdapterName:function(e){return e||(e={}),j.isString(e)&&(e={adapter:e}),e.adapter||this.mapperDefaults.defaultAdapter},getAdapters:function(){return this._adapters},getMapper:function(e){var t=this._mappers[e];if(!t)throw j.err(Se+"#getMapper",e)(404,"mapper");return t},registerAdapter:function(e,t,n){var r=this;n||(n={}),r.getAdapters()[e]=t,(n===!0||n.default)&&(r.mapperDefaults.defaultAdapter=e,j.forOwn(r._mappers,function(t){t.defaultAdapter=e}))}};ke.forEach(function(e){Pe[e]=function(t){for(var n,r=arguments.length,i=Array(r>1?r-1:0),o=1;r>o;o++)i[o-1]=arguments[o];return(n=this.getMapper(t))[e].apply(n,i)}});var Me=t.extend(Pe),Ke="LinkedCollection",Le=N.extend({constructor:function e(t,n){var r=this;if(j.classCallCheck(r,e),e.__super__.call(r,t,n),Object.defineProperty(r,"_added",{value:{}}),!r.datastore)throw j.err("new "+Ke,"opts.datastore")(400,"DataStore",r.datastore);return r},_onRecordEvent:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];j.getSuper(e).prototype._onRecordEvent.apply(e,n);var i=n[0];j.isString(i)&&0===i.indexOf("change")&&e.updateIndexes(n[1])},add:function(e,t){var n=this,r=n.datastore,i=n.mapper,o=i.relationList,a=(new Date).getTime(),u=!!i.recordClass,c=i.idAttribute,l=void 0;return j.isObject(e)&&!j.isArray(e)&&(l=!0,e=[e]),e=j.getSuper(n).prototype.add.call(n,e,t),o.length&&e.length&&i.relationList.forEach(function(t){var n=t.relation,i=r.getMapper(n),o=i.idAttribute,a=t.foreignKey,u=r.getCollection(n),l=t.type,f=l===T,d=j.isUndefined(t.add)?!0:!!t.add,p=void 0;e.forEach(function(e){p=t.getLocalField(e);var n=j.get(e,c);if(j.isFunction(t.add))p=t.add(r,t,e);else if(p)if(f)p=p.map(function(n){return n!==u.get(u.recordId(n))&&(a&&t.setForeignKey(e,n),d&&(n=u.add(n))),n});else{var i=j.get(p,o);p!==u.get(i)&&(t.setForeignKey(e,p),d&&(p=u.add(p)))}if(!p||j.isArray(p)&&!p.length)if(l===D){var h=j.get(e,a);j.isUndefined(h)||(p=u.get(h))}else if(l===Q){var v=u.filter(s.defineProperty({},a,n));p=v.length?v[0]:void 0}else if(l===T)if(a){var g=u.filter(s.defineProperty({},a,n));p=g.length?g:void 0}else if(t.localKeys&&j.get(e,t.localKeys)){var y=u.filter({where:s.defineProperty({},o,{in:j.get(e,t.localKeys)})});p=y.length?y:void 0}else if(t.foreignKeys){var m=u.filter({where:s.defineProperty({},t.foreignKeys,{contains:n})});p=m.length?m:void 0}p&&t.setLocalField(e,p)})}),e.forEach(function(e){n._added[n.recordId(e)]=a,u&&e._set("$",a)}),l?e[0]:e},remove:function(e,t){var n=this,r=n.mapper,i=j.getSuper(n).prototype.remove.call(n,e,t);return i&&(delete n._added[e],r.recordClass&&i._set("$")),i},removeAll:function(e,t){var n=this,r=n.mapper,i=j.getSuper(n).prototype.removeAll.call(n,e,t);return i.forEach(function(e){delete n._added[n.recordId(e)],r.recordClass&&e._set("$")}),i}}),Ue="DataStore",Ne={},De=function(e,t,n){e&&e._set?e._set(t,n):j.set(e,t,n)},Te=function(e,t,n){var r=this,i=r._completedQueries[e][t];return j.isFunction(i)?i(e,t,n):i},Qe={constructor:function e(t){var n=this;return j.classCallCheck(n,e),e.__super__.call(n,t),n.collectionClass=n.collectionClass||Le,n._collections={},j.fillIn(n,Ne),n._pendingQueries={},n._completedQueries={},n},_callSuper:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return this.constructor.__super__.prototype[e].apply(this,n)},_end:function(e,t,n){var r=n.raw?t.data:t;return r&&j.isFunction(this.addToCache)&&(r=this.addToCache(e,r,n),n.raw?t.data=r:t=r),t},_onCollectionEvent:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=n.shift();this.emit.apply(this,[i,e].concat(n))},addToCache:function(e,t,n){return this.getCollection(e).add(t,n)},cachedFind:Te,cachedFindAll:Te,cacheFind:function(e,t,n,r){var i=this;i._completedQueries[e][n]=function(e,t,n){return i.get(e,t)}},cacheFindAll:function(e,t,n,r){var i=this;i._completedQueries[e][n]=function(e,t,n){return i.filter(e,j.fromJson(t))}},create:function(e,t,n){var r=this;return n||(n={}),r._callSuper("create",e,t,n).then(function(t){return r._end(e,t,n)})},createMany:function(e,t,n){var r=this;return n||(n={}),r._callSuper("createMany",e,t,n).then(function(t){return r._end(e,t,n)})},defineMapper:function(e,t){var n=this,r=j.getSuper(n).prototype.defineMapper.call(n,e,t);n._pendingQueries[e]={},n._completedQueries[e]={},r.relationList||Object.defineProperty(r,"relationList",{value:[]});var i=n._collections[e]=new n.collectionClass(null,{_added:{},datastore:n,mapper:r}),o=r.schema||{},a=o.properties||{};j.forOwn(a,function(e,t){e.indexed&&i.createIndex(t)}),i.createIndex("addedTimestamps",["$"],{fieldGetter:function(e){return i._added[i.recordId(e)]}}),i.on("all",function(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];n._onCollectionEvent.apply(n,[e].concat(r))});var u=r.idAttribute;return r.relationList.forEach(function(e){var t=e.relation,o=e.localField,a="links."+o,s=e.foreignKey,c=e.type,l={index:s},f=void 0,d=function(){return this._get(a)};c===D?(i.indexes[s]||i.createIndex(s),f={get:d,set:function(o){var c=this,f=this._get(a);if(o===f)return f;var d=j.get(c,u),p=e.getInverse(r);if(o){var h=e.getRelation().idAttribute,v=j.get(o,h);if(j.isUndefined(v)||(o=n.get(t,v)||o),c._set(a,o),De(c,s,v),i.updateIndex(c,l),p.type===Q)j.set(o,p.localField,c);else if(p.type===T){var g=j.get(o,p.localField);j.noDupeAdd(g,c,function(e){return d===j.get(e,u)})}}else c._set(a,void 0),De(c,s,void 0),i.updateIndex(c,l);if(f)if(p.type===Q)j.set(f,p.localField,void 0);else if(p.type===T){var y=j.get(f,p.localField);j.remove(y,function(e){return d===j.get(e,u)})}return o}},r.recordClass.prototype.hasOwnProperty(s)&&!function(){var e=r.recordClass;r.recordClass=e.extend({constructor:function(){var t=function(n,r){j.classCallCheck(this,t),e.call(this,n,r)};return t}()})}(),Object.defineProperty(r.recordClass.prototype,s,{enumerable:!0,get:function(){return this._get(s)},set:function(e){var r=this;if(j.isUndefined(e))j.set(r,o,void 0);else{De(r,s,e);var i=n.get(t,e);i&&j.set(r,o,i)}}})):c===T?!function(){var i=e.localKeys,o=e.foreignKeys;n._collections[t]&&s&&!n.getCollection(t).indexes[s]&&n.getCollection(t).createIndex(s),f={get:function(){var e=this,t=d.call(e);return t||e._set(a,[]),d.call(e)},set:function(c){var f=this;c||(c=[]),c&&!j.isArray(c)&&(c=[c]);var d=j.get(f,u),p=e.getRelation().idAttribute,h=e.getInverse(r),v=h.localField,g=f._get(a);g||(g=[]);var y=g;g=[];var m={};return c.forEach(function(e){var r=j.get(e,p);j.isUndefined(r)||(e=n.get(t,r)||e,m[r]=e),g.push(e)}),s?(c.forEach(function(e){De(e,s,d),n.getCollection(t).updateIndex(e,l),j.set(e,v,f)}),y.forEach(function(e){var r=j.get(e,p);j.isUndefined(r)||m.hasOwnProperty(r)||(De(e,s,void 0),n.getCollection(t).updateIndex(e,l),j.set(e,v,void 0))})):i?!function(){var e=[];c.forEach(function(t){j.set(t,v,f),e.push(j.get(t,p))}),j.set(f,i,e),y.forEach(function(e){var t=j.get(e,p);j.isUndefined(t)||m.hasOwnProperty(t)||j.set(e,v,void 0)})}():o&&(y.forEach(function(e){var t=j.get(e,o)||[];j.remove(t,function(e){return d===e});var n=j.get(e,v)||[];j.remove(n,function(e){return d===j.get(e,u)})}),c.forEach(function(e){var t=j.get(e,o)||[];j.noDupeAdd(t,d,function(e){return d===e});var n=j.get(e,v)||[];j.noDupeAdd(n,f,function(e){return d===j.get(e,u)})})),f._set(a,g),g}}}():c===Q&&(n._collections[t]&&s&&!n.getCollection(t).indexes[s]&&n.getCollection(t).createIndex(s),f={get:d,set:function(i){var o=this,c=this._get(a);if(i===c)return c;var f=j.get(i,e.getRelation().idAttribute),d=e.getInverse(r).localField;return c&&(De(c,s,void 0),n.getCollection(t).updateIndex(c,l),j.set(c,d,void 0)),i?(j.isUndefined(f)||(i=n.get(t,f)||i),o._set(a,i),De(i,s,j.get(o,u)),n.getCollection(t).updateIndex(i,l),j.set(i,d,o)):o._set(a,void 0),i}}),f&&(f.enumerable=j.isUndefined(e.enumerable)?!0:e.enumerable,e.get&&!function(){var t=f.get;f.get=function(){var n=this;return e.get(e,this,function(){for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];return t.apply(n,r)})}}(),e.set&&!function(){var t=f.set;f.set=function(n){var r=this;return e.set(e,this,n,function(e){return t.call(r,void 0===e?n:e)})}}(),Object.defineProperty(r.recordClass.prototype,o,f))}),r},destroy:function(e,t,n){var r=this;return n||(n={}),r._callSuper("destroy",e,t,n).then(function(i){return n.raw?i.data=r.getCollection(e).remove(t,n):i=r.getCollection(e).remove(t,n),delete r._pendingQueries[e][t],delete r._completedQueries[e][t],i})},destroyAll:function(e,t,n){var r=this;return n||(n={}),r._callSuper("destroyAll",e,t,n).then(function(i){n.raw?i.data=r.getCollection(e).removeAll(t,n):i=r.getCollection(e).removeAll(t,n);var o=r.hashQuery(e,t,n);return delete r._pendingQueries[e][o],delete r._completedQueries[e][o],i})},eject:function(e,t){return this.remove(e,t)},ejectAll:function(e,t){return this.removeAll(e,t)},find:function(e,t,n){var r=this;n||(n={});var i=r._pendingQueries[e][t];if(j.fillIn(n,r.getMapper(e)),i)return i;var o=r.cachedFind(e,t,n),a=void 0;return a=n.force||!o?r._pendingQueries[e][t]=r._callSuper("find",e,t,n).then(function(i){delete r._pendingQueries[e][t];var o=r._end(e,i,n);return r.cacheFind(e,o,t,n),o},function(n){return delete r._pendingQueries[e][t],j.reject(n)}):j.resolve(o)},findAll:function(e,t,n){var r=this;n||(n={});var i=r.hashQuery(e,t,n),o=r._pendingQueries[e][i];if(j.fillIn(n,r.getMapper(e)),o)return o;var a=r.cachedFindAll(e,i,n),u=void 0;return u=n.force||!a?r._pendingQueries[e][i]=r._callSuper("findAll",e,t,n).then(function(t){delete r._pendingQueries[e][i];var o=r._end(e,t,n);return r.cacheFindAll(e,o,i,n),o},function(t){return delete r._pendingQueries[e][i],j.reject(t)}):j.resolve(a)},getCollection:function(e){var t=this._collections[e];if(!t)throw j.err(Ue+"#getCollection",e)(404,"collection");return t},hashQuery:function(e,t,n){return j.toJson(t)},inject:function(e,t){return this.add(e,t)},remove:function(e,t,n){var r=this,i=r.getCollection(e).remove(t,n);return i&&r.removeRelated(e,[i],n),i},removeAll:function(e,t,n){var r=this,i=r.getCollection(e).removeAll(t,n);return i.length&&r.removeRelated(e,i,n),i},removeRelated:function(e,t,n){var r=this;j.forEachRelation(r.getMapper(e),n,function(e,n){t.forEach(function(t){var i=void 0,o=void 0;if(!e.foreignKey||e.type!==Q&&e.type!==T?e.type===T&&e.localKeys?o={where:s.defineProperty({},e.getRelation().idAttribute,{in:j.get(t,e.localKeys)})}:e.type===T&&e.foreignKeys?o={where:s.defineProperty({},e.foreignKeys,{contains:e.getForeignKey(t)})}:e.type===D&&(i=r.remove(e.relation,e.getForeignKey(t),n)):o=s.defineProperty({},e.foreignKey,e.getForeignKey(t)),o&&(i=r.removeAll(e.relation,o,n)),i){if(j.isArray(i)&&!i.length)return;e.type===Q&&(i=i[0]),e.setLocalField(t,i)}})})},update:function(e,t,n,r){var i=this;return r||(r={}),i._callSuper("update",e,t,n,r).then(function(t){return i._end(e,t,r)})},updateAll:function(e,t,n,r){var i=this;return r||(r={}),i._callSuper("updateAll",e,n,t,r).then(function(t){return i._end(e,t,r)})},updateMany:function(e,t,n){var r=this;return n||(n={}),r._callSuper("updateMany",e,t,n).then(function(t){return r._end(e,t,n)})}},qe=["add","between","createIndex","filter","get","getAll","query","toJson"];qe.forEach(function(e){Qe[e]=function(t){for(var n,r=arguments.length,i=Array(r>1?r-1:0),o=1;r>o;o++)i[o-1]=arguments[o];return(n=this.getCollection(t))[e].apply(n,i)}});var Je=Me.extend(Qe),Be={beta:1,full:"3.0.0-beta.1",major:3,minor:0,patch:0};e.version=Be,e.Collection=N,e.Component=t,e.Container=Me,e.DataStore=Je,e.Index=a,e.LinkedCollection=Le,e.Mapper=Ee,e.Query=K,e.Record=W,e.Schema=Oe,e.utils=j,e.belongsToType=D,e.hasManyType=T,e.hasOneType=Q,e.belongsTo=B,e.hasMany=$,e.hasOne=V}); //# sourceMappingURL=js-data.min.map \ No newline at end of file diff --git a/dist/js-data.min.map b/dist/js-data.min.map index 4f343a62..3d761b69 100644 --- a/dist/js-data.min.map +++ b/dist/js-data.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data.js"],"names":["global","factory","exports","module","define","amd","JSData","this","Component","Object","defineProperty","value","sort","a","b","hashCode","insertAt","array","index","splice","removeAt","binarySearch","field","lo","hi","length","compared","mid","found","Index","fieldList","opts","utils$1","classCallCheck","isArray","Error","fieldGetter","isIndex","keys","values","Relation","related","self","localField","foreignKey","localKey","type","belongsToType","hasOneType","localKeys","foreignKeys","hasManyType","isString","relation","isFunction","getRelation","name","undefined","writable","fillIn","babelHelpers","typeof","Symbol","iterator","obj","constructor","key","enumerable","configurable","toConsumableArray","arr","Array","i","arr2","from","INFINITY","MAX_INTEGER","BOOL_TAG","DATE_TAG","FUNC_TAG","NUMBER_TAG","OBJECT_TAG","REGEXP_TAG","STRING_TAG","objToString","prototype","toString","PATH","toInteger","sign","remainder","toStr","call","isPlainObject","mkdirP","object","path","parts","split","forEach","utils","Promise","_","dest","src","forOwn","isUndefined","indexOf","_forRelation","def","fn","ctx","relationName","containedName","with","_getIndex","withAll","optsCopy","slice","_activeWith","substr","list","_relation","isObject","addHiddenPropsToTarget","target","props","map","defineProperties","areDifferent","diff","diffObjects","diffCount","added","removed","changed","instance","ctor","TypeError","copy","to","stackFrom","stackTo","blacklist","plain","push","result","hasOwnProperty","isBlacklisted","isDate","Date","getTime","isRegExp","RegExp","source","match","lastIndex","create","getPrototypeOf","deepFillIn","existing","deepMixIn","equalsFn","bl","ignore","strictEqual","oldValue","newValue","equal","eventify","getter","setter","_events","emit","events","_len","arguments","args","_key","shift","listeners","f","apply","c","all","unshift","off","func","on","extend","classProps","superClass","_subClass","_len2","_key2","_this","possibleConstructorReturn","__super__","setPrototypeOf","strictEs6Class","__proto__","findIndex","record","forEachRelation","mapper","relationList","thisArg","len","fromJson","json","JSON","parse","get","prop","last","pop","getSuper","isCtor","intersection","array1","array2","item","matches","test","isBoolean","isBrowser","isInteger","isNull","isNumber","isSorN","logify","dbg","_len3","_key3","log","concat","level","_len4","_key4","debug","prefix","toUpperCase","console","_console","_console2","noDupeAdd","omit","_props","plainCopy","ReferenceError","reject","remove","resolve","set","_path","exec","_equal","toJson","stringify","unset","window","e","_listeners","reserved","limit","offset","orderBy","skip","where","escapeRegExp","percentRegExp","underscoreRegExp","escape","pattern","replace","Query","collection","data","between","leftKeys","rightKeys","getIndex","compare","cA","cB","temp","evaluate","op","predicate","ops","like","filter","query","getData","==","fields","predicates","clause","expr","first","keep","isOr","charAt","forEachFn","keyList","getAll","flags","num","Math","min","mapFn","mapCall","funcName","run","===","!=","!==",">",">=","<","<=","isectEmpty","isectNotEmpty","in","notIn","contains","notContains","pos","dataLocation","newIndex","results","visitAll","cb","leftInclusive","rightInclusive","_between","leftKey","rightKey","_i","currKey","peek","clear","insertRecord","removeRecord","updateRecord","COLLECTION_DEFAULTS","idAttribute","onConflict","Collection","records","recordId","indexes","createRecord","_onRecordEvent","add","beforeAdd","singular","id","updateIndexes","afterAdd","afterRemove","afterRemoveAll","beforeRemove","beforeRemoveAll","createIndex","instances","_query","reduce","initialValue","removeAll","toJSON","updateIndex","relatedMapper","getLocalKeys","getForeignKey","setForeignKey","relatedRecord","relatedRecordItem","getLocalField","setLocalField","getInverse","inverse","relatedTo","relationFields","_belongsTo","_hasMany","_hasOne","superMethod","store","datastore","bind","Record","_get","_set","_value","_unset","noValidate","_mapper","afterLoadRelations","beforeLoadRelations","changes","commit","destroy","hasChanges","quickHasChanges","isValid","validate","loadRelations","relations","adapter","getAdapterName","then","tasks","task","raw","load","relatedData","previous","revert","preserve","save","changesOnly","silent","_ret","v","types","boolean","integer","null","number","string","segmentToString","segment","prev","str","makePath","segments","makeError","actual","expected","addError","errors","maxLengthCommon","keyword","schema","max","minLengthCommon","validationKeywords","allOf","allErrors","_schema","_validate","anyOf","validated","dependencies","enum","possibleValues","join","items","checkingTuple","maximum","exclusiveMaximum","maxItems","maxLength","maxProperties","minimum","exclusiveMinimum","minItems","minLength","minProperties","multipleOf","not","oneOf","properties","additionalProperties","toValidate","patternProperties","undef","required","existingOnly","prevProp","validType","_type","validator","typeGroupValidators","uniqueItems","j","validateKeyword","runOps","ANY_OPS","ARRAY_OPS","NUMERIC_OPS","OBJECT_OPS","STRING_OPS","validateAny","shouldPop","changingPath","changedPath","creatingPath","eventIdPath","noValidatePath","silentPath","validationFailureMsg","makeDescriptor","descriptor","keyPath","previousPath","unsetter","error","track","current","changing","clearTimeout","setTimeout","numeric","Schema","definition","_definition","makeNotify","notify","notify2","LIFECYCLE_METHODS","count","defaults","destroyAll","find","findAll","sum","update","adapterArgs","beforeAssign","updateAll","updateMany","MAPPER_DEFAULTS","_adapters","applySchema","defaultAdapter","Mapper","recordClass","lifecycleMethods","subClass","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeCount","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_end","_data","wrap","belongsTo","crud","belongsToRelationData","relationData","relatedIdAttribute","createMany","getAdapter","pass","createdRecord","_result","createInstance","_records","relatedRecords","createdRecords","belongsToData","is","method","config","upper","before","after","_self$getAdapter","getAdapters","getSchema","hasMany","hasOne","registerAdapter","default","strict","_record","toProxy","Container","mapperDefaults","mapperClass","_mappers","_onMapperEvent","defineMapper","group","_name","getMapper","defineResource","_getMapper","LinkedCollection","_added","event","timestamp","usesRecordClass","relationIdAttribute","relatedCollection","getCollection","isHasMany","shouldAdd","toInsertItem","inserted","relatedDataId","relatedId","_records2","_records3","_records4","DATASTORE_DEFAULTS","safeSet","cachedFn","hashOrId","cached","_completedQueries","props$1","DataStore","collectionClass","_collections","_pendingQueries","_callSuper","addToCache","_onCollectionEvent","cachedFind","cachedFindAll","cacheFind","cacheFindAll","hash","indexed","updateOpts","_self","inverseDef","children","_children","storeRecord","inverseLocalField","linked","toLink","_localKeys","_localField","origGet","_key5","origSet","_this2","hashQuery","eject","ejectAll","pendingQuery","promise","force","err","inject","removeRelated","toProxy$1","_getCollection","_len5","_key6","version","alpha","beta","full","major","parseInt","minor","patch"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,SACrD,kBAAXE,SAAyBA,OAAOC,IAAMD,OAAO,WAAY,WAAYH,GAC3EA,EAASD,EAAOM,OAASN,EAAOM,aACjCC,KAAM,SAAUL,GAAW,YAkkC3B,SAASM,KASPC,OAAOC,eAAeH,KAAM,cAAgBI,WA4oB9C,QAASC,GAAKC,EAAGC,EAAGC,GAIlB,MAAIF,KAAMC,EACD,GAELC,IACFF,EAAIE,EAASF,GACbC,EAAIC,EAASD,IAEL,OAAND,GAAoB,OAANC,EACT,EAGC,OAAND,EACK,GAGC,OAANC,EACK,EAGDA,EAAJD,EACK,GAGLA,EAAIC,EACC,EAGF,GAGT,QAASE,GAASC,EAAOC,EAAOP,GAE9B,MADAM,GAAME,OAAOD,EAAO,EAAGP,GAChBM,EAGT,QAASG,GAASH,EAAOC,GAEvB,MADAD,GAAME,OAAOD,EAAO,GACbD,EAGT,QAASI,GAAaJ,EAAON,EAAOW,GAMlC,IALA,GAAIC,GAAK,EACLC,EAAKP,EAAMQ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,EAAK+e,EAAQ,GAAKhf,UAAUgf,EAG9B,QAAQF,EAAiBvpB,KAAKgmB,cAAc/iB,IAAO8gB,GAAQhZ,MAAMwe,EAAgB7e,KA2CrF,IAAIuc,IAAYnC,GAAUxZ,OAAO0b,IAuC7B0C,IACFC,MAAO,KACPC,KAAM,QACNC,KAAM,iBACNC,MAAOC,SAAS,IAAK,IACrBC,MAAOD,SAAS,IAAK,IACrBE,MAAOF,SAAS,IAAK,IAGvBpqB,GAAQ+pB,QAAUA,GAClB/pB,EAAQ0V,WAAaA,EACrB1V,EAAQM,UAAYA,EACpBN,EAAQmlB,UAAYA,GACpBnlB,EAAQsnB,UAAYA,GACpBtnB,EAAQ8lB,iBAAmBA,GAC3B9lB,EAAQuhB,OAASA,GACjBvhB,EAAQiR,MAAQA,EAChBjR,EAAQqY,OAASA,EACjBrY,EAAQigB,OAASA,GACjBjgB,EAAQkG,MAAQpE,EAChB9B,EAAQ6C,cAAgBA,EACxB7C,EAAQiD,YAAcA,EACtBjD,EAAQ8C,WAAaA,EACrB9C,EAAQojB,UAAYtL,EACpB9X,EAAQ4kB,QAAU7M,EAClB/X,EAAQ6kB,OAAS7M","file":"dist/js-data.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data.js"],"names":["global","factory","exports","module","define","amd","JSData","this","Component","Object","defineProperty","value","sort","a","b","hashCode","insertAt","array","index","splice","removeAt","binarySearch","field","lo","hi","length","compared","mid","found","Index","fieldList","opts","utils$1","classCallCheck","isArray","Error","fieldGetter","isIndex","keys","values","Relation","related","self","DOMAIN_ERR","DOMAIN$4","localField","err","foreignKey","localKey","type","belongsToType","hasOneType","localKeys","foreignKeys","hasManyType","isString","relation","isFunction","getRelation","name","undefined","writable","fillIn","babelHelpers","typeof","Symbol","iterator","obj","constructor","key","enumerable","configurable","toConsumableArray","arr","Array","i","arr2","from","DOMAIN","INFINITY","MAX_INTEGER","BOOL_TAG","DATE_TAG","FUNC_TAG","NUMBER_TAG","OBJECT_TAG","REGEXP_TAG","STRING_TAG","objToString","prototype","toString","PATH","ERRORS","400","arguments","404","toInteger","sign","remainder","toStr","call","isPlainObject","mkdirP","object","path","parts","split","forEach","utils","Promise","_","dest","src","forOwn","isUndefined","indexOf","_forRelation","def","fn","ctx","relationName","containedName","with","_getIndex","withAll","optsCopy","slice","_activeWith","substr","list","_relation","isObject","addHiddenPropsToTarget","target","props","map","defineProperties","areDifferent","diff","diffObjects","diffCount","added","removed","changed","instance","ctor","copy","to","stackFrom","stackTo","blacklist","plain","push","result","hasOwnProperty","isBlacklisted","isDate","Date","getTime","isRegExp","RegExp","source","match","lastIndex","create","getPrototypeOf","deepFillIn","existing","deepMixIn","equalsFn","bl","ignore","strictEqual","oldValue","newValue","equal","domain","code","prefix","message","apply","eventify","getter","setter","_events","emit","events","_len","args","_key","shift","listeners","f","c","all","unshift","off","func","on","extend","classProps","superClass","_subClass","_len2","_key2","setPrototypeOf","strictEs6Class","__proto__","findIndex","record","forEachRelation","mapper","relationList","thisArg","len","fromJson","json","JSON","parse","get","prop","last","pop","getSuper","isCtor","__super__","intersection","array1","array2","item","matches","test","isBoolean","isBrowser","isInteger","isNull","isNumber","isSorN","logify","dbg","_len3","_key3","log","concat","level","_len4","_key4","debug","toUpperCase","console","_console","_console2","noDupeAdd","omit","_props","plainCopy","reject","remove","resolve","set","_path","exec","_equal","toJson","stringify","unset","window","e","_listeners","DOMAIN$2","INDEX_ERR","reserved","limit","offset","orderBy","skip","where","escapeRegExp","percentRegExp","underscoreRegExp","escape","pattern","replace","Query","collection","data","between","leftKeys","rightKeys","getIndex","compare","cA","cB","temp","evaluate","op","predicate","ops","like","filter","query","getData","==","fields","predicates","clause","expr","first","keep","isOr","charAt","forEachFn","keyList","getAll","flags","num","Math","min","mapFn","mapCall","funcName","run","===","!=","!==",">",">=","<","<=","isectEmpty","isectNotEmpty","in","notIn","contains","notContains","pos","dataLocation","newIndex","results","visitAll","cb","leftInclusive","rightInclusive","_between","leftKey","rightKey","_i","currKey","peek","clear","insertRecord","removeRecord","_this","updateRecord","DOMAIN$1","COLLECTION_DEFAULTS","idAttribute","onConflict","Collection","records","recordId","indexes","add","_onRecordEvent","beforeAdd","singular","id","updateIndexes","createRecord","afterAdd","afterRemove","afterRemoveAll","beforeRemove","beforeRemoveAll","createIndex","instances","_query","reduce","initialValue","removeAll","toJSON","updateIndex","relatedMapper","getForeignKey","setForeignKey","relatedRecord","relatedRecordItem","getLocalField","setLocalField","getInverse","inverse","relatedTo","relationFields","_belongsTo","_hasMany","_hasOne","DOMAIN$6","superMethod","store","datastore","bind","Record","_get","_set","_value","_unset","noValidate","_mapper","afterLoadRelations","beforeLoadRelations","changes","commit","destroy","hasChanges","quickHasChanges","isValid","validate","loadRelations","relations","adapter","getAdapterName","then","tasks","task","raw","load","relatedData","previous","revert","preserve","save","changesOnly","silent","_ret","v","DOMAIN$7","types","boolean","integer","null","number","string","segmentToString","segment","prev","str","makePath","segments","makeError","actual","expected","addError","errors","maxLengthCommon","keyword","schema","max","minLengthCommon","validationKeywords","allOf","allErrors","_schema","_validate","anyOf","validated","dependencies","enum","possibleValues","join","items","checkingTuple","maximum","exclusiveMaximum","maxItems","maxLength","maxProperties","minimum","exclusiveMinimum","minItems","minLength","minProperties","multipleOf","not","oneOf","properties","additionalProperties","toValidate","patternProperties","undef","required","existingOnly","prevProp","validType","_type","validator","typeGroupValidators","uniqueItems","j","validateKeyword","runOps","ANY_OPS","ARRAY_OPS","NUMERIC_OPS","OBJECT_OPS","STRING_OPS","validateAny","shouldPop","changingPath","changedPath","creatingPath","eventIdPath","noValidatePath","silentPath","validationFailureMsg","makeDescriptor","descriptor","keyPath","previousPath","unsetter","error","track","current","changing","clearTimeout","setTimeout","numeric","Schema","definition","_definition","DOMAIN$5","makeNotify","notify","notify2","LIFECYCLE_METHODS","count","defaults","destroyAll","find","findAll","sum","update","adapterArgs","beforeAssign","updateAll","updateMany","MAPPER_DEFAULTS","_adapters","applySchema","defaultAdapter","Mapper","recordClass","lifecycleMethods","subClass","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeCount","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_end","_data","wrap","belongsTo","crud","belongsToRelationData","relationData","relatedIdAttribute","createMany","getAdapter","pass","createdRecord","_result","createInstance","_records","relatedRecords","createdRecords","belongsToData","is","method","config","upper","before","after","_self$getAdapter","getAdapters","getSchema","hasMany","hasOne","registerAdapter","default","strict","_record","hasErrors","DOMAIN$3","toProxy","Container","mapperDefaults","mapperClass","_mappers","_onMapperEvent","defineMapper","group","_name","getMapper","defineResource","_getMapper","DOMAIN$9","LinkedCollection","event","timestamp","usesRecordClass","relationIdAttribute","relatedCollection","getCollection","isHasMany","shouldAdd","toInsertItem","relatedDataId","relatedId","_records2","_records3","_records4","_added","DOMAIN$8","DATASTORE_DEFAULTS","safeSet","cachedFn","hashOrId","cached","_completedQueries","props$1","DataStore","collectionClass","_collections","_pendingQueries","_callSuper","addToCache","_onCollectionEvent","cachedFind","cachedFindAll","cacheFind","cacheFindAll","hash","indexed","updateOpts","_self","inverseDef","children","_children","storeRecord","inverseLocalField","linked","toLink","_localKeys","_localField","origGet","_key5","origSet","_this2","hashQuery","eject","ejectAll","pendingQuery","promise","force","inject","removeRelated","toProxy$1","_getCollection","_len5","_key6","version","beta","full","major","minor","patch"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,SACrD,kBAAXE,SAAyBA,OAAOC,IAAMD,OAAO,WAAY,WAAYH,GAC3EA,EAASD,EAAOM,OAASN,EAAOM,aACjCC,KAAM,SAAUL,GAAW,YAglC3B,SAASM,KASPC,OAAOC,eAAeH,KAAM,cAAgBI,WA+oB9C,QAASC,GAAKC,EAAGC,EAAGC,GAIlB,MAAIF,KAAMC,EACD,GAEL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OAAO+b,IAuC7ByC,IACJC,KAAM,EACNC,KAAM,eACNC,MAAO,EACPC,MAAO,EACPC,MAAO,EAGPlrB,GAAQ6qB,QAAUA,GAClB7qB,EAAQoW,WAAaA,EACrBpW,EAAQM,UAAYA,EACpBN,EAAQimB,UAAYA,GACpBjmB,EAAQqoB,UAAYA,GACpBroB,EAAQ2B,MAAQA,EAChB3B,EAAQ6mB,iBAAmBA,GAC3B7mB,EAAQmiB,OAASA,GACjBniB,EAAQyR,MAAQA,EAChBzR,EAAQ+Y,OAASA,EACjB/Y,EAAQ4gB,OAASA,GACjB5gB,EAAQ0G,MAAQ5E,EAChB9B,EAAQgD,cAAgBA,EACxBhD,EAAQoD,YAAcA,EACtBpD,EAAQiD,WAAaA,EACrBjD,EAAQgkB,UAAYzL,EACpBvY,EAAQwlB,QAAUhN,EAClBxY,EAAQylB,OAAShN","file":"dist/js-data.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 5b3cb401..c7bafff8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data", "description": "Robust, framework-agnostic in-memory data store.", - "version": "3.0.0-alpha.29", + "version": "3.0.0-beta.1", "homepage": "http://www.js-data.io", "repository": { "type": "git", @@ -61,7 +61,7 @@ "ci": "npm test && nyc report --reporter=lcov | codecov" }, "devDependencies": { - "babel-core": "6.7.5", + "babel-core": "6.7.6", "babel-plugin-syntax-async-functions": "6.5.0", "babel-plugin-transform-es2015-modules-umd": "6.6.5", "babel-plugin-transform-regenerator": "6.6.5", @@ -82,7 +82,7 @@ "karma-sauce-launcher": "0.3.1", "karma-sinon": "1.0.4", "mocha": "2.4.5", - "nyc": "6.2.1", + "nyc": "6.4.0", "phantomjs-prebuilt": "2.1.7", "rollup": "0.25.8", "rollup-plugin-babel": "2.4.0",