Comparing version 3.0.0-alpha.3 to 3.0.0-alpha.4
@@ -0,1 +1,6 @@ | ||
##### 3.0.0-alpha.4 - 04 January 2016 | ||
- Collections now fire "add" and "remove" events | ||
- Added before/after(Inject/Eject/EjectAll) lifecycle hooks | ||
##### 3.0.0-alpha.3 - 29 December 2015 | ||
@@ -2,0 +7,0 @@ |
@@ -1,2 +0,2 @@ | ||
{ | ||
{ | ||
"source": { | ||
@@ -15,5 +15,5 @@ "includePattern": ".*js$" | ||
"templates": { | ||
"theme": "cosmo", | ||
"theme": "lumen", | ||
"systemName": "js-data", | ||
"copyright": "js-data Copyright © 2014-2015 Jason Dobry" | ||
"copyright": "js-data Copyright © 2014-2016 Jason Dobry" | ||
}, | ||
@@ -20,0 +20,0 @@ "source": { |
# Contributing Guide | ||
First, support is handled via the [Slack Channel](http://slack.js-data.io) and the [Mailing List](https://groups.io/org/groupsio/jsdata). Ask your questions there. | ||
### Support | ||
When submitting issues on GitHub, please include as much detail as possible to make debugging quick and easy. | ||
Support questions are handled via [StackOverflow][so], [Slack][slack], and the | ||
[Mailing List][ml]. Ask your questions there. | ||
- good - Your versions of Angular, JSData, etc, relevant console logs/error, code examples that revealed the issue | ||
- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or [bin](http://jsbin.com/?html,output) that demonstrates the issue | ||
- best - A Pull Request that fixes the issue, including test coverage for the issue and the fix | ||
### Community | ||
- [StackOverflow Channel][so] | ||
- [Slack Chat][slack] [![Slack Status][sl_b]][slack] | ||
- [Announcements](http://www.js-data.io/blog) | ||
- [Mailing List](ml) | ||
- [Issues Tracker](https://github.com/js-data/js-data/issues) | ||
- [GitHub](https://github.com/js-data/js-data) | ||
- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md) | ||
[Github Issues](https://github.com/js-data/js-data/issues). | ||
### Contributing | ||
#### Submitting Pull Requests | ||
When submitting bug reports or feature requests on GitHub, please include _as | ||
much detail as possible_. | ||
1. Contribute to the issue/discussion that is the reason you'll be developing in the first place | ||
- good - Your versions of Angular, JSData, etc, relevant console logs, stack | ||
traces, code examples that revealed the issue, etc. | ||
- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or | ||
[bin](http://jsbin.com/?html,output) that demonstrates the issue | ||
- best - A Pull Request that fixes the issue, including test coverage for the | ||
issue and the fix | ||
#### Pull Requests | ||
1. Contribute to the issue/discussion that is the reason you'll be developing in | ||
the first place | ||
1. Fork js-data | ||
1. `git clone git@github.com:<you>/js-data.git` | ||
1. `cd js-data; npm install; bower install;` | ||
1. `cd js-data; npm install;` | ||
1. Write your code, including relevant documentation and tests | ||
1. Run `npm test` (build and test) | ||
1. Your code will be linted and checked for formatting, the tests will be run | ||
1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They will be committed when a release is cut. | ||
1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They | ||
will be committed when a release is cut. | ||
1. Submit your PR and we'll review! | ||
1. Thanks! | ||
#### Have write access? | ||
### Have write access? | ||
@@ -40,3 +58,6 @@ To cut a release: | ||
- attach the files in the `dist/` folder | ||
1. `git fetch origin` | ||
1. `npm publish .` | ||
1. `npm publish .` | ||
[slack]: http://slack.js-data.io | ||
[ml]: https://groups.io/org/groupsio/jsdata | ||
[so]: http://stackoverflow.com/questions/tagged/jsdata |
/*! | ||
* js-data | ||
* @version 3.0.0-alpha.3 - Homepage <http://www.js-data.io/> | ||
* @version 3.0.0-alpha.4 - Homepage <http://www.js-data.io/> | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
@@ -10,4 +10,4 @@ * @copyright (c) 2014-2015 Jason Dobry | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSData={})}(this,function(t){"use strict";function e(t){return"[object Object]"===toString.call(t)||!1}function n(t){return!!t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&t.constructor===Object}function i(t){return"[object RegExp]"===toString.call(t)||!1}function r(t){return"string"==typeof t||t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&"[object String]"===toString.call(t)||!1}function o(t){return t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&"[object Date]"===toString.call(t)||!1}function a(t){var e="undefined"==typeof t?"undefined":it.typeof(t);return"number"===e||t&&"object"===e&&"[object Number]"===toString.call(t)||!1}function s(t){return"[object Boolean]"===toString.call(t)}function u(t){return"function"==typeof t||t&&"[object Function]"===toString.call(t)||!1}function c(t){return r(t)||a(t)}function l(t,e){if(e){for(var n=e.split("."),i=n.pop();e=n.shift();)if(t=t[e],null==t)return;return t[i]}}function f(t,e){for(var n=e.split("."),i=n.pop();e=n.shift();)if(t=t[e],null==t)return;t[i]=void 0,delete t[i]}function h(t,e){if(!e)return t;var n=e.split(".");return n.forEach(function(e){t[e]||(t[e]={}),t=t[e]}),t}function d(t,n,i){if(e(n))p(n,function(e,n){d(t,n,e)});else{var r=ot.exec(n);r?h(t,r[1])[r[2]]=i:t[n]=i}}function p(t,e,n){var i=Object.keys(t),r=i.length,o=void 0;for(o=0;r>o;o++)e.call(n,t[i[o]],i[o],t)}function g(t,e){return e&&p(e,function(t,e){var i=this[e];n(t)&&n(i)?g(i,t):this[e]=t},t),t}function v(t){return Promise.resolve(t)}function y(t){return Promise.reject(t)}function m(t,e){for(var n in t){var i=t[n];void 0!==e[n]||u(i)||(e[n]=i)}}function b(t,e){if(!t||!e)return[];var n=[],i=void 0,r=void 0,o=t.length;for(r=0;o>r;r++)i=t[r],-1===n.indexOf(i)&&-1!==e.indexOf(i)&&n.push(i);return n}function _(t,e){p(e,function(e,n){void 0===t[n]&&(t[n]=e)})}function A(t,e){if(!e||!e.length)return!1;for(var n=void 0,i=0;i<e.length;i++)if("[object RegExp]"===Object.prototype.toString.call(e[i])&&e[i].test(t)||e[i]===t)return n=t;return!!n}function x(t){return r(t)?JSON.parse(t):t}function w(t,n,r,a,s){if(n){if(t===n)throw new Error("Cannot copy! Source and destination are identical.");if(r=r||[],a=a||[],e(t)){var u=r.indexOf(t);if(-1!==u)return a[u];r.push(t),a.push(n)}var c=void 0;if(rt(t)){var l=void 0;for(n.length=0,l=0;l<t.length;l++)c=w(t[l],null,r,a,s),e(t[l])&&(r.push(t[l]),a.push(c)),n.push(c)}else{rt(n)?n.length=0:p(n,function(t,e){delete n[e]});for(var f in t)if(t.hasOwnProperty(f)){if(A(f,s))continue;c=w(t[f],null,r,a,s),e(t[f])&&(r.push(t[f]),a.push(c)),n[f]=c}}}else n=t,t&&(rt(t)?n=w(t,[],r,a,s):o(t)?n=new Date(t.getTime()):i(t)?(n=new RegExp(t.source,t.toString().match(/[^\/]*$/)[0]),n.lastIndex=t.lastIndex):e(t)&&(n=w(t,Object.create(Object.getPrototypeOf(t)),r,a,s)));return n}function j(t,e,n){return""+e.toUpperCase()+n.toLowerCase()}function O(t){return t.replace(ut,"").replace(ct,j)}function k(t){return t.split(st).map(O).join("")}function E(t){return t=k(t),t?t.charAt(0).toLowerCase()+t.slice(1):t}function C(t,e,n){t=t||this;var i={};e||n||(e=function(){return i},n=function(t){i=t}),Object.defineProperties(t,{on:{value:function(t,i,r){e.call(this)||n.call(this,{});var o=e.call(this);o[t]=o[t]||[],o[t].push({f:i,c:r})}},off:{value:function(t,i){var r=e.call(this),o=r[t];if(o)if(i){for(var a=0;a<o.length;a++)if(o[a].f===i){o.splice(a,1);break}}else o.splice(0,o.length);else n.call(this,{})}},emit:{value:function(){for(var t=e.call(this)||{},n=arguments.length,i=Array(n),r=0;n>r;r++)i[r]=arguments[r];var o=i.shift(),a=t[o]||[],s=void 0;for(s=0;s<a.length;s++)a[s].f.apply(a[s].c,i);for(a=t.all||[],i.unshift(o),s=0;s<a.length;s++)a[s].f.apply(a[s].c,i)}}})}function R(t,e){for(e=t="";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e}function I(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function P(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==("undefined"==typeof e?"undefined":it.typeof(e))&&"function"!=typeof e?t:e}function F(t,e){p(e,function(t,n){e[n]={value:t}}),Object.defineProperties(t,e)}function M(t){I(this,M),this.collection=t,this.data=null}function S(t,e,n,i){var o=t[e],a=l(n,o[0]),s=l(i,o[0]);return a&&r(a)&&(a=a.toUpperCase()),s&&r(s)&&(s=s.toUpperCase()),"DESC"===o[1]?a>s?-1:s>a?1:e<t.length-1?S(t,e+1,n,i):0:s>a?-1:a>s?1:e<t.length-1?S(t,e+1,n,i):0}function L(t){return t.replace(ht,"\\$1")}function N(t,e){return new RegExp("^"+L(t).replace(dt,".*").replace(pt,".")+"$",e)}function D(t,e,n){switch(e){case"==":return t==n;case"===":return t===n;case"!=":return t!=n;case"!==":return t!==n;case">":return t>n;case">=":return t>=n;case"<":return n>t;case"<=":return n>=t;case"isectEmpty":return!b(t||[],n||[]).length;case"isectNotEmpty":return b(t||[],n||[]).length;case"in":return-1!==n.indexOf(t);case"notIn":return-1===n.indexOf(t);case"contains":return-1!==t.indexOf(n);case"notContains":return-1===t.indexOf(n);default:if(0===e.indexOf("like"))return null!==N(n,e.substr(4)).exec(t);if(0===e.indexOf("notLike"))return null===N(n,e.substr(7)).exec(t)}}function K(t,e,n){return t===e?0:(n&&(t=n(t),e=n(e)),null===t&&null===e?0:null===t?-1:null===e?1:e>t?-1:t>e?1:0)}function U(t,e,n){return t.splice(e,0,n),t}function T(t,e){return t.splice(e,1),t}function $(t,e,n){for(var i=0,r=t.length,o=void 0,a=void 0;r>i;){if(a=(i+r)/2|0,o=K(e,t[a],n),0===o)return{found:!0,index:a};0>o?r=a:i=a+1}return{found:!1,index:r}}function q(t,e){if(I(this,q),t||(t=[]),!rt(t))throw new Error("fieldList must be an array.");e||(e={}),this.fieldList=t,this.fieldGetter=e.fieldGetter,this.hashCode=e.hashCode,this.isIndex=!0,this.keys=[],this.values=[]}function J(){var t=this,e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(I(this,J),!rt(e))throw new TypeError("new Collection([data]): data: Expected array. Found "+("undefined"==typeof e?"undefined":it.typeof(e)));this.idAttribute=n,this.index=new q([n],{hashCode:function(t){return l(t,n)}}),this.indexes={},e.forEach(function(e){t.index.insertRecord(e),e&&u(e.on)&&e.on("all",t._onModelEvent,t)})}function z(t,e,n){n||(n={});var i=n.localField=n.localField||e.name.toLowerCase(),r=n.localKey=n.localKey||e.name.toLowerCase()+"_id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var t=l(this,r),n=void 0!==t?e.get(t):void 0;return this._set("links."+i,n),n},set:function(t){return this._set("links."+i,t),d(this,r,t[e.idAttribute]),l(this,i)}},a=o.get,s=o.set;return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete o.get,delete o.set,o.writable=!0),n.get&&(o.get=function(){var i=this;return n.get(t,e,this,a?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return a.apply(i,e)}:void 0)},delete o.writable),n.set&&(o.set=function(i){var r=this;return n.set(t,e,this,i,s?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return s.apply(r,e)}:void 0)},delete o.writable),o.get&&(o.set||(o.set=function(){})),Object.defineProperty(t.prototype,i,o),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="belongsTo",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t.collection.createIndex(r),t}function B(t,e){return function(n){return n.dbg(vt,"Model:",t,"opts:",e),z(n,t,e)}}function V(t){var e=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return t=t||{},function(n){return p(t,function(t,i){(void 0===n[i]||e)&&(n[i]=w(t))}),n}}function G(t,e,n){n||(n={});var i=n.localField||E(e.name)+"Collection",r=n.foreignKey,o=n.localKeys,a=n.foreignKeys;r||o||a||(r=n.foreignKey=E(t.name)+"Id"),r&&e.collection.createIndex(r);var s={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var n={},s=void 0;if(r)s=e.getAll(l(this,t.idAttribute),{index:r});else if(o){var u=l(this,o)||[],c=rt(u)?u:Object.keys(u);s=e.getAll.apply(e,c)}else a&&(d(n,"where."+a+".contains",l(this,t.idAttribute)),s=e.filter(n));return this._set("links."+i,s),s},set:function(n){var s=this;return this._set("links."+i,n),n&&n.length&&!function(){var i=l(s,t.idAttribute);r?n.forEach(function(t){d(t,r,i)}):o?!function(){var t=[];n.forEach(function(n){t.push(l(n,e.idAttribute))}),d(s,o,t)}():a&&n.forEach(function(t){var e=l(t,a);e?-1===e.indexOf(i)&&e.push(i):d(t,a,[i])})}(),l(this,i)}};return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete s.get,delete s.set,s.writable=!0),n.get&&!function(){var i=s.get;s.get=function(){var r=this;return n.get(t,e,this,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(r,e)}:void 0)}}(),n.set&&!function(){var i=s.set;s.set=function(r){var o=this;return n.set(t,e,this,r,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(o,e)}:void 0)}}(),Object.defineProperty(t.prototype,i,s),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="hasMany",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t}function H(t,e){return function(n){return n.dbg(yt,"Model:",t,"opts:",e),G(n,t,e)}}function Q(t,e,n){n||(n={});var i=n.localField=n.localField||E(e.name),r=n.foreignKey=n.foreignKey||E(t.name)+"Id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var n=e.getAll(l(this,t.idAttribute),{index:r}),o=n&&n.length?n[0]:void 0;return this._set("links."+i,o),o},set:function(e){return this._set("links."+i,e),d(e,r,l(this,t.idAttribute)),l(this,i)}};return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete o.get,delete o.set),n.get&&!function(){var i=o.get;o.get=function(){var r=this;return n.get(t,e,this,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(r,e)}:void 0)}}(),n.set&&!function(){var i=o.set;o.set=function(r){var o=this;return n.set(t,e,this,r,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(o,e)}:void 0)}}(),Object.defineProperty(t.prototype,i,o),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="hasOne",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t.collection.createIndex(r),t}function Y(t,e){return function(n){return n.dbg(mt,"Model:",t,"opts:",e),Q(n,t,e)}}function Z(t,e){var n=[];return p(t,function(t,i){var r=_t[i];if(r){var o=r(t,e);o&&n.push(o)}}),n.length?n:void 0}function W(t,e,n){var i={enumerable:void 0!==n.enumerable?n.enumerable:!0};return i.get=function(){return this._get("props."+e)},i.set=function(i){var r=this,o=this._get,a=this._set,s=this._unset;if(!o("noValidate")){var u=Z(n,i);if(u)throw new Error(u.join(", "))}return n.track&&!o("creating")&&!function(){var t=o("changing"),n=o("previous."+e),u=o("props."+e),c=o("changed");t||(c=[]);var f=c.indexOf(e);u!==i&&-1===f&&c.push(e),n!==i?a("changes."+e,i):(s("changes."+e),f>=0&&c.splice(f,1)),c.length||(t=!1,s("changing"),s("changed"),o("eventId")&&(clearTimeout(o("eventId")),s("eventId"))),!t&&c.length&&(a("changed",c),a("changing",!0),a("eventId",setTimeout(function(){if(s("changed"),s("eventId"),s("changing"),!o("silent")){var t=void 0;for(t=0;t<c.length;t++)r.emit("change:"+c[t],r,l(r,c[t]));r.emit("change",r,o("changes"))}s("silent")},0)))}(),a("props."+e,i),o("$")&&n.indexed&&t.collection.updateRecord(this,{index:e}),i},n.indexed&&t.createIndex(e),n.get&&(i.get?!function(){var t=i.get;i.get=function(){return n.get.call(this,t)}}():i.get=n.get),n.set&&(i.set?!function(){var t=i.set;i.set=function(e){return n.set.call(this,e,t)}}():i.set=n.set),i}function X(t){return t||(t={}),function(e){return e.dbg(At,"opts:",t),e.schema||(e.schema={}),V(e.schema,t),p(t,function(t,n){var i=W(e,n,t);i.writable||Object.defineProperty(e.prototype,n,i)}),e}}function tt(t,e,n){return n||(n={}),n.op=xt,function(i){i.dbg(xt,"name:",t,"adapter:",e,"opts:",n),i.adapters[t]=e,(n===!0||n.default)&&(i.defaultAdapter=t)}}function et(t,e){I(this,et),t||(t={}),e||(e={});var n={};Object.defineProperties(this,{_get:{value:function(t){return l(n,t)}},_set:{value:function(t,e){return d(n,t,e)}},_unset:{value:function(t){return f(n,t)}}}),this._set("creating",!0),e.noValidate&&this._set("noValidate",!0),_(this,t),this._unset("creating"),this._set("changes",{}),this._unset("noValidate"),this._set("previous",w(t))}function nt(t){I(this,nt),t||(t={}),this.definitions={}}var it={};it.typeof=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},it.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var rt=Array.isArray,ot=/^(.+)\.(.+)$/,at=JSON.stringify,st=/\s+/,ut=/[^A-Za-z]/g,ct=/(\w)(\w*)/g,lt=Object.freeze({isArray:rt,isObject:e,isRegExp:i,isString:r,isDate:o,isNumber:a,isBoolean:s,isFunction:u,isSorN:c,get:l,unset:f,set:d,forOwn:p,deepMixIn:g,resolve:v,reject:y,_:m,intersection:b,fillIn:_,isBlacklisted:A,fromJson:x,toJson:at,copy:w,pascalCase:k,camelCase:E,eventify:C,uuid:R,classCallCheck:I,possibleConstructorReturn:P,addHiddenPropsToTarget:F}),ft={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},ht=/([.*+?^=!:${}()|[\]\/\\])/g,dt=/%/g,pt=/_/g;F(M.prototype,{getData:function(){return this.data||(this.data=this.collection.index.getAll()),this.data},between:function(t,e,n){n||(n={});var i=this.collection,r=n.index?i.indexes[n.index]:i.index;if(this.data)throw new Error("Cannot access index after first operation!");return this.data=r.between(t,e,n),this},get:function(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],e=arguments[1];if(e||(e={}),this.data)throw new Error("Cannot access index after first operation!");if(t&&!rt(t)&&(t=[t]),!t.length)return this.getData(),this;var n=this.collection,i=e.index?n.indexes[e.index]:n.index;return this.data=i.get(t),this},getAll:function(){var t=this,n={};if(this.data)throw new Error("Cannot access index after first operation!");for(var i=arguments.length,r=Array(i),o=0;i>o;o++)r[o]=arguments[o];if(!r.length||1===r.length&&e(r[0]))return this.getData(),this;r.length&&e(r[r.length-1])&&(n=r[r.length-1],r.pop());var a=this.collection,s=n.index?a.indexes[n.index]:a.index;return this.data=[],r.forEach(function(e){t.data=t.data.concat(s.get(e))}),this},filter:function(t,n){var i=this;return t||(t={}),this.getData(),e(t)?!function(){var n={};e(t.where)&&(n=t.where),p(t,function(t,e){e in ft||e in n||(n[e]={"==":t})});var o=[],s=[],u=[];p(n,function(t,n){e(t)||(t={"==":t}),p(t,function(t,e){o.push(n),s.push(e),u.push(t)})}),o.length&&!function(){var t=void 0,e=o.length;i.data=i.data.filter(function(n){var i=!0,r=!0;for(t=0;e>t;t++){var a=s[t],c="|"===a.charAt(0);a=c?a.substr(1):a;var f=D(l(n,o[t]),a,u[t]);void 0!==f&&(r=i?f:c?r||f:r&&f),i=!1}return r})}();var c=t.orderBy||t.sort;r(c)&&(c=[[c,"ASC"]]),rt(c)||(c=null),c&&!function(){var t=0;c.forEach(function(t,e){r(t)&&(c[e]=[t,"ASC"])}),i.data.sort(function(e,n){return S(c,t,e,n)})}(),a(t.skip)?i.skip(t.skip):a(t.offset)&&i.skip(t.offset),a(t.limit)&&i.limit(t.limit)}():u(t)&&(this.data=this.data.filter(t,n)),this},skip:function(t){if(!a(t))throw new TypeError("skip: Expected number but found "+("undefined"==typeof t?"undefined":it.typeof(t))+"!");var e=this.getData();return t<e.length?this.data=e.slice(t):this.data=[],this},limit:function(t){if(!a(t))throw new TypeError("limit: Expected number but found "+("undefined"==typeof t?"undefined":it.typeof(t))+"!");var e=this.getData();return this.data=e.slice(0,Math.min(e.length,t)),this},forEach:function(t,e){return this.getData().forEach(t,e),this},map:function(t,e){return this.data=this.getData().map(t,e),this},run:function(){var t=this.data;return this.data=null,t}});var gt={">":1,">=":1,"<":1,"<=":1};F(q.prototype,{set:function(t,e){rt(t)||(t=[t]);var n=t.shift()||null,i=$(this.keys,n);if(0===t.length)if(i.found){var r=$(this.values[i.index],e,this.hashCode);r.found||U(this.values[i.index],r.index,e)}else U(this.keys,i.index,n),U(this.values,i.index,[e]);else if(i.found)this.values[i.index].set(t,e);else{U(this.keys,i.index,n);var o=new q([],{hashCode:this.hashCode});o.set(t,e),U(this.values,i.index,o)}},get:function(t){rt(t)||(t=[t]);var e=t.shift()||null,n=$(this.keys,e);return 0===t.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(t):[]},getAll:function(){var t=[];return this.values.forEach(function(e){t=e.isIndex?t.concat(e.getAll()):t.concat(e)}),t},visitAll:function(t,e){this.values.forEach(function(n){n.isIndex?n.visitAll(t,e):n.forEach(t,e)})},query:function(t){var e=void 0,n=void 0;if(t[">"]?(e=t[">"],t.leftInclusive=!1):t[">="]&&(e=t[">="],t.leftInclusive=!0),t["<"]?(n=t["<"],t.rightInclusive=!1):t["<="]&&(n=t["<="],t.rightInclusive=!0),e.length!==n.length)throw new Error("Key arrays must be same length");var i={};return p(t,function(t,e){gt[e]||(i[e]=t)}),this.between(e,n,i)},between:function(t,e){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];rt(t)||(t=[t]),rt(e)||(e=[e]),_(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var i=this._between(t,e,n);return n.limit?i.slice(n.offset,n.limit+n.offset):i.slice(n.offset)},_between:function(t,e,n){var i=[],r=t.shift(),o=e.shift(),a=void 0;if(a=void 0!==r?$(this.keys,r):{found:!1,index:0},0===t.length){a.found&&n.leftInclusive===!1&&(a.index+=1);for(var s=a.index;s<this.keys.length;s+=1){if(void 0!==o)if(n.rightInclusive){if(this.keys[s]>o)break}else if(this.keys[s]>=o)break;if(i=this.values[s].isIndex?i.concat(this.values[s].getAll()):i.concat(this.values[s]),n.limit&&i.length>=n.limit+n.offset)break}}else for(var s=a.index;s<this.keys.length;s+=1){var u=this.keys[s];if(u>o)break;if(i=this.values[s].isIndex?u===r?i.concat(this.values[s]._between(w(t),e.map(function(){}),n)):u===o?i.concat(this.values[s]._between(t.map(function(){}),w(e),n)):i.concat(this.values[s].getAll()):i.concat(this.values[s]),n.limit&&i.length>=n.limit+n.offset)break}return n.limit?i.slice(0,n.limit+n.offset):i},peek:function(){return this.values.length?this.values[0].isIndex?this.values[0].peek():this.values[0]:[]},remove:function(t,e){rt(t)||(t=[t]);var n=t.shift(),i=$(this.keys,n);if(0===t.length){if(i.found){var r=$(this.values[i.index],e,this.hashCode);r.found&&(T(this.values[i.index],r.index),0===this.values[i.index].length&&(T(this.keys,i.index),T(this.values,i.index)))}}else i.found&&this.values[i.index].delete(t,e)},clear:function(){this.keys=[],this.values=[]},insertRecord:function(t){var e=this.fieldList.map(function(e){return u(e)?e(t)||null:t[e]||null});this.set(e,t)},removeRecord:function(t){var e=this,n=void 0;return this.values.forEach(function(i,r){if(i.isIndex){if(i.removeRecord(t))return 0===i.keys.length&&(T(e.keys,r),T(e.values,r)),n=!0,!1}else{var o=$(i,t,e.hashCode);if(o.found)return T(i,o.index),0===i.length&&(T(e.keys,r),T(e.values,r)),n=!0,!1}}),n?t:void 0},updateRecord:function(t){this.removeRecord(t),this.insertRecord(t)}}),F(J.prototype,{_onModelEvent:function(){this.emit.apply(this,arguments)},createIndex:function(t,e,n){r(t)&&void 0===e&&(e=[t]),n||(n={});var i=this.idAttribute;n.hashCode=function(t){return l(t,i)};var o=this.indexes[t]=new q(e,n);return this.index.visitAll(o.insertRecord,o),this},query:function(){return new M(this)},between:function(t,e,n){return this.query().between(t,e,n).run()},get:function(t,e){return this.query().get(t,e).run()},getAll:function(){var t;return(t=this.query()).getAll.apply(t,arguments).run()},filter:function(t,e){return this.query().filter(t,e).run()},skip:function(t){return this.query().skip(t).run()},limit:function(t){return this.query().limit(t).run()},forEach:function(t,e){this.index.visitAll(t,e)},reduce:function(t,e){var n=this.getAll();return n.reduce(t,e)},map:function(t,e){var n=[];return this.index.visitAll(function(i){n.push(t.call(e,i))}),n},insert:function(t){this.index.insertRecord(t),p(this.indexes,function(e,n){e.insertRecord(t)}),t&&u(t.on)&&t.on("all",this._onModelEvent,this)},update:function(t){this.index.updateRecord(t),p(this.indexes,function(e,n){e.updateRecord(t)})},remove:function(t){this.index.removeRecord(t),p(this.indexes,function(e,n){e.removeRecord(t)}),t&&u(t.off)&&t.off("all",this._onModelEvent,this)},updateRecord:function(t,e){e||(e={});var n=e.index?this.indexes[e.index]:this.index;n.updateRecord(t)}}),C(J.prototype,function(){return this._events},function(t){this._events=t});var vt="belongsTo",yt="hasMany",mt="hasOne",bt={array:rt,boolean:s,integer:a,number:a,null:function(t){return null===t},object:e,string:r},_t={type:function(t,e){if(void 0!==e){r(t)&&(t=[t]);var n=t.map(function(n){var i=bt[n];return i?i(e)?void 0:1:"type: Unknown type "+t});return-1!==n.indexOf(void 0)?void 0:"type: Expected: "+t.join(" or ")+". Actual: "+("undefined"==typeof e?"undefined":it.typeof(e))}},anyOf:function(t,e){var n=!1,i=[];return t.forEach(function(t){var r=Z(t,e);r?i=i.concat(r):n=!0}),n?void 0:i},allOf:function(t,e){var n=[];return t.forEach(function(t){n=n.concat(Z(t,e)||[])}),n.length?void 0:n},oneOf:function(t,e){var n=!1,i=[];return t.forEach(function(t){var r=Z(t,e);if(r)i=i.concat(r);else{if(n)return i=["more than one schema validated"],n=!1,!1;n=!0}}),n?void 0:i}},At="setSchema",xt="registerAdapter",wt=v,jt={length:1,name:1,arguments:1,prototype:1,caller:1,__super__:1},Ot=!1;try{Ot=!!window}catch(t){}var kt=function(t,e,n,i){return n.raw?(e.adapter=i,n.autoInject&&(e.data=t.inject(e.data)),e):(n.autoInject&&(e=t.inject(e)),e)};F(et.prototype,{schema:function(t){var e=this.constructor.schema;return t?e[t]:e},validate:function(t,e){var n=[],i=this.schema();if(t)if(r(t)){var o=i[t];o&&(n=Z(o,e)||[])}else p(i,function(e,i){n=n.concat(Z(e,l(t,i))||[])});else t=this;return n.length?n:void 0},create:function(t){return this.constructor.create(this,t)},save:function(t){var e=this.constructor,n=e.getAdapterName(t);return e.getAdapter(n).update(e,l(this,e.idAttribute),this,t)},destroy:function(t){var e=this.constructor;return e.destroy(l(this,e.idAttribute),t)},get:function(t){return l(this,t)},set:function(t,n,i){e(t)&&(i=n),i||(i={}),i.silent&&this._set("silent",!0),d(this,t,n),this._get("eventId")||this._unset("silent")},unset:function(t,e){e||(e={}),e.silent&&this._set("silent",!0),f(this,t),this._get("eventId")||this._unset("silent")},hashCode:function(){return l(this,this.constructor.idAttribute)},changes:function(t){return t?this._get("changes."+t):this._get("changes")},changed:function(){return this._get("changed")},hasChanges:function(){return!!(this._get("changed")||[]).length},commit:function(){return this._unset("changed"),this._set("changes",{}),this._set("previous",w(this)),this},previous:function(t){return t?this._get("previous."+t):this._get("previous")},revert:function(t){var e=this,n=this._get("previous")||{};return t||(t={}),t.preserve||(t.preserve=[]),p(this,function(i,r){r!==e.constructor.idAttribute&&!n.hasOwnProperty(r)&&e.hasOwnProperty(r)&&-1===t.preserve.indexOf(r)&&delete e[r]}),p(n,function(n,i){-1===t.preserve.indexOf(i)&&(e[i]=n)}),this.commit(),this},toJSON:function(t){var e=this;t||(t={});var n=this.constructor,i=this;return this instanceof et&&(i={},d(i,this),n&&n.relationList&&t.with&&(r(t.with)&&(t.with=[t.with]),n.relationList.forEach(function(n){var r=void 0;-1!==t.with.indexOf(n.relation)?r=n.relation:-1!==t.with.indexOf(n.localField)&&(r=n.localField),r&&!function(){var o={with:t.with.slice()};o.with.splice(o.with.indexOf(r),1),o.with.forEach(function(t,e){t&&0===t.indexOf(r)&&t.length>=r.length&&"."===t[r.length]?o.with[e]=t.substr(r.length+1):o.with[e]=""});var a=l(e,n.localField);a&&(rt(a)?d(i,n.localField,a.map(function(t){return n.Relation.prototype.toJSON.call(t,o)})):d(i,n.localField,n.Relation.prototype.toJSON.call(a,o)))}()}))),i}}),_(et,{autoEject:!0,autoInject:Ot,bypassCache:!1,csp:!1,defaultAdapter:"http",debug:!1,eagerEject:!1,idAttribute:"id",linkRelations:Ot,onConflict:"merge",relationsEnumerable:!1,raw:!1,upsert:!0,createIndex:function(t,e){this.dbg("createIndex","name:",t,"keyList:",e),this.collection.createIndex(t,e)},createInstance:function(t){var e=this;return t instanceof e?t:new e(t)},is:function(t){return t instanceof this},getAutoPkItems:function(){return this.getAll().filter(function(t){return t._get("autoPk")})},changes:function(t,e){this.dbg("changes","id:",t);var n=this.get(t);return n?n.changes(e):void 0},changed:function(t){this.dbg("changed","id:",t);var e=this.get(t);return e?e.changed():void 0},hasChanges:function(t){this.dbg("hasChanges","id:",t);var e=this.get(t);return e?e.hasChanges():void 0},inject:function(t,e){var n=this,i="inject";n.dbg(i,"item(s):",t,"opts:",e),e||(e={}),e.op=i;var r=!1,o=n.collection,a=n.idAttribute,s=n.relationList||[];rt(t)||(t=[t],r=!0);var h=(new Date).getTime();return t=t.map(function(t){var i=l(t,a),r=!1;if(!c(i)){if(!(e.autoPk||void 0===e.autoPk&&n.autoPk))throw new TypeError("User#"+a+": Expected string or number, found "+("undefined"==typeof i?"undefined":it.typeof(i))+"!");i=R(),d(t,a,i),r=!0}var v=n.get(i);if(t===v)return v;if(s.forEach(function(e){var r=e.Relation,o=r.idAttribute,s=e.foreignKey,c=l(t,e.localField);if(u(e.inject))e.inject(n,e,t);else if(c&&e.inject!==!1)if(rt(c))c=c.map(function(t){if(t!==r.get(l(t,o)))try{s&&d(t,s,i),t=r.inject(t)}catch(t){throw new Error("Failed to inject "+e.type+' relation: "'+e.relation+'"! '+t.message)}return t}),e.localKeys&&d(t,e.localKeys,c.map(function(t){return l(t,o)}));else if(c!==r.get(l(c,o)))try{e.localKey&&d(t,e.localKey,l(c,r.idAttribute)),s&&d(c,e.foreignKey,l(t,a)),c=r.inject(c)}catch(t){throw new Error("Failed to inject "+e.type+' relation: "'+e.relation+'"!')}e.link||void 0===e.link&&n.linkRelations?f(t,e.localField):d(t,e.localField,c)}),v){var y=e.onConflict||n.onConflict;"merge"===y?g(v,t):"replace"===y&&(p(v,function(e,n){n===a||t.hasOwnProperty(n)||delete v[n]}),v.set(t)),t=v,o.update(t)}else t=n.createInstance(t),r&&t._set("autoPk",r),o.insert(t);return t._set("$",h),t}),r?t.length?t[0]:void 0:t},eject:function(t,e){var n="eject";this.dbg(n,"id:",t,"opts:",e),e||(e={}),e.op=n;var i=this.get(t);return i&&(i._unset("$"),this.collection.remove(i)),i},ejectAll:function(t,e){var n="ejectAll";this.dbg(n,"params:",t,"opts:",e),e||(e={}),e.op=n;var i=this.filter(t),r=this.collection;return i.forEach(function(t){r.remove(t)}),i},get:function(t){this.dbg("get","id:",t);var e=this.collection.get(t);return e.length?e[0]:void 0},between:function(){var t;return(t=this.collection).between.apply(t,arguments)},getAll:function(){var t;return(t=this.collection).getAll.apply(t,arguments)},filter:function(t,e){return e||(e={}),this.collection.filter(t,e)},query:function(){return this.collection.query()},getAdapter:function(t){this.dbg("getAdapter","name:",t);var e=this.getAdapterName(t);if(!e)throw new ReferenceError(e+" not found!");return this.adapters[e]},getAdapterName:function(t){return t||(t={}),r(t)&&(t={adapter:t}),t.adapter||t.defaultAdapter},beforeCreate:function(){},create:function(t,e){var n=this,i="create";this.dbg(i,"props:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,!e.upsert||!l(t,this.idAttribute)||this.is(t)&&t._get("autoPk")?wt(this.beforeCreate(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).create(n,n.prototype.toJSON.call(t,e),e)}).then(function(i){return wt(n.afterCreate(i,e)).then(function(){return n.is(t)&&t._get("$")&&n.eject(l(t,n.idAttribute)),kt(n,i,e,r)})}):this.update(l(t,this.idAttribute),t,e)},afterCreate:function(){},beforeCreateMany:function(){},createMany:function(t,e){var n=this,i="createMany";this.dbg(i,"items:",t,"opts:",e);var r=void 0;if(t||(t=[]),e||(e={}),m(this,e),e.op=i,e.upsert){var o=function(){var i=!0;return t.forEach(function(t){i=i&&l(t,n.idAttribute)&&(!u(t._get)||!t._get("autoPk"))}),i?{v:n.updateMany(t,e)}:void 0}();if("object"===("undefined"==typeof o?"undefined":it.typeof(o)))return o.v}return wt(this.beforeCreateMany(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).createMany(n,t.map(function(t){return n.prototype.toJSON.call(t,e)}),e)}).then(function(i){return wt(n.afterCreateMany(i,e)).then(function(){return t.forEach(function(t){n.is(t)&&t._get("$")&&n.eject(l(t,n.idAttribute))}),kt(n,i,e,r)})})},afterCreateMany:function(){},beforeFind:function(){},find:function(t,e){var n=this,i="find";this.dbg(i,"id:",t,"opts:",e);var r=void 0;return e||(e={}),m(this,e),e.op=i,wt(this.beforeFind(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).find(n,t,e)}).then(function(t){return wt(n.afterFind(t,e)).then(function(){return kt(n,t,e,r)})})},afterFind:function(){},beforeFindAll:function(){},findAll:function(t,e){var n=this,i="findAll";this.dbg(i,"query:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,wt(this.beforeFindAll(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).findAll(n,t,e)}).then(function(t){return wt(n.afterFindAll(t,e)).then(function(){return kt(n,t,e,r)})})},afterFindAll:function(){},beforeUpdate:function(){},update:function(t,e,n){var i=this,r="update";this.dbg(r,"id:",t,"props:",e,"opts:",n);var o=void 0;return e||(e={}),n||(n={}),m(this,n),n.op=r,wt(this.beforeUpdate(t,e,n)).then(function(){return o=i.getAdapterName(n),i.getAdapter(o).update(i,t,i.prototype.toJSON.call(e,n),n)}).then(function(e){return wt(i.afterUpdate(t,e,n)).then(function(){return kt(i,e,n,o)})})},afterUpdate:function(){},beforeUpdateMany:function(){},updateMany:function(t,e){var n=this,i="updateMany";this.dbg(i,"items:",t,"opts:",e);var r=void 0;return t||(t=[]),e||(e={}),m(this,e),e.op=i,wt(this.beforeUpdateMany(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).updateMany(n,t.map(function(t){return n.prototype.toJSON.call(t,e)}),e)}).then(function(t){return wt(n.afterUpdateMany(t,e)).then(function(){return kt(n,t,e,r)})})},afterUpdateMany:function(){},beforeUpdateAll:function(){},updateAll:function(t,e,n){var i=this,r="updateAll";this.dbg(r,"query:",t,"props:",e,"opts:",n);var o=void 0;return t||(t={}),e||(e={}),n||(n={}),m(this,n),n.op=r,wt(this.beforeUpdateAll(t,e,n)).then(function(){return o=i.getAdapterName(n),i.getAdapter(o).updateAll(i,t,e,n)}).then(function(e){return wt(i.afterUpdateAll(t,e,n)).then(function(){return kt(i,e,n,o)})})},afterUpdateAll:function(){},beforeDestroy:function(){},destroy:function(t,e){var n=this,i="destroy";this.dbg(i,"id:",t,"opts:",e);var r=void 0;return e||(e={}),m(this,e),e.op=i,wt(this.beforeDestroy(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).destroy(n,t,e)}).then(function(i){return wt(n.afterDestroy(t,e)).then(function(){return e.raw?(i.adapter=r,e.autoEject&&(i.data=n.eject(t,e)),i):(e.autoEject&&(i=n.eject(t,e)),i)})})},afterDestroy:function(){},beforeDestroyAll:function(){},destroyAll:function(t,e){var n=this,i="destroyAll";this.dbg(i,"query:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,wt(this.beforeDestroyAll(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).destroyAll(n,t,e)}).then(function(i){return wt(n.afterDestroyAll(t,e)).then(function(){return e.raw?(i.adapter=r,e.autoEject&&(i.data=n.ejectAll(t,e)),i):(e.autoEject&&(i=n.ejectAll(t,e)),i)})})},afterDestroyAll:function(){},beforeLoadRelations:function(){},loadRelations:function(t,e,n){var i=this,o=this,a=o.is(t)?t:void 0;t=a?l(a,o.idAttribute):t;var s="loadRelations";o.dbg(s,"id:",t,"relations:",e,"opts:",n),e||(e=[]),n||(n={});var f=o.relationList||[];return m(o,n),n.op=s,wt(o.beforeLoadRelations(t,e,n)).then(function(){ | ||
if(c(t)&&!a&&(a=o.get(a)),!a)throw new Error("You passed an id of an instance not found in the collection of the Model!");return r(e)&&(e=[e]),Promise.all(f.map(function(e){if(u(e.load))return e.load(o,e,a,n);var i=void 0;if(e.foreignKey)i=e.Relation.findAll(it.defineProperty({},e.foreignKey,t),n);else if(e.localKey){var r=l(a,e.localKey);c(r)&&(i=e.Relation.find(r,n))}else e.localKeys?i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{in:l(a,e.localKeys)}),n):e.foreignKeys&&(i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{contains:l(a,o.idAttribute)}),n));return i&&(i=i.then(function(t){n.raw&&(t=t.data),d(a,e.localField,"hasOne"===e.type?t.length?t[0]:void 0:t)})),i}))}).then(function(){return wt(i.afterLoadRelations(a,e,n)).then(function(){return a})})},afterLoadRelations:function(){},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var r=t.toUpperCase()+": ("+this.name+")";if(console[t]){var o;(o=console)[t].apply(o,[r].concat(n))}else{var a;(a=console).log.apply(a,[r].concat(n))}}},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},belongsTo:function(t,e){return B(t,e)(this)},hasMany:function(t,e){return H(t,e)(this)},hasOne:function(t,e){return Y(t,e)(this)},setSchema:function(t){return X(t)(this)},configure:function(t){return V(t)(this)},registerAdapter:function(t,e,n){return tt(t,e,n)(this)},extend:function(t,e){var n=this,i=void 0;n.dbg("extend","props:",t,"classProps:",e),t||(t={}),e||(e={});var r=t.initialize;if(delete t.initialize,t.hasOwnProperty("constructor"))i=t.constructor,delete t.constructor;else{if(!e.name)throw new TypeError("name: Expected string, found "+it.typeof(e.name)+"!");if(e.csp)i=function(){I(this,i);for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var o=P(this,(i.__super__||Object.getPrototypeOf(i)).apply(this,e));return r&&r.apply(o,e),o};else{var o=k(e.name),a="return function "+o+"() {\n classCallCheck(this, "+o+")\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var _this = possibleConstructorReturn(this, ("+o+".__super__ || Object.getPrototypeOf("+o+")).apply(this, args));\n if (initialize) {\n initialize.apply(_this, arguments)\n }\n return _this\n }";i=new Function("classCallCheck","possibleConstructorReturn","Parent","initialize",a)(I,P,n,r)}}e.shortname=e.shortname||E(i.name||e.name),delete e.name;var s=e.schema;if(delete e.schema,i.prototype=Object.create(n&&n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n&&e.strictEs6Class)Object.setPrototypeOf?Object.setPrototypeOf(i,n):i.__proto__=n;else{var u=Object.getOwnPropertyNames(n);u.forEach(function(t){jt[t]||Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(n,t))})}return Object.defineProperty(i,"__super__",{configurable:!0,value:n}),V(t)(i.prototype),V(e)(i),s&&X(s)(i),i}}),Object.defineProperties(et,{__events:{configurable:!0,value:{}},_events:{get:function(){return this.__events===(this.__super__?this.__super__:Object.getPrototypeOf(this)).__events&&Object.defineProperty(this,"__events",{value:{}}),this.__events}},_adapters:{configurable:!0,value:{}},adapters:{get:function(){var t=(this.__super__?this.__super__:Object.getPrototypeOf(this))._adapters;return this._adapters===t&&(Object.defineProperty(this,"_adapters",{value:{}}),_(this._adapters,t)),this._adapters}},_collection:{configurable:!0,value:new J([],"id")},collection:{get:function(){return this._collection===(this.__super__?this.__super__:Object.getPrototypeOf(this))._collection&&(Object.defineProperty(this,"_collection",{value:new J([],this.idAttribute)}),this._collection.on("all",this.emit,this),this._collection.createIndex("lastInjected",["$"],{fieldGetter:function(t){return t._get("$")}})),this._collection}}}),C(et,function(){return this._events},function(t){this._events=t}),C(et.prototype,function(){return this._get("events")},function(t){this._set("events",t)}),F(nt.prototype,{clear:function(){var t={};return p(this.definitions,function(e){var n=e.name;t[n]=e.ejectAll()}),t},defineModel:function(t){var e=et.extend(t.methods||{},t);return this.definitions[e.name]=e,e}}),nt.prototype.defineResource=nt.prototype.defineModel,p(et,function(t,e){u(t)&&(nt.prototype[e]=function(t){var n;if(!this.definitions[t])throw new Error(t+" is not a registered Model!");for(var i=arguments.length,r=Array(i>1?i-1:0),o=1;i>o;o++)r[o-1]=arguments[o];return(n=this.definitions[t])[e].apply(n,r)})}),Promise.prototype.spread||(Promise.prototype.spread=function(t){return this.then(function(e){return t.apply(this,e)})});var Et=lt,Ct={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"};t.utils=Et,t.version=Ct,t.Collection=J,t.Query=M,t.DS=nt,t.belongsTo=B,t.configure=V,t.hasMany=H,t.hasOne=Y,t.setSchema=X,t.registerAdapter=tt,t.Model=et,t.rules=_t,t.validate=Z}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSData={})}(this,function(t){"use strict";function e(t){return"[object Object]"===toString.call(t)||!1}function n(t){return!!t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&t.constructor===Object}function i(t){return"[object RegExp]"===toString.call(t)||!1}function r(t){return"string"==typeof t||t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&"[object String]"===toString.call(t)||!1}function o(t){return t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&"[object Date]"===toString.call(t)||!1}function a(t){var e="undefined"==typeof t?"undefined":it.typeof(t);return"number"===e||t&&"object"===e&&"[object Number]"===toString.call(t)||!1}function s(t){return"[object Boolean]"===toString.call(t)}function u(t){return"function"==typeof t||t&&"[object Function]"===toString.call(t)||!1}function c(t){return r(t)||a(t)}function l(t,e){if(e){for(var n=e.split("."),i=n.pop();e=n.shift();)if(t=t[e],null==t)return;return t[i]}}function f(t,e){for(var n=e.split("."),i=n.pop();e=n.shift();)if(t=t[e],null==t)return;t[i]=void 0,delete t[i]}function h(t,e){if(!e)return t;var n=e.split(".");return n.forEach(function(e){t[e]||(t[e]={}),t=t[e]}),t}function d(t,n,i){if(e(n))p(n,function(e,n){d(t,n,e)});else{var r=ot.exec(n);r?h(t,r[1])[r[2]]=i:t[n]=i}}function p(t,e,n){var i=Object.keys(t),r=i.length,o=void 0;for(o=0;r>o;o++)e.call(n,t[i[o]],i[o],t)}function v(t,e){return e&&p(e,function(t,e){var i=this[e];n(t)&&n(i)?v(i,t):this[e]=t},t),t}function g(t){return Promise.resolve(t)}function y(t){return Promise.reject(t)}function m(t,e){for(var n in t){var i=t[n];void 0!==e[n]||u(i)||(e[n]=i)}}function b(t,e){if(!t||!e)return[];var n=[],i=void 0,r=void 0,o=t.length;for(r=0;o>r;r++)i=t[r],-1===n.indexOf(i)&&-1!==e.indexOf(i)&&n.push(i);return n}function _(t,e){p(e,function(e,n){void 0===t[n]&&(t[n]=e)})}function A(t,e){if(!e||!e.length)return!1;for(var n=void 0,i=0;i<e.length;i++)if("[object RegExp]"===Object.prototype.toString.call(e[i])&&e[i].test(t)||e[i]===t)return n=t;return!!n}function x(t){return r(t)?JSON.parse(t):t}function w(t,n,r,a,s){if(n){if(t===n)throw new Error("Cannot copy! Source and destination are identical.");if(r=r||[],a=a||[],e(t)){var u=r.indexOf(t);if(-1!==u)return a[u];r.push(t),a.push(n)}var c=void 0;if(rt(t)){var l=void 0;for(n.length=0,l=0;l<t.length;l++)c=w(t[l],null,r,a,s),e(t[l])&&(r.push(t[l]),a.push(c)),n.push(c)}else{rt(n)?n.length=0:p(n,function(t,e){delete n[e]});for(var f in t)if(t.hasOwnProperty(f)){if(A(f,s))continue;c=w(t[f],null,r,a,s),e(t[f])&&(r.push(t[f]),a.push(c)),n[f]=c}}}else n=t,t&&(rt(t)?n=w(t,[],r,a,s):o(t)?n=new Date(t.getTime()):i(t)?(n=new RegExp(t.source,t.toString().match(/[^\/]*$/)[0]),n.lastIndex=t.lastIndex):e(t)&&(n=w(t,Object.create(Object.getPrototypeOf(t)),r,a,s)));return n}function j(t,e,n){return""+e.toUpperCase()+n.toLowerCase()}function O(t){return t.replace(ut,"").replace(ct,j)}function E(t){return t.split(st).map(O).join("")}function k(t){return t=E(t),t?t.charAt(0).toLowerCase()+t.slice(1):t}function C(t,e,n){t=t||this;var i={};e||n||(e=function(){return i},n=function(t){i=t}),Object.defineProperties(t,{on:{value:function(t,i,r){e.call(this)||n.call(this,{});var o=e.call(this);o[t]=o[t]||[],o[t].push({f:i,c:r})}},off:{value:function(t,i){var r=e.call(this),o=r[t];if(o)if(i){for(var a=0;a<o.length;a++)if(o[a].f===i){o.splice(a,1);break}}else o.splice(0,o.length);else n.call(this,{})}},emit:{value:function(){for(var t=e.call(this)||{},n=arguments.length,i=Array(n),r=0;n>r;r++)i[r]=arguments[r];var o=i.shift(),a=t[o]||[],s=void 0;for(s=0;s<a.length;s++)a[s].f.apply(a[s].c,i);for(a=t.all||[],i.unshift(o),s=0;s<a.length;s++)a[s].f.apply(a[s].c,i)}}})}function I(t,e){for(e=t="";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e}function R(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function P(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==("undefined"==typeof e?"undefined":it.typeof(e))&&"function"!=typeof e?t:e}function S(t,e){p(e,function(t,n){e[n]={value:t}}),Object.defineProperties(t,e)}function F(t){R(this,F),this.collection=t,this.data=null}function M(t,e,n,i){var o=t[e],a=l(n,o[0]),s=l(i,o[0]);return a&&r(a)&&(a=a.toUpperCase()),s&&r(s)&&(s=s.toUpperCase()),"DESC"===o[1]?a>s?-1:s>a?1:e<t.length-1?M(t,e+1,n,i):0:s>a?-1:a>s?1:e<t.length-1?M(t,e+1,n,i):0}function N(t){return t.replace(ht,"\\$1")}function L(t,e){return new RegExp("^"+N(t).replace(dt,".*").replace(pt,".")+"$",e)}function D(t,e,n){switch(e){case"==":return t==n;case"===":return t===n;case"!=":return t!=n;case"!==":return t!==n;case">":return t>n;case">=":return t>=n;case"<":return n>t;case"<=":return n>=t;case"isectEmpty":return!b(t||[],n||[]).length;case"isectNotEmpty":return b(t||[],n||[]).length;case"in":return-1!==n.indexOf(t);case"notIn":return-1===n.indexOf(t);case"contains":return-1!==(t||[]).indexOf(n);case"notContains":return-1===(t||[]).indexOf(n);default:if(0===e.indexOf("like"))return null!==L(n,e.substr(4)).exec(t);if(0===e.indexOf("notLike"))return null===L(n,e.substr(7)).exec(t)}}function K(t,e,n){return t===e?0:(n&&(t=n(t),e=n(e)),null===t&&null===e?0:null===t?-1:null===e?1:e>t?-1:t>e?1:0)}function T(t,e,n){return t.splice(e,0,n),t}function U(t,e){return t.splice(e,1),t}function $(t,e,n){for(var i=0,r=t.length,o=void 0,a=void 0;r>i;){if(a=(i+r)/2|0,o=K(e,t[a],n),0===o)return{found:!0,index:a};0>o?r=a:i=a+1}return{found:!1,index:r}}function J(t,e){if(R(this,J),t||(t=[]),!rt(t))throw new Error("fieldList must be an array.");e||(e={}),this.fieldList=t,this.fieldGetter=e.fieldGetter,this.hashCode=e.hashCode,this.isIndex=!0,this.keys=[],this.values=[]}function q(){var t=this,e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(R(this,q),!rt(e))throw new TypeError("new Collection([data]): data: Expected array. Found "+("undefined"==typeof e?"undefined":it.typeof(e)));this.idAttribute=n,this.index=new J([n],{hashCode:function(t){return l(t,n)}}),this.indexes={},e.forEach(function(e){t.index.insertRecord(e),e&&u(e.on)&&e.on("all",t._onModelEvent,t)})}function z(t,e,n){n||(n={});var i=n.localField=n.localField||e.name.toLowerCase(),r=n.localKey=n.localKey||e.name.toLowerCase()+"_id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var t=l(this,r),n=void 0!==t?e.get(t):void 0;return this._set("links."+i,n),n},set:function(t){return this._set("links."+i,t),d(this,r,t[e.idAttribute]),l(this,i)}},a=o.get,s=o.set;return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete o.get,delete o.set,o.writable=!0),n.get&&(o.get=function(){var i=this;return n.get(t,e,this,function(){return a.call(i)})},delete o.writable),n.set&&(o.set=function(i){var r=this;return n.set(t,e,this,i,function(t){return s.call(r,void 0===t?i:t)})},delete o.writable),o.get&&(o.set||(o.set=function(){})),Object.defineProperty(t.prototype,i,o),Object.defineProperty(t.prototype,r,{configurable:!0,enumerable:!0,get:function(){return this._get("props."+r)},set:function(e){this._set("props."+r,e),this._get("$")&&t.collection.indexes[r].updateRecord(this,{index:r})}}),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="belongsTo",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t.collection.createIndex(r),t}function B(t,e){return function(n){return n.dbg(gt,"Model:",t,"opts:",e),z(n,t,e)}}function V(t){var e=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return t=t||{},function(n){return p(t,function(t,i){(void 0===n[i]||e)&&(n[i]=w(t))}),n}}function G(t,e,n){n||(n={});var i=n.localField=n.localField||k(e.name)+"Collection",r=n.foreignKey,o=n.localKeys,a=n.foreignKeys;r||o||a||(r=n.foreignKey=k(t.name)+"_id"),r&&e.collection.createIndex(r);var s={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var n={},s=void 0;if(r)s=e.getAll(l(this,t.idAttribute),{index:r});else if(o){var u=l(this,o)||[],c=rt(u)?u:Object.keys(u);s=e.getAll.apply(e,c)}else a&&(d(n,"where."+a+".contains",l(this,t.idAttribute)),s=e.filter(n));return this._set("links."+i,s),s},set:function(n){var s=this;return this._set("links."+i,n),n&&n.length&&!function(){var i=l(s,t.idAttribute);r?n.forEach(function(t){d(t,r,i)}):o?!function(){var t=[];n.forEach(function(n){t.push(l(n,e.idAttribute))}),d(s,o,t)}():a&&n.forEach(function(t){var e=l(t,a);e?-1===e.indexOf(i)&&e.push(i):d(t,a,[i])})}(),l(this,i)}},u=s.get,c=s.set;return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete s.get,delete s.set,s.writable=!0),n.get&&(s.get=function(){var i=this;return n.get(t,e,this,function(){return u.call(i)})}),n.set&&(s.set=function(i){var r=this;return n.set(t,e,this,i,function(t){return c.call(r,void 0===t?i:t)})}),Object.defineProperty(t.prototype,i,s),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="hasMany",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t}function H(t,e){return function(n){return n.dbg(yt,"Model:",t,"opts:",e),G(n,t,e)}}function Q(t,e,n){n||(n={});var i=n.localField=n.localField||k(e.name),r=n.foreignKey=n.foreignKey||k(t.name)+"Id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var n=e.getAll(l(this,t.idAttribute),{index:r}),o=n&&n.length?n[0]:void 0;return this._set("links."+i,o),o},set:function(e){return this._set("links."+i,e),d(e,r,l(this,t.idAttribute)),l(this,i)}};return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete o.get,delete o.set),n.get&&!function(){var i=o.get;o.get=function(){var r=this;return n.get(t,e,this,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(r,e)}:void 0)}}(),n.set&&!function(){var i=o.set;o.set=function(r){var o=this;return n.set(t,e,this,r,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(o,e)}:void 0)}}(),Object.defineProperty(t.prototype,i,o),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="hasOne",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t.collection.createIndex(r),t}function Y(t,e){return function(n){return n.dbg(mt,"Model:",t,"opts:",e),Q(n,t,e)}}function Z(t,e){var n=[];return p(t,function(t,i){var r=_t[i];if(r){var o=r(t,e);o&&n.push(o)}}),n.length?n:void 0}function W(t,e,n){var i={enumerable:void 0!==n.enumerable?n.enumerable:!0};return i.get=function(){return this._get("props."+e)},i.set=function(i){var r=this,o=this._get,a=this._set,s=this._unset;if(!o("noValidate")){var u=Z(n,i);if(u)throw new Error(u.join(", "))}return n.track&&!o("creating")&&!function(){var t=o("changing"),n=o("previous."+e),u=o("props."+e),c=o("changed");t||(c=[]);var f=c.indexOf(e);u!==i&&-1===f&&c.push(e),n!==i?a("changes."+e,i):(s("changes."+e),f>=0&&c.splice(f,1)),c.length||(t=!1,s("changing"),s("changed"),o("eventId")&&(clearTimeout(o("eventId")),s("eventId"))),!t&&c.length&&(a("changed",c),a("changing",!0),a("eventId",setTimeout(function(){if(s("changed"),s("eventId"),s("changing"),!o("silent")){var t=void 0;for(t=0;t<c.length;t++)r.emit("change:"+c[t],r,l(r,c[t]));r.emit("change",r,o("changes"))}s("silent")},0)))}(),a("props."+e,i),o("$")&&n.indexed&&t.collection.updateRecord(this,{index:e}),i},n.indexed&&t.createIndex(e),n.get&&(i.get?!function(){var t=i.get;i.get=function(){return n.get.call(this,t)}}():i.get=n.get),n.set&&(i.set?!function(){var t=i.set;i.set=function(e){return n.set.call(this,e,t)}}():i.set=n.set),i}function X(t){return t||(t={}),function(e){return e.dbg(At,"opts:",t),e.schema||(e.schema={}),V(e.schema,t),p(t,function(t,n){var i=W(e,n,t);i.writable||Object.defineProperty(e.prototype,n,i)}),e}}function tt(t,e,n){return n||(n={}),n.op=xt,function(i){i.dbg(xt,"name:",t,"adapter:",e,"opts:",n),i.adapters[t]=e,(n===!0||n.default)&&(i.defaultAdapter=t)}}function et(t,e){R(this,et),t||(t={}),e||(e={});var n={};Object.defineProperties(this,{_get:{value:function(t){return l(n,t)}},_set:{value:function(t,e){return d(n,t,e)}},_unset:{value:function(t){return f(n,t)}}}),this._set("creating",!0),e.noValidate&&this._set("noValidate",!0),_(this,t),this._unset("creating"),this._set("changes",{}),this._unset("noValidate"),this._set("previous",w(t))}function nt(t){R(this,nt),t||(t={}),this.definitions={}}var it={};it.typeof=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},it.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var rt=Array.isArray,ot=/^(.+)\.(.+)$/,at=JSON.stringify,st=/\s+/,ut=/[^A-Za-z]/g,ct=/(\w)(\w*)/g,lt=Object.freeze({isArray:rt,isObject:e,isRegExp:i,isString:r,isDate:o,isNumber:a,isBoolean:s,isFunction:u,isSorN:c,get:l,unset:f,set:d,forOwn:p,deepMixIn:v,resolve:g,reject:y,_:m,intersection:b,fillIn:_,isBlacklisted:A,fromJson:x,toJson:at,copy:w,pascalCase:E,camelCase:k,eventify:C,uuid:I,classCallCheck:R,possibleConstructorReturn:P,addHiddenPropsToTarget:S}),ft={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},ht=/([.*+?^=!:${}()|[\]\/\\])/g,dt=/%/g,pt=/_/g;S(F.prototype,{getData:function(){return this.data||(this.data=this.collection.index.getAll()),this.data},between:function(t,e,n){n||(n={});var i=this.collection,r=n.index?i.indexes[n.index]:i.index;if(this.data)throw new Error("Cannot access index after first operation!");return this.data=r.between(t,e,n),this},get:function(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],e=arguments[1];if(e||(e={}),this.data)throw new Error("Cannot access index after first operation!");if(t&&!rt(t)&&(t=[t]),!t.length)return this.getData(),this;var n=this.collection,i=e.index?n.indexes[e.index]:n.index;return this.data=i.get(t),this},getAll:function(){var t=this,n={};if(this.data)throw new Error("Cannot access index after first operation!");for(var i=arguments.length,r=Array(i),o=0;i>o;o++)r[o]=arguments[o];if(!r.length||1===r.length&&e(r[0]))return this.getData(),this;r.length&&e(r[r.length-1])&&(n=r[r.length-1],r.pop());var a=this.collection,s=n.index?a.indexes[n.index]:a.index;return this.data=[],r.forEach(function(e){t.data=t.data.concat(s.get(e))}),this},filter:function(t,n){var i=this;return t||(t={}),this.getData(),e(t)?!function(){var n={};e(t.where)&&(n=t.where),p(t,function(t,e){e in ft||e in n||(n[e]={"==":t})});var o=[],s=[],u=[];p(n,function(t,n){e(t)||(t={"==":t}),p(t,function(t,e){o.push(n),s.push(e),u.push(t)})}),o.length&&!function(){var t=void 0,e=o.length;i.data=i.data.filter(function(n){var i=!0,r=!0;for(t=0;e>t;t++){var a=s[t],c="|"===a.charAt(0);a=c?a.substr(1):a;var f=D(l(n,o[t]),a,u[t]);void 0!==f&&(r=i?f:c?r||f:r&&f),i=!1}return r})}();var c=t.orderBy||t.sort;r(c)&&(c=[[c,"ASC"]]),rt(c)||(c=null),c&&!function(){var t=0;c.forEach(function(t,e){r(t)&&(c[e]=[t,"ASC"])}),i.data.sort(function(e,n){return M(c,t,e,n)})}(),a(t.skip)?i.skip(t.skip):a(t.offset)&&i.skip(t.offset),a(t.limit)&&i.limit(t.limit)}():u(t)&&(this.data=this.data.filter(t,n)),this},skip:function(t){if(!a(t))throw new TypeError("skip: Expected number but found "+("undefined"==typeof t?"undefined":it.typeof(t))+"!");var e=this.getData();return t<e.length?this.data=e.slice(t):this.data=[],this},limit:function(t){if(!a(t))throw new TypeError("limit: Expected number but found "+("undefined"==typeof t?"undefined":it.typeof(t))+"!");var e=this.getData();return this.data=e.slice(0,Math.min(e.length,t)),this},forEach:function(t,e){return this.getData().forEach(t,e),this},map:function(t,e){return this.data=this.getData().map(t,e),this},mapCall:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];return this.data=this.getData().map(function(e){return e[t].apply(e,n)}),this},run:function(){var t=this.data;return this.data=null,t}});var vt={">":1,">=":1,"<":1,"<=":1};S(J.prototype,{set:function(t,e){rt(t)||(t=[t]);var n=t.shift()||null,i=$(this.keys,n);if(0===t.length)if(i.found){var r=$(this.values[i.index],e,this.hashCode);r.found||T(this.values[i.index],r.index,e)}else T(this.keys,i.index,n),T(this.values,i.index,[e]);else if(i.found)this.values[i.index].set(t,e);else{T(this.keys,i.index,n);var o=new J([],{hashCode:this.hashCode});o.set(t,e),T(this.values,i.index,o)}},get:function(t){rt(t)||(t=[t]);var e=t.shift()||null,n=$(this.keys,e);return 0===t.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(t):[]},getAll:function(){var t=[];return this.values.forEach(function(e){t=e.isIndex?t.concat(e.getAll()):t.concat(e)}),t},visitAll:function(t,e){this.values.forEach(function(n){n.isIndex?n.visitAll(t,e):n.forEach(t,e)})},query:function(t){var e=void 0,n=void 0;if(t[">"]?(e=t[">"],t.leftInclusive=!1):t[">="]&&(e=t[">="],t.leftInclusive=!0),t["<"]?(n=t["<"],t.rightInclusive=!1):t["<="]&&(n=t["<="],t.rightInclusive=!0),e.length!==n.length)throw new Error("Key arrays must be same length");var i={};return p(t,function(t,e){vt[e]||(i[e]=t)}),this.between(e,n,i)},between:function(t,e){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];rt(t)||(t=[t]),rt(e)||(e=[e]),_(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var i=this._between(t,e,n);return n.limit?i.slice(n.offset,n.limit+n.offset):i.slice(n.offset)},_between:function(t,e,n){var i=[],r=t.shift(),o=e.shift(),a=void 0;if(a=void 0!==r?$(this.keys,r):{found:!1,index:0},0===t.length){a.found&&n.leftInclusive===!1&&(a.index+=1);for(var s=a.index;s<this.keys.length;s+=1){if(void 0!==o)if(n.rightInclusive){if(this.keys[s]>o)break}else if(this.keys[s]>=o)break;if(i=this.values[s].isIndex?i.concat(this.values[s].getAll()):i.concat(this.values[s]),n.limit&&i.length>=n.limit+n.offset)break}}else for(var s=a.index;s<this.keys.length;s+=1){var u=this.keys[s];if(u>o)break;if(i=this.values[s].isIndex?u===r?i.concat(this.values[s]._between(w(t),e.map(function(){}),n)):u===o?i.concat(this.values[s]._between(t.map(function(){}),w(e),n)):i.concat(this.values[s].getAll()):i.concat(this.values[s]),n.limit&&i.length>=n.limit+n.offset)break}return n.limit?i.slice(0,n.limit+n.offset):i},peek:function(){return this.values.length?this.values[0].isIndex?this.values[0].peek():this.values[0]:[]},remove:function(t,e){rt(t)||(t=[t]);var n=t.shift(),i=$(this.keys,n);if(0===t.length){if(i.found){var r=$(this.values[i.index],e,this.hashCode);r.found&&(U(this.values[i.index],r.index),0===this.values[i.index].length&&(U(this.keys,i.index),U(this.values,i.index)))}}else i.found&&this.values[i.index].delete(t,e)},clear:function(){this.keys=[],this.values=[]},insertRecord:function(t){var e=this.fieldList.map(function(e){return u(e)?e(t)||null:t[e]||null});this.set(e,t)},removeRecord:function(t){var e=this,n=void 0;return this.values.forEach(function(i,r){if(i.isIndex){if(i.removeRecord(t))return 0===i.keys.length&&(U(e.keys,r),U(e.values,r)),n=!0,!1}else{var o=$(i,t,e.hashCode);if(o.found)return U(i,o.index),0===i.length&&(U(e.keys,r),U(e.values,r)),n=!0,!1}}),n?t:void 0},updateRecord:function(t){this.removeRecord(t),this.insertRecord(t)}}),S(q.prototype,{_onModelEvent:function(){this.emit.apply(this,arguments)},createIndex:function(t,e,n){r(t)&&void 0===e&&(e=[t]),n||(n={});var i=this.idAttribute;n.hashCode=n.hashCode||function(t){return l(t,i)};var o=this.indexes[t]=new J(e,n);return this.index.visitAll(o.insertRecord,o),this},query:function(){return new F(this)},between:function(t,e,n){return this.query().between(t,e,n).run()},get:function(t,e){return this.query().get(t,e).run()},getAll:function(){var t;return(t=this.query()).getAll.apply(t,arguments).run()},filter:function(t,e){return this.query().filter(t,e).run()},skip:function(t){return this.query().skip(t).run()},limit:function(t){return this.query().limit(t).run()},forEach:function(t,e){this.index.visitAll(t,e)},reduce:function(t,e){var n=this.getAll();return n.reduce(t,e)},map:function(t,e){var n=[];return this.index.visitAll(function(i){n.push(t.call(e,i))}),n},insert:function(t){this.index.insertRecord(t),p(this.indexes,function(e,n){e.insertRecord(t)}),t&&u(t.on)&&(t.on("all",this._onModelEvent,this),this.emit("add",t))},update:function(t){this.index.updateRecord(t),p(this.indexes,function(e,n){e.updateRecord(t)})},remove:function(t){this.index.removeRecord(t),p(this.indexes,function(e,n){e.removeRecord(t)}),t&&u(t.off)&&(t.off("all",this._onModelEvent,this),this.emit("remove",t))},updateRecord:function(t,e){e||(e={});var n=e.index?this.indexes[e.index]:this.index;n.updateRecord(t)},mapCall:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];var r=[];return this.index.visitAll(function(e){r.push(e[t].apply(e,n))}),r}}),C(q.prototype,function(){return this._events},function(t){this._events=t});var gt="belongsTo",yt="hasMany",mt="hasOne",bt={array:rt,boolean:s,integer:a,number:a,null:function(t){return null===t},object:e,string:r},_t={type:function(t,e){if(void 0!==e){r(t)&&(t=[t]);var n=t.map(function(n){var i=bt[n];return i?i(e)?void 0:1:"type: Unknown type "+t});return-1!==n.indexOf(void 0)?void 0:"type: Expected: "+t.join(" or ")+". Actual: "+("undefined"==typeof e?"undefined":it.typeof(e))}},anyOf:function(t,e){var n=!1,i=[];return t.forEach(function(t){var r=Z(t,e);r?i=i.concat(r):n=!0}),n?void 0:i},allOf:function(t,e){var n=[];return t.forEach(function(t){n=n.concat(Z(t,e)||[])}),n.length?void 0:n},oneOf:function(t,e){var n=!1,i=[];return t.forEach(function(t){var r=Z(t,e);if(r)i=i.concat(r);else{if(n)return i=["more than one schema validated"],n=!1,!1;n=!0}}),n?void 0:i}},At="setSchema",xt="registerAdapter",wt=g,jt={length:1,name:1,arguments:1,prototype:1,caller:1,__super__:1},Ot=!1;try{Ot=!!window}catch(t){}var Et=function(){for(var t=this,e=arguments.length,n=Array(e),i=0;e>i;i++)n[i]=arguments[i];var r=n.pop();(r.notify||void 0===r.notify&&this.notify)&&setTimeout(function(){t.emit.apply(t,[r.op].concat(n))})},kt=function(t,e,n,i){return n.raw?(e.adapter=i,n.autoInject&&(e.data=t.inject(e.data)),e):(n.autoInject&&(e=t.inject(e)),(n.notify||void 0===n.notify&&t.notify)&&setTimeout(function(){t.emit(n.op,e,n)}),e)};S(et.prototype,{schema:function(t){var e=this.constructor.schema;return t?e[t]:e},validate:function(t,e){var n=[],i=this.schema();if(t)if(r(t)){var o=i[t];o&&(n=Z(o,e)||[])}else p(i,function(e,i){n=n.concat(Z(e,l(t,i))||[])});else t=this;return n.length?n:void 0},create:function(t){return this.constructor.create(this,t)},beforeSave:function(){},save:function(t){var e=this,n=this.constructor,i="save";n.dbg(i,"instance:",this,"opts:",t);var r=void 0;return t||(t={}),m(n,t),t.op=i,wt(this.beforeSave(t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).update(n,l(e,n.idAttribute),e.toJSON(t),t)}).then(function(i){return wt(e.afterSave(t)).then(function(){return kt(n,i,t,r)})})},afterSave:function(){},destroy:function(t){var e=this.constructor;return e.destroy(l(this,e.idAttribute),t)},get:function(t){return l(this,t)},set:function(t,n,i){e(t)&&(i=n),i||(i={}),i.silent&&this._set("silent",!0),d(this,t,n),this._get("eventId")||this._unset("silent")},unset:function(t,e){e||(e={}),e.silent&&this._set("silent",!0),f(this,t),this._get("eventId")||this._unset("silent")},hashCode:function(){return l(this,this.constructor.idAttribute)},changes:function(t){return t?this._get("changes."+t):this._get("changes")},hasChanges:function(){return!!(this._get("changed")||[]).length},commit:function(){return this._unset("changed"),this._set("changes",{}),this._set("previous",w(this)),this},previous:function(t){return t?this._get("previous."+t):this._get("previous")},revert:function(t){var e=this,n=this._get("previous")||{};return t||(t={}),t.preserve||(t.preserve=[]),p(this,function(i,r){r!==e.constructor.idAttribute&&!n.hasOwnProperty(r)&&e.hasOwnProperty(r)&&-1===t.preserve.indexOf(r)&&delete e[r]}),p(n,function(n,i){-1===t.preserve.indexOf(i)&&(e[i]=n)}),this.commit(),this},toJSON:function(t){var e=this;t||(t={});var n=this.constructor,i=this;if(this instanceof et){i={};for(var o in this)i[o]=this[o];n&&n.relationList&&t.with&&(r(t.with)&&(t.with=[t.with]),n.relationList.forEach(function(n){var r=void 0;-1!==t.with.indexOf(n.relation)?r=n.relation:-1!==t.with.indexOf(n.localField)&&(r=n.localField),r&&!function(){var o={with:t.with.slice()};o.with.splice(o.with.indexOf(r),1),o.with.forEach(function(t,e){t&&0===t.indexOf(r)&&t.length>=r.length&&"."===t[r.length]?o.with[e]=t.substr(r.length+1):o.with[e]=""});var a=l(e,n.localField);a&&(rt(a)?d(i,n.localField,a.map(function(t){return n.Relation.prototype.toJSON.call(t,o)})):d(i,n.localField,n.Relation.prototype.toJSON.call(a,o)))}()}))}return i}}),_(et,{autoEject:!0,autoInject:Ot,bypassCache:!1,csp:!1,defaultAdapter:"http",debug:!1,eagerEject:!1,idAttribute:"id",linkRelations:Ot,notify:Ot,onConflict:"merge",relationsEnumerable:!1,raw:!1,upsert:!0,createIndex:function(t,e,n){this.dbg("createIndex","name:",t,"fieldList:",e,"opts:",n),this.collection.createIndex(t,e,n)},createInstance:function(t,e){var n=this;return t instanceof n?t:new n(t,e)},is:function(t){return t instanceof this},getAutoPkItems:function(){return this.getAll().filter(function(t){return t._get("autoPk")})},changes:function(t){if(this.dbg("changes","id:",t),c(t)){var e=this.get(t);return e?e.changes():void 0}return this.collection.mapCall("changes")},hasChanges:function(t){var e=this;if(this.dbg("hasChanges","id:",t),c(t)){var n=this.get(t);if(n)return n.hasChanges()}else{var i=function(){var t=!1;return e.collection.forEach(function(e){t=t||e.hasChanges()}),{v:t}}();if("object"===("undefined"==typeof i?"undefined":it.typeof(i)))return i.v}},beforeInject:function(){},inject:function(t,e){var n=this,i="inject";n.dbg(i,"entities:",t,"opts:",e),e||(e={}),m(n,e),e.op=i,this.beforeInject(t,e);var r=!1,o=n.collection,a=n.idAttribute,s=n.relationList||[],h=(new Date).getTime();rt(t)||(t=[t],r=!0),t=t.map(function(t){var i=l(t,a),r=!1;if(!c(i)){if(!e.autoPk)throw new TypeError("User#"+a+": Expected string or number, found "+("undefined"==typeof i?"undefined":it.typeof(i))+"!");i=I(),d(t,a,i),r=!0}var g=n.get(i);if(t===g)return g;if(s.forEach(function(e){var r=e.Relation,o=r.idAttribute,s=e.foreignKey,c=l(t,e.localField);if(u(e.inject))e.inject(n,e,t);else if(c&&e.inject!==!1)if(rt(c))c=c.map(function(t){if(t!==r.get(l(t,o)))try{s&&d(t,s,i),t=r.inject(t)}catch(t){throw new Error("Failed to inject "+e.type+' relation: "'+e.relation+'"! '+t.message)}return t}),e.localKeys&&d(t,e.localKeys,c.map(function(t){return l(t,o)}));else if(c!==r.get(l(c,o)))try{e.localKey&&d(t,e.localKey,l(c,r.idAttribute)),s&&d(c,e.foreignKey,l(t,a)),c=r.inject(c)}catch(t){throw new Error("Failed to inject "+e.type+' relation: "'+e.relation+'"!')}e.link||void 0===e.link&&n.linkRelations?f(t,e.localField):d(t,e.localField,c)}),g){var y=e.onConflict||n.onConflict;"merge"===y?v(g,t):"replace"===y&&(p(g,function(e,n){n===a||t.hasOwnProperty(n)||delete g[n]}),g.set(t)),t=g,o.update(t)}else t=n.createInstance(t),r&&t._set("autoPk",r),o.insert(t);return t._set("$",h),t});var g=r?t.length?t[0]:void 0:t;return this.afterInject(g,e),g},afterInject:function(){},beforeEject:function(){},eject:function(t,e){var n="eject";this.dbg(n,"id:",t,"opts:",e),e||(e={}),e.op=n,this.beforeEject(t,e);var i=this.get(t);return i&&(i._unset("$"),this.collection.remove(i)),this.afterEject(i,e),i},afterEject:function(){},beforeEjectAll:function(){},ejectAll:function(t,e){var n="ejectAll";this.dbg(n,"query:",t,"opts:",e),e||(e={}),e.op=n,this.beforeEjectAll(t,e);var i=this.filter(t),r=this.collection;return i.forEach(function(t){r.remove(t)}),this.afterEjectAll(i,t,e),i},afterEjectAll:function(){},get:function(t){this.dbg("get","id:",t);var e=this.collection.get(t);return e.length?e[0]:void 0},between:function(){var t;return(t=this.collection).between.apply(t,arguments)},getAll:function(){var t;return(t=this.collection).getAll.apply(t,arguments)},filter:function(t,e){return e||(e={}),this.collection.filter(t,e)},forEach:function(t,e){return this.collection.forEach(t,e)},map:function(t,e){return this.collection.map(t,e)},reduce:function(t,e){return this.collection.reduce(t,e)},mapCall:function(){var t;return(t=this.collection).mapCall.apply(t,arguments)},toJSON:function(t){return this.mapCall("toJSON",t)},query:function(){return this.collection.query()},getAdapter:function(t){this.dbg("getAdapter","name:",t);var e=this.getAdapterName(t);if(!e)throw new ReferenceError(e+" not found!");return this.adapters[e]},getAdapterName:function(t){return t||(t={}),r(t)&&(t={adapter:t}),t.adapter||t.defaultAdapter},beforeCreate:Et,create:function(t,e){var n=this,i="create";if(this.dbg(i,"props:",t,"opts:",e),t||(t={}),e||(e={}),m(this,e),e.op=i,e.upsert&&l(t,this.idAttribute)&&(!this.is(t)||!t._get("autoPk")))return this.update(l(t,this.idAttribute),t,e);var r=void 0;return wt(this.beforeCreate(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).create(n,n.prototype.toJSON.call(t,e),e)}).then(function(i){return wt(n.afterCreate(i,e)).then(function(){return n.is(t)&&t._get("$")&&n.eject(l(t,n.idAttribute)),kt(n,i,e,r)})})},afterCreate:Et,beforeCreateMany:Et,createMany:function(t,e){var n=this,i="createMany";if(this.dbg(i,"entities:",t,"opts:",e),t||(t=[]),e||(e={}),m(this,e),e.op=i,e.upsert){var r=function(){var i=!0;return t.forEach(function(t){i=i&&l(t,n.idAttribute)&&(!u(t._get)||!t._get("autoPk"))}),i?{v:n.updateMany(t,e)}:void 0}();if("object"===("undefined"==typeof r?"undefined":it.typeof(r)))return r.v}var o=void 0;return wt(this.beforeCreateMany(t,e)).then(function(){return o=n.getAdapterName(e),n.getAdapter(o).createMany(n,t.map(function(t){return n.prototype.toJSON.call(t,e)}),e)}).then(function(i){return wt(n.afterCreateMany(i,e)).then(function(){return t.forEach(function(t){n.is(t)&&t._get("$")&&n.eject(l(t,n.idAttribute))}),kt(n,i,e,o)})})},afterCreateMany:Et,beforeFind:Et,find:function(t,e){var n=this,i="find";this.dbg(i,"id:",t,"opts:",e);var r=void 0;return e||(e={}),m(this,e),e.op=i,wt(this.beforeFind(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).find(n,t,e)}).then(function(t){return wt(n.afterFind(t,e)).then(function(){return kt(n,t,e,r)})})},afterFind:Et,beforeFindAll:Et,findAll:function(t,e){var n=this,i="findAll";this.dbg(i,"query:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,wt(this.beforeFindAll(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).findAll(n,t,e)}).then(function(i){return wt(n.afterFindAll(t,i,e)).then(function(){return kt(n,i,e,r)})})},afterFindAll:Et,beforeSave:Et,save:function(t,e){var n=this,i="save",r=this.get(t);return e||(e={}),m(this,e),e.op=i,wt(this.beforeSave(r,e)).then(function(){if(!r)throw new Error('instance with "'+n.idAttribute+'" of '+t+" not in Model's collection!");return r.save(e)}).then(function(t){return wt(n.afterSave(r,e)).then(function(){return t})})},afterSave:Et,beforeUpdate:Et,update:function(t,e,n){var i=this,r="update";this.dbg(r,"id:",t,"props:",e,"opts:",n);var o=void 0;return e||(e={}),n||(n={}),m(this,n),n.op=r,wt(this.beforeUpdate(t,e,n)).then(function(){return o=i.getAdapterName(n),i.getAdapter(o).update(i,t,i.prototype.toJSON.call(e,n),n)}).then(function(e){return wt(i.afterUpdate(t,e,n)).then(function(){return kt(i,e,n,o)})})},afterUpdate:Et,beforeUpdateMany:Et,updateMany:function(t,e){var n=this,i="updateMany";this.dbg(i,"entities:",t,"opts:",e);var r=void 0;return t||(t=[]),e||(e={}),m(this,e),e.op=i,wt(this.beforeUpdateMany(t,e)).then(function(){ | ||
return r=n.getAdapterName(e),n.getAdapter(r).updateMany(n,t.map(function(t){return n.prototype.toJSON.call(t,e)}),e)}).then(function(t){return wt(n.afterUpdateMany(t,e)).then(function(){return kt(n,t,e,r)})})},afterUpdateMany:Et,beforeUpdateAll:Et,updateAll:function(t,e,n){var i=this,r="updateAll";this.dbg(r,"query:",t,"props:",e,"opts:",n);var o=void 0;return t||(t={}),e||(e={}),n||(n={}),m(this,n),n.op=r,wt(this.beforeUpdateAll(t,e,n)).then(function(){return o=i.getAdapterName(n),i.getAdapter(o).updateAll(i,t,e,n)}).then(function(e){return wt(i.afterUpdateAll(t,e,n)).then(function(){return kt(i,e,n,o)})})},afterUpdateAll:Et,beforeDestroy:Et,destroy:function(t,e){var n=this,i="destroy";this.dbg(i,"id:",t,"opts:",e);var r=void 0;return e||(e={}),m(this,e),e.op=i,wt(this.beforeDestroy(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).destroy(n,t,e)}).then(function(i){return wt(n.afterDestroy(t,e)).then(function(){return e.raw?(i.adapter=r,e.autoEject&&(i.data=n.eject(t,e)),i):(e.autoEject&&(i=n.eject(t,e)),i)})})},afterDestroy:Et,beforeDestroyAll:Et,destroyAll:function(t,e){var n=this,i="destroyAll";this.dbg(i,"query:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,wt(this.beforeDestroyAll(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).destroyAll(n,t,e)}).then(function(i){return wt(n.afterDestroyAll(t,e)).then(function(){return e.raw?(i.adapter=r,e.autoEject&&(i.data=n.ejectAll(t,e)),i):(e.autoEject&&(i=n.ejectAll(t,e)),i)})})},afterDestroyAll:Et,beforeLoadRelations:Et,loadRelations:function(t,e,n){var i=this,o=this,a=o.is(t)?t:void 0;t=a?l(a,o.idAttribute):t;var s="loadRelations";o.dbg(s,"id:",t,"relations:",e,"opts:",n),e||(e=[]),n||(n={});var f=o.relationList||[];return m(o,n),n.op=s,wt(o.beforeLoadRelations(t,e,n)).then(function(){if(c(t)&&!a&&(a=o.get(a)),!a)throw new Error("You passed an id of an instance not found in the collection of the Model!");return r(e)&&(e=[e]),Promise.all(f.map(function(e){if(u(e.load))return e.load(o,e,a,n);var i=void 0;if(e.foreignKey)i=e.Relation.findAll(it.defineProperty({},e.foreignKey,t),n);else if(e.localKey){var r=l(a,e.localKey);c(r)&&(i=e.Relation.find(r,n))}else e.localKeys?i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{in:l(a,e.localKeys)}),n):e.foreignKeys&&(i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{contains:l(a,o.idAttribute)}),n));return i&&(i=i.then(function(t){n.raw&&(t=t.data),d(a,e.localField,"hasOne"===e.type?t.length?t[0]:void 0:t)})),i}))}).then(function(){return wt(i.afterLoadRelations(a,e,n)).then(function(){return a})})},afterLoadRelations:Et,log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var r=t.toUpperCase()+": ("+this.name+")";if(console[t]){var o;(o=console)[t].apply(o,[r].concat(n))}else{var a;(a=console).log.apply(a,[r].concat(n))}}},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},belongsTo:function(t,e){return B(t,e)(this)},hasMany:function(t,e){return H(t,e)(this)},hasOne:function(t,e){return Y(t,e)(this)},setSchema:function(t){return X(t)(this)},configure:function(t){return V(t)(this)},registerAdapter:function(t,e,n){return tt(t,e,n)(this)},extend:function(t,e){var n=this,i=void 0;n.dbg("extend","props:",t,"classProps:",e),t||(t={}),e||(e={});var r=t.initialize;if(delete t.initialize,t.hasOwnProperty("constructor"))i=t.constructor,delete t.constructor;else{if(!e.name)throw new TypeError("name: Expected string, found "+it.typeof(e.name)+"!");if(e.csp)i=function(){R(this,i);for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var o=P(this,(i.__super__||Object.getPrototypeOf(i)).apply(this,e));return r&&r.apply(o,e),o};else{var o=E(e.name),a="return function "+o+"() {\n classCallCheck(this, "+o+")\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var _this = possibleConstructorReturn(this, ("+o+".__super__ || Object.getPrototypeOf("+o+")).apply(this, args));\n if (initialize) {\n initialize.apply(_this, arguments)\n }\n return _this\n }";i=new Function("classCallCheck","possibleConstructorReturn","Parent","initialize",a)(R,P,n,r)}}e.shortname=e.shortname||k(i.name||e.name),delete e.name;var s=e.schema;if(delete e.schema,i.prototype=Object.create(n&&n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf)Object.setPrototypeOf(i,n);else if(e.strictEs6Class)i.__proto__=n;else{var u=Object.getOwnPropertyNames(n);u.forEach(function(t){jt[t]||Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(n,t))})}return Object.defineProperty(i,"__super__",{configurable:!0,value:n}),V(t)(i.prototype),V(e)(i),s&&X(s)(i),i}}),Object.defineProperties(et,{__events:{configurable:!0,value:{}},_events:{get:function(){return this.__events===(this.__super__?this.__super__:Object.getPrototypeOf(this)).__events&&Object.defineProperty(this,"__events",{value:{}}),this.__events}},_adapters:{configurable:!0,value:{}},adapters:{get:function(){var t=(this.__super__?this.__super__:Object.getPrototypeOf(this))._adapters;return this._adapters===t&&(Object.defineProperty(this,"_adapters",{value:{}}),_(this._adapters,t)),this._adapters}},_collection:{configurable:!0,value:new q([],"id")},collection:{get:function(){return this._collection===(this.__super__?this.__super__:Object.getPrototypeOf(this))._collection&&(Object.defineProperty(this,"_collection",{value:new q([],this.idAttribute)}),this._collection.on("all",this.emit,this),this._collection.createIndex("lastInjected",["$"],{fieldGetter:function(t){return t._get("$")}})),this._collection}}}),C(et,function(){return this._events},function(t){this._events=t}),C(et.prototype,function(){return this._get("events")},function(t){this._set("events",t)}),S(nt.prototype,{clear:function(){var t={};return p(this.definitions,function(e){var n=e.name;t[n]=e.ejectAll()}),t},defineModel:function(t){var e=et.extend(t.methods||{},t);return this.definitions[e.name]=e,e}}),nt.prototype.defineResource=nt.prototype.defineModel,p(et,function(t,e){u(t)&&(nt.prototype[e]=function(t){var n;if(!this.definitions[t])throw new Error(t+" is not a registered Model!");for(var i=arguments.length,r=Array(i>1?i-1:0),o=1;i>o;o++)r[o-1]=arguments[o];return(n=this.definitions[t])[e].apply(n,r)})}),Promise.prototype.spread||(Promise.prototype.spread=function(t){return this.then(function(e){return t.apply(this,e)})});var Ct=lt,It={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"};t.utils=Ct,t.version=It,t.Collection=q,t.Query=F,t.DS=nt,t.belongsTo=B,t.configure=V,t.hasMany=H,t.hasOne=Y,t.setSchema=X,t.registerAdapter=tt,t.Model=et,t.rules=_t,t.validate=Z}); | ||
//# sourceMappingURL=dist/js-data.min.map |
195
js-data.d.ts
@@ -14,3 +14,3 @@ // Type definitions for JSData v3 | ||
*/ | ||
createIndex(name: string, keyList: string[]): this; | ||
createIndex(name: string, keyList: string[]): Collection<R>; | ||
@@ -57,3 +57,3 @@ /** | ||
*/ | ||
forEach(fn: Function, thisArg); | ||
forEach(fn: Function, thisArg?); | ||
@@ -68,3 +68,3 @@ /** | ||
*/ | ||
map<T>(fn: Function, thisArg): T[]; | ||
map<T>(fn: (each: R) => T, thisArg?): T[]; | ||
@@ -111,3 +111,3 @@ /** | ||
*/ | ||
between(leftKeys: string[], rightKeys: string[], options: QueryOptions): this; | ||
between(leftKeys: string[], rightKeys: string[], options: QueryOptions): Query<R>; | ||
@@ -117,3 +117,3 @@ /** | ||
*/ | ||
get(keyList: string[], options: QueryOptionsBase): this; | ||
get(keyList: string[], options: QueryOptionsBase): Query<R>; | ||
@@ -123,3 +123,3 @@ /** | ||
*/ | ||
getAll(keyList: string[], options: QueryOptionsBase): this; | ||
getAll(keyList: string[], options: QueryOptionsBase): Query<R>; | ||
@@ -130,3 +130,3 @@ /** | ||
*/ | ||
filter(query: Object | Function, thisArg): this; | ||
filter(query: Object | Function, thisArg?): Query<R>; | ||
@@ -136,3 +136,3 @@ /** | ||
*/ | ||
skip(number: Number): this; | ||
skip(number: Number): Query<R>; | ||
@@ -142,3 +142,3 @@ /** | ||
*/ | ||
limit(number: Number): this; | ||
limit(number: Number): Query<R>; | ||
@@ -148,3 +148,3 @@ /** | ||
*/ | ||
forEach(fn: Function, thisArg): this; | ||
forEach(fn: Function, thisArg?): Query<R>; | ||
@@ -154,3 +154,3 @@ /** | ||
*/ | ||
map(fn: Function, thisArg): this; | ||
map(fn: Function, thisArg?): Query<R>; | ||
@@ -231,8 +231,58 @@ /** | ||
class Model<R> { | ||
new(properties: R, options: ModelOptions): this; | ||
schema(key?: string): Object; | ||
validate(obj?: Object): string[] | void; | ||
create(opts?: Object): Promise<Model<R>>; | ||
save(opts?: Object): Promise<Model<R>>; | ||
destroy(opts?: Object): Promise<Model<R>>; | ||
/** | ||
* Return the value at the given path for this instance. | ||
*/ | ||
get(key: string): any; | ||
/** | ||
* Set the value for a given key, or the values for the given keys if "key" is | ||
* an object. | ||
*/ | ||
set(key: string, value): any; | ||
/** | ||
* Return a plain object representation of this instance. | ||
*/ | ||
toJSON(opts?: Object): string; | ||
/** | ||
* Extend this Model and return a new child Model. Static properties on this | ||
* Model will be shallow copied to the child Model. The child Model's | ||
* prototype will point to the parent Model. | ||
*/ | ||
static extend<R>(instanceProps?: Object, staticProps?: ModelOptions): ModelConstructor<R>; | ||
} | ||
interface ModelOptions { | ||
autoEject?: boolean; | ||
autoInject?: boolean; | ||
bypassCache?: boolean; | ||
csp?: boolean; | ||
defaultAdapter?: string; | ||
debug?: boolean; | ||
eagerEject?: boolean; | ||
endpoint?: string; | ||
idAttribute?: string; | ||
linkRelations?: boolean; | ||
name?: string; | ||
notify?: boolean; | ||
onConflict?: string; | ||
relationsEnumerable?: boolean; | ||
raw?: boolean; | ||
upsert?: boolean; | ||
} | ||
interface ModelConstructor<R> extends ModelOptions { | ||
new (properties: R, options: ModelOptions): Model<R>; | ||
/** | ||
* Create a new secondary index in the Collection instance of this Model. | ||
*/ | ||
static createIndex(name: string, keyList: string[]); | ||
createIndex(name: string, keyList: string[]); | ||
@@ -242,3 +292,3 @@ /** | ||
*/ | ||
static createInstance<R>(props: Object): Model<R>; | ||
createInstance(props: Object): Model<R>; | ||
@@ -248,3 +298,3 @@ /** | ||
*/ | ||
static is(instance): boolean; | ||
is(instance): boolean; | ||
@@ -261,3 +311,3 @@ /** | ||
*/ | ||
static inject<R>(items: Model<R> | Object, options?: Object): Model<R>; | ||
inject(items: Model<R> | Object, options?: Object): Model<R>; | ||
@@ -274,3 +324,3 @@ /** | ||
*/ | ||
static inject<R>(items: Model<R>[] | Object[], options?: Object): Model<R>[]; | ||
inject(items: Model<R>[] | Object[], options?: Object): Model<R>[]; | ||
@@ -281,3 +331,3 @@ /** | ||
*/ | ||
static eject<R>(id: ID): Model<R> | void; | ||
eject(id: ID): Model<R> | void; | ||
@@ -288,3 +338,3 @@ /** | ||
*/ | ||
static ejectAll<R>(query: Object): Model<R>[]; | ||
ejectAll(query: Object): Model<R>[]; | ||
@@ -295,3 +345,3 @@ /** | ||
*/ | ||
static get<R>(id: ID): Model<R> | void; | ||
get(id: ID): Model<R> | void; | ||
@@ -301,3 +351,3 @@ /** | ||
*/ | ||
static getAll<R>(keyList: string[], options: QueryOptionsBase): R[]; | ||
getAll(keyList: string[], options: QueryOptionsBase): R[]; | ||
@@ -307,3 +357,3 @@ /** | ||
*/ | ||
static filter<R>(query: Object | Function): R[]; | ||
filter(query: Object | Function): R[]; | ||
@@ -313,3 +363,3 @@ /** | ||
*/ | ||
static query<R>(): Query<R>; | ||
query(): Query<R>; | ||
@@ -320,3 +370,3 @@ /** | ||
*/ | ||
static getAdapter(name?: string): Adapter; | ||
getAdapter(name?: string): Adapter; | ||
@@ -327,3 +377,3 @@ /** | ||
*/ | ||
static getAdapterName(options: Object): string; | ||
getAdapterName(options: Object): string; | ||
@@ -342,3 +392,3 @@ /** | ||
*/ | ||
static beforeCreate(props?: Object, opts?: Object): Promise<void> | void; | ||
beforeCreate(props?: Object, opts?: Object): Promise<void> | void; | ||
@@ -363,3 +413,3 @@ /** | ||
*/ | ||
static create<R>(props?: Object, opts?: Object): Promise<R>; | ||
create(props?: Object, opts?: Object): Promise<R>; | ||
@@ -377,31 +427,31 @@ /** | ||
*/ | ||
static afterCreate(data?: Object, opts?: Object): Promise<void> | void; | ||
afterCreate(data?: Object, opts?: Object): Promise<void> | void; | ||
static beforeCreateMany(items?: Object[], opts?: Object): Promise<void> | void; | ||
static createMany<R>(items?: Object[], opts?: Object): Promise<R[]>; | ||
static afterCreateMany(data?: Object[], opts?: Object): Promise<void> | void; | ||
static beforeFind(id?: ID, opts?: Object): Promise<void> | void; | ||
static find<R>(id: ID, opts?: Object): Promise<R>; | ||
static afterFind(data?: Object, opts?: Object): Promise<void> | void; | ||
static beforeFindAll(query?: Object, opts?: Object): Promise<void> | void; | ||
static findAll<R>(query?: Object, opts?: Object): Promise<R[]>; | ||
static afterFindAll(query?: Object, opts?: Object): Promise<void> | void; | ||
static beforeUpdate(id?: ID, props?: Object, opts?: Object): Promise<void> | void; | ||
static update<R>(id: ID, props?: Object, opts?: Object): Promise<R>; | ||
static afterUpdate(id?: ID, props?: Object, opts?: Object): Promise<void> | void; | ||
static beforeUpdateMany(items?: Object[], opts?: Object): Promise<void> | void; | ||
static updateMany<R>(items?: Object[], opts?: Object): Promise<R[]>; | ||
static afterUpdateMany(data?: Object[], opts?: Object): Promise<void> | void; | ||
static beforeUpdateAll(query?: Object, props?: Object, opts?: Object): Promise<void> | void; | ||
static updateAll<R>(query?: Object, props?: Object, opts?: Object): Promise<R[]>; | ||
static afterUpdateAll(query?: Object, data?: Object[], opts?: Object): Promise<void> | void; | ||
static beforeDestroy(id?: ID, opts?: Object): Promise<void> | void; | ||
static destroy<R>(id: ID, opts?: Object): Promise<R>; | ||
static afterDestroy(data?: Object, opts?: Object): Promise<void> | void; | ||
static beforeDestroyAll(query?: Object, opts?: Object): Promise<void> | void; | ||
static destroyAll<R>(query?: Object, opts?: Object): Promise<R[]>; | ||
static afterDestroyAll(query?: Object, opts?: Object): Promise<void> | void; | ||
static belongsTo(model: Model<any>, opts?: RelationOptions): any; | ||
static hasMany(model: Model<any>, opts?: RelationOptions): any; | ||
static hasOne(model: Model<any>, opts?: RelationOptions): any; | ||
beforeCreateMany(items?: Object[], opts?: Object): Promise<void> | void; | ||
createMany(items?: Object[], opts?: Object): Promise<R[]>; | ||
afterCreateMany(data?: Object[], opts?: Object): Promise<void> | void; | ||
beforeFind(id?: ID, opts?: Object): Promise<void> | void; | ||
find(id: ID, opts?: Object): Promise<R>; | ||
afterFind(data?: Object, opts?: Object): Promise<void> | void; | ||
beforeFindAll(query?: Object, opts?: Object): Promise<void> | void; | ||
findAll(query?: Object, opts?: Object): Promise<R[]>; | ||
afterFindAll(query?: Object, opts?: Object): Promise<void> | void; | ||
beforeUpdate(id?: ID, props?: Object, opts?: Object): Promise<void> | void; | ||
update(id: ID, props?: Object, opts?: Object): Promise<R>; | ||
afterUpdate(id?: ID, props?: Object, opts?: Object): Promise<void> | void; | ||
beforeUpdateMany(items?: Object[], opts?: Object): Promise<void> | void; | ||
updateMany(items?: Object[], opts?: Object): Promise<R[]>; | ||
afterUpdateMany(data?: Object[], opts?: Object): Promise<void> | void; | ||
beforeUpdateAll(query?: Object, props?: Object, opts?: Object): Promise<void> | void; | ||
updateAll(query?: Object, props?: Object, opts?: Object): Promise<R[]>; | ||
afterUpdateAll(query?: Object, data?: Object[], opts?: Object): Promise<void> | void; | ||
beforeDestroy(id?: ID, opts?: Object): Promise<void> | void; | ||
destroy(id: ID, opts?: Object): Promise<R>; | ||
afterDestroy(data?: Object, opts?: Object): Promise<void> | void; | ||
beforeDestroyAll(query?: Object, opts?: Object): Promise<void> | void; | ||
destroyAll(query?: Object, opts?: Object): Promise<R[]>; | ||
afterDestroyAll(query?: Object, opts?: Object): Promise<void> | void; | ||
belongsTo(model: Model<any>, opts?: RelationOptions): any; | ||
hasMany(model: Model<any>, opts?: RelationOptions): any; | ||
hasOne(model: Model<any>, opts?: RelationOptions): any; | ||
@@ -411,3 +461,3 @@ /** | ||
*/ | ||
static setSchema(opts?: Object): any; | ||
setSchema(opts?: Object): any; | ||
@@ -417,3 +467,3 @@ /** | ||
*/ | ||
static configure(opts?: Object): any; | ||
configure(opts?: Object): any; | ||
@@ -423,25 +473,10 @@ /** | ||
*/ | ||
static registerAdapter(name: string, adapter: Adapter, opts?: Object): Model<any>; | ||
registerAdapter(name: string, adapter: Adapter, opts?: Object): ModelConstructor<R>; | ||
schema(key?: string): Object; | ||
validate(obj?: Object): string[] | void; | ||
create(opts?: Object): Promise<Model<R>>; | ||
save(opts?: Object): Promise<Model<R>>; | ||
destroy(opts?: Object): Promise<Model<R>>; | ||
/** | ||
* Return the value at the given path for this instance. | ||
* Extend this Model and return a new child Model. Static properties on this | ||
* Model will be shallow copied to the child Model. The child Model's | ||
* prototype will point to the parent Model. | ||
*/ | ||
get(key: string): any; | ||
/** | ||
* Set the value for a given key, or the values for the given keys if "key" is | ||
* an object. | ||
*/ | ||
set(key: string, value): any; | ||
/** | ||
* Return a plain object representation of this instance. | ||
*/ | ||
toJSON(opts?: Object): string; | ||
extend<R>(instanceProps?: Object, staticProps?: ModelOptions): ModelConstructor<R>; | ||
} | ||
@@ -523,3 +558,3 @@ | ||
*/ | ||
function forOwn(object: Object, fn: Function, thisArg); | ||
function forOwn(object: Object, fn: Function, thisArg?); | ||
@@ -542,5 +577,5 @@ /** | ||
/** | ||
* Shallow copy own enumerable non-function properties from `model` to `options`. | ||
* Shallow copy own enumerable non-function properties from `src` to `dest`. | ||
*/ | ||
function _<R>(model: Model<R>, options: Object); | ||
function _(src: Object, dest: Object); | ||
@@ -547,0 +582,0 @@ /** |
{ | ||
"name": "js-data", | ||
"description": "Robust, framework-agnostic in-memory data store.", | ||
"version": "3.0.0-alpha.3", | ||
"version": "3.0.0-alpha.4", | ||
"homepage": "http://www.js-data.io", | ||
@@ -6,0 +6,0 @@ "repository": { |
209
README.md
@@ -1,63 +0,56 @@ | ||
<img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="64" height="64" /> | ||
<img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="96" height="96" /> | ||
## JSData [![Slack Status][sl_b]][slack] [![npm version][npm_b]][npm_l] [![Circle CI][circle_b]][circle_l] [![npm downloads][dn_b]][dn_l] [![Coverage Status][cov_b]][cov_l] [![Codacy][cod_b]][cod_l] | ||
# [JSData](http://www.js-data.io/) | ||
Inspired by [Ember Data][ember], __JSData__ is the model layer you've been | ||
craving. It consists of a convenient __framework-agnostic__, __in-memory store__ | ||
for managing your data, which uses __adapters__ to communicate with various | ||
__persistence layers__. | ||
[![Slack Status][sl_b]][slack] | ||
[![npm version][npm_b]][npm_l] | ||
[![Circle CI][circle_b]][circle_l] | ||
[![npm downloads][dn_b]][dn_l] | ||
[![Coverage Status][cov_b]][cov_l] | ||
[![Codacy][cod_b]][cod_l] | ||
The most commonly used adapter is the [http adapter][http], which is perfect for | ||
connecting your frontend to your backend. [localStorage][3], [localForage][4], | ||
[firebase][5] and [other adapters][6] are already available. On the server you | ||
could hook up to the [SQL adapter (Postgres/MySQL/MariaDB/SQLite3)][7] and add | ||
in the [Redis adapter][8] as a caching layer for your read endpoints. More | ||
adapters are coming, and you're free to implement your own. See [Adapters][9]. | ||
JSData is a datastore-agnostic ORM for Node.js and the Browser. | ||
Unlike some libraries, JSData does not require the use of getter and setter | ||
functions, and doesn't decorate your data with a bunch of cruft. | ||
Adapters allow JSData to connect to various datastores such as Firebase, MySql, | ||
RethinkDB, MongoDB, localStorage, Redis, a REST API, etc. With JSData you can | ||
re-use your Models between environments, keep your data layer intact when | ||
transitioning between app frameworks, and work with a unified data API on the | ||
server and the client. JSData employs conventions for rapid development, but | ||
allows for endless customization in order to meet your particular needs. Think | ||
of it as the "Twitter Bootstrap" of JavaScript data layers. | ||
Supporting relations, Node.js and the Browser, model lifecycle control and a | ||
slew of other features, JSData is the tool for [giving your data the respect it deserves][12]. | ||
To get started, check out <http://js-data.io>! | ||
Written in ES6 and built for modern web development, JSData will save you | ||
thousands of lines of code. | ||
## Table of contents | ||
Support is handled via the [Slack channel][slack] or the [Mailing List][ml]. | ||
* [Quick start](#quick-start) | ||
* [Background](#background) | ||
* [Dependencies](#dependencies) | ||
* [Documentation](#documentation) | ||
* [API Reference](#api-reference) | ||
* [Support](#support) | ||
* [Community](#community) | ||
* [Contributing](#contributing) | ||
* [License](#license) | ||
##### Looking for contributors! | ||
## Quick Start | ||
JSData is getting popular and becoming a lot of work for me. I could use help | ||
with tests, documentation, demos/examples, and adapters. Contact me if you wan | ||
to help! jason dot dobry at gmail dot com | ||
##### js-data + http adapter in the Browser | ||
[![MtnWestJS Conf 2015 Presentation][mtn_b]][mtn_l] | ||
### Dependencies | ||
JSData requires the presence of the ES6-spec (ES2015) `Promise` constructor in | ||
the global environment. In the browser, `window.Promise` must be available. In | ||
Node, `global.Promise` must be available. Here is a handy library for | ||
polyfilling: https://github.com/jakearchibald/es6-promise. | ||
### Quick Start | ||
##### For use in a Browser | ||
`npm install --save js-data js-data-http` or `bower install --save js-data js-data-http`. | ||
(You may also substitute `js-data-http` for any one of the other client-side adapters.) | ||
(Substitute `js-data-http` for any one of the other client-side adapters.) | ||
##### For use in Node.js | ||
##### js-data + http adapter in Node.js | ||
`npm install --save js-data axios js-data-http-node` | ||
(You may also substitute `js-data-http-node` for any one of the other server-side adapters.) | ||
(Substitute `axios` and `js-data-http-node` for any one of the other server-side adapters.) | ||
See [installation instructions][inst] for making js-data part of your | ||
See [installation instructions][inst] for making JSData part of your | ||
r.js/browserify/webpack build. | ||
__ES7:__ | ||
__ES2016:__ | ||
```js | ||
```javascript | ||
import {Model, registerAdapter} from 'js-data' | ||
@@ -76,21 +69,16 @@ import DSHttpAdapter from 'js-data-http' | ||
// The user instance is stored in User now | ||
// The user instance is now stored in the User Model's collection | ||
console.log(User.get(user.id)) // { id: 1, name: 'John' } | ||
console.log(user === User.get(user.id)) // true | ||
// No need for another GET request, will resolve immediately | ||
// See http://www.js-data.io/docs/dsfind | ||
user = await User.find(user.id) | ||
user.name = 'Johnny' | ||
console.log(user === User.get(user.id)) // true | ||
// PUT /user/1 {name:"Johnny"} | ||
// See http://www.js-data.io/docs/dsupdate | ||
user = await User.update(user.id, { name: 'Johnny' }) | ||
user = await user.save() | ||
// The user instance stored in User has been updated | ||
// The user instance has been updated | ||
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' } | ||
console.log(user === User.get(user.id)) // true | ||
await User.destroy(user.id) | ||
await user.destroy() | ||
@@ -104,5 +92,5 @@ // The user instance no longer stored in User | ||
__ES6:__ | ||
__ES2015:__ | ||
```js | ||
```javascript | ||
import {Model, registerAdapter} from 'js-data' | ||
@@ -122,21 +110,16 @@ import DSHttpAdapter from 'js-data-http' | ||
// The user instance is stored in User now | ||
// The user instance is now stored in the User Model's collection | ||
console.log(User.get(user.id)) // { id: 1, name: 'John' } | ||
console.log(user === User.get(user.id)) // true | ||
// No need for another GET request, will resolve immediately | ||
// See http://www.js-data.io/docs/dsfind | ||
user = yield User.find(user.id) | ||
user.name = 'Johnny' | ||
console.log(user === User.get(user.id)) // true | ||
// PUT /user/1 {name:"Johnny"} | ||
// See http://www.js-data.io/docs/dsupdate | ||
user = yield User.update(user.id, { name: 'Johnny' }) | ||
user = yield user.save() | ||
// The user instance stored in User has been updated | ||
// The user instance has been updated | ||
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' } | ||
console.log(user === User.get(user.id)) // true | ||
yield User.destroy(user.id) | ||
yield user.destroy() | ||
@@ -152,3 +135,3 @@ // The user instance no longer stored in User | ||
```js | ||
```javascript | ||
var User = JSData.Model.extend({}, { name: 'User' }) | ||
@@ -159,3 +142,2 @@ // register and use http by default for async operations | ||
// Example CRUD operations with default configuration | ||
// See http://www.js-data.io/docs/dsfind | ||
User.find(1) | ||
@@ -166,19 +148,13 @@ .then(function (user) { | ||
// The user instance is stored in User now | ||
// The user instance is now stored in the User Model's collection | ||
console.log(User.get(user.id)) // { id: 1, name: 'John' } | ||
console.log(user === User.get(user.id)) // true | ||
// No need for another GET request, will resolve immediately | ||
// See http://www.js-data.io/docs/dsfind | ||
return User.find(user.id) | ||
}) | ||
.then(function (user) { | ||
console.log(user === User.get(user.id)) // true | ||
user.name = 'Johnny' | ||
// PUT /user/1 {name:"Johnny"} | ||
// See http://www.js-data.io/docs/dsupdate | ||
return User.update(user.id, { name: 'Johnny' }) | ||
return user.save() | ||
}) | ||
.then(function (user) { | ||
// The user instance stored in User has been updated | ||
// The user instance has been updated | ||
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' } | ||
@@ -188,4 +164,3 @@ console.log(user === User.get(user.id)) // true | ||
// DELETE /user/1 | ||
// See http://www.js-data.io/docs/dsdestroy | ||
return User.destroy(user.id) | ||
return user.destroy() | ||
}) | ||
@@ -198,5 +173,37 @@ .then(function () { | ||
All your data are belong to you... | ||
## Background | ||
### Guides | ||
Most ORMs only work with a single datastore. Even when written in JavaScript, | ||
most ORMs only work in Node.js _or_ the Browser. Wouldn't it be nice if you | ||
could use the same ORM on the client as you do on the backend? Wouldn't it be | ||
nice if you could switch databases without having to switch ORMs? Enter | ||
__JSData__. | ||
Originally inspired by the desire to have something like [Ember Data][ember] | ||
that worked in Angular.js and other frameworks, JSData was created. Turns out, | ||
JSData works in Node.js, so server-side adapters were written. JSData is the | ||
Model layer you've been craving. It consists of a convenient | ||
__framework-agnostic__, __datastore-agnostic__ ORM for managing your data, which | ||
uses __adapters__ to connect to various __persistence layers__. | ||
The most commonly used adapter is the [http adapter][http], which is perfect for | ||
connecting your frontend to your backend. [localStorage][3], [localForage][4], | ||
[Firebase][5] and [other adapters][6] are already available. On the server you | ||
could hook up to the [SQL adapter (Postgres/MySQL/MariaDB/SQLite3)][7] or the | ||
[MongoDB][8] adapter. More adapters are coming, and you're free to implement | ||
your own. See [Adapters][9]. | ||
[![MtnWestJS Conf 2015 Presentation][mtn_b]][mtn_l] | ||
### Dependencies | ||
JSData requires the presence of a `Promise` constructor in the global | ||
environment. In the browser, `window.Promise` must be available. In Node.js, | ||
`global.Promise` must be available. Here is a handy library for polyfilling: | ||
https://github.com/jakearchibald/es6-promise. | ||
JSData also requires full ES5 support from the runtime. Here is a handy library | ||
for polyfilling: https://github.com/afarkas/html5shiv | ||
### Documentation | ||
- [Getting Started with js-data](http://www.js-data.io/docs/home) | ||
@@ -214,6 +221,8 @@ - [Resources/Models](http://www.js-data.io/docs/resources) | ||
- [FAQ](http://www.js-data.io/docs/faq) | ||
- [CHANGELOG.md](https://github.com/js-data/js-data/blob/master/CHANGELOG.md) | ||
See an issue with or have a suggestion for the documentation? You can suggest edits right on the documentation pages! (There's a link at the top right of each page.) | ||
See an issue with the documentation? Have something to add? Click the "Suggest | ||
Edits" at the top right of each page and make your suggested changes! | ||
### API Documentation | ||
### API Reference | ||
- [DS](http://www.js-data.io/docs/ds) | ||
@@ -233,11 +242,14 @@ - [Configuration Options](http://www.js-data.io/docs/dsdefaults) | ||
### Changelog | ||
[CHANGELOG.md](https://github.com/js-data/js-data/blob/master/CHANGELOG.md) | ||
### Support | ||
Support questions are handled via [StackOverflow][so], [Slack][slack], and the | ||
[Mailing List][ml]. Ask your questions there. | ||
### Community | ||
- [Slack Channel](http://slack.js-data.io) [![Slack Status][sl_b]][slack] - Better than IRC! | ||
- [StackOverflow Channel][so] | ||
- [Slack Chat][slack] [![Slack Status][sl_b]][slack] | ||
- [Announcements](http://www.js-data.io/blog) | ||
- [Mailing List](ml) - Ask your questions! | ||
- [Issues](https://github.com/js-data/js-data/issues) - Found a bug? Feature request? Submit an issue! | ||
- [GitHub](https://github.com/js-data/js-data) - View the source code for JSData. | ||
- [Mailing List](ml) | ||
- [Issues Tracker](https://github.com/js-data/js-data/issues) | ||
- [GitHub](https://github.com/js-data/js-data) | ||
- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md) | ||
@@ -247,10 +259,7 @@ | ||
First, support is handled via the [Slack Channel][slack] and the | ||
[Mailing List][ml]. Ask your questions there. | ||
When submitting bug reports or feature requests on GitHub, please include _as | ||
much detail as possible_. | ||
When submitting issues on GitHub, please include as much detail as possible to | ||
make debugging quick and easy. | ||
- good - Your versions of Angular, JSData, etc, relevant console logs/error, | ||
code examples that revealed the issue | ||
- good - Your versions of Angular, JSData, etc, relevant console logs, stack | ||
traces, code examples that revealed the issue, etc. | ||
- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or | ||
@@ -261,4 +270,2 @@ [bin](http://jsbin.com/?html,output) that demonstrates the issue | ||
[Github Issues](https://github.com/js-data/js-data/issues). | ||
#### Pull Requests | ||
@@ -283,3 +290,3 @@ | ||
Copyright (c) 2014-2015 Jason Dobry | ||
Copyright (c) 2014-2016 Jason Dobry | ||
@@ -304,3 +311,2 @@ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
[sl_b]: http://slack.js-data.io/badge.svg | ||
@@ -325,3 +331,3 @@ [npm_b]: https://img.shields.io/npm/v/js-data.svg?style=flat | ||
[7]: http://www.js-data.io/docs/dssqladapter | ||
[8]: http://www.js-data.io/docs/dsredisadapter | ||
[8]: http://www.js-data.io/docs/dsmongodbadapter | ||
[9]: http://www.js-data.io/docs/working-with-adapters | ||
@@ -337,2 +343,3 @@ [10]: https://github.com/Polymer/observe-js | ||
[slack]: http://slack.js-data.io | ||
[ml]: https://groups.io/org/groupsio/jsdata | ||
[ml]: https://groups.io/org/groupsio/jsdata | ||
[so]: http://stackoverflow.com/questions/tagged/jsdata |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
736006
10533
329