ember-data-source 2.15.4 → 2.16.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/globals/ember-data.js +206 -540
- data/dist/globals/ember-data.min.js +6 -6
- data/dist/globals/ember-data.prod.js +205 -535
- data/package.json +7 -13
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9028ed814e25a03806793b8a55f5317fd6cf71f
|
4
|
+
data.tar.gz: 628ba272f2c7cf6a5a946d421c6ca3765b9f820a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0b7eadc0bcbca0a335358c177b3f4cf0cf05a4d656ae7a63cdf338fd65204cc9d265c70ff648c2f6fe330328c9f034093f245b2981e659b104525fccecd6aa5
|
7
|
+
data.tar.gz: 2a4395a7905d496f1dbcd84e7262ceb06915b53cb405bac77fbfae4b98b826a4da82d643a2e45b33bd6cb89fc6af9b114138bfb9ecf5d3eae2ae5b678ad89fca
|
data/dist/globals/ember-data.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* @copyright Copyright 2011-2017 Tilde Inc. and contributors.
|
7
7
|
* Portions Copyright 2011 LivingSocial Inc.
|
8
8
|
* @license Licensed under MIT license (see license.js)
|
9
|
-
* @version 2.
|
9
|
+
* @version 2.16.0-beta.1
|
10
10
|
*/
|
11
11
|
|
12
12
|
var loader, define, requireModule, require, requirejs;
|
@@ -14,6 +14,8 @@ var loader, define, requireModule, require, requirejs;
|
|
14
14
|
(function (global) {
|
15
15
|
'use strict';
|
16
16
|
|
17
|
+
var heimdall = global.heimdall;
|
18
|
+
|
17
19
|
function dict() {
|
18
20
|
var obj = Object.create(null);
|
19
21
|
obj['__'] = undefined;
|
@@ -55,9 +57,7 @@ var loader, define, requireModule, require, requirejs;
|
|
55
57
|
}
|
56
58
|
}
|
57
59
|
}
|
58
|
-
}
|
59
|
-
// Option to enable or disable the generation of default exports
|
60
|
-
makeDefaultExport: true
|
60
|
+
}
|
61
61
|
};
|
62
62
|
|
63
63
|
var registry = dict();
|
@@ -107,7 +107,6 @@ var loader, define, requireModule, require, requirejs;
|
|
107
107
|
return this.module.exports;
|
108
108
|
}
|
109
109
|
|
110
|
-
|
111
110
|
if (loader.wrapModules) {
|
112
111
|
this.callback = loader.wrapModules(this.id, this.callback);
|
113
112
|
}
|
@@ -121,9 +120,7 @@ var loader, define, requireModule, require, requirejs;
|
|
121
120
|
if (!(this.hasExportsAsDep && result === undefined)) {
|
122
121
|
this.module.exports = result;
|
123
122
|
}
|
124
|
-
|
125
|
-
this.makeDefaultExport();
|
126
|
-
}
|
123
|
+
this.makeDefaultExport();
|
127
124
|
return this.module.exports;
|
128
125
|
};
|
129
126
|
|
@@ -281,7 +278,6 @@ var loader, define, requireModule, require, requirejs;
|
|
281
278
|
return child;
|
282
279
|
}
|
283
280
|
|
284
|
-
|
285
281
|
var parts = child.split('/');
|
286
282
|
var nameParts = id.split('/');
|
287
283
|
var parentBase = nameParts.slice(0, -1);
|
@@ -403,7 +399,7 @@ define('ember-data/-debug', ['exports', 'ember'], function (exports, _ember) {
|
|
403
399
|
|
404
400
|
exports.assertPolymorphicType = assertPolymorphicType;
|
405
401
|
});
|
406
|
-
define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], function (exports, _ember) {
|
402
|
+
define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember', 'ember-inflector'], function (exports, _ember, _emberInflector) {
|
407
403
|
'use strict';
|
408
404
|
|
409
405
|
exports.__esModule = true;
|
@@ -803,10 +799,11 @@ define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], fun
|
|
803
799
|
endpoint of "/line_items/".
|
804
800
|
```app/adapters/application.js
|
805
801
|
import DS from 'ember-data';
|
802
|
+
import { pluralize } from 'ember-inflector';
|
806
803
|
export default DS.RESTAdapter.extend({
|
807
804
|
pathForType: function(modelName) {
|
808
805
|
var decamelized = Ember.String.decamelize(modelName);
|
809
|
-
return
|
806
|
+
return pluralize(decamelized);
|
810
807
|
}
|
811
808
|
});
|
812
809
|
```
|
@@ -816,7 +813,7 @@ define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], fun
|
|
816
813
|
**/
|
817
814
|
pathForType: function (modelName) {
|
818
815
|
var camelized = _ember.default.String.camelize(modelName);
|
819
|
-
return
|
816
|
+
return (0, _emberInflector.pluralize)(camelized);
|
820
817
|
}
|
821
818
|
});
|
822
819
|
});
|
@@ -1865,7 +1862,7 @@ define('ember-data/-private/system/identity-map', ['exports', 'ember-data/-priva
|
|
1865
1862
|
IdentityMap.prototype.retrieve = function retrieve(modelName) {
|
1866
1863
|
var map = this._map[modelName];
|
1867
1864
|
|
1868
|
-
if (
|
1865
|
+
if (map === undefined) {
|
1869
1866
|
map = this._map[modelName] = new _internalModelMap.default(modelName);
|
1870
1867
|
}
|
1871
1868
|
|
@@ -1927,13 +1924,14 @@ define('ember-data/-private/system/internal-model-map', ['exports', 'ember-data/
|
|
1927
1924
|
}
|
1928
1925
|
|
1929
1926
|
/**
|
1930
|
-
|
1927
|
+
*
|
1928
|
+
* @param id
|
1929
|
+
* @returns {InternalModel}
|
1931
1930
|
*/
|
1932
1931
|
|
1933
1932
|
|
1934
1933
|
InternalModelMap.prototype.get = function get(id) {
|
1935
|
-
|
1936
|
-
return r;
|
1934
|
+
return this._idToModel[id];
|
1937
1935
|
};
|
1938
1936
|
|
1939
1937
|
InternalModelMap.prototype.has = function has(id) {
|
@@ -1962,9 +1960,7 @@ define('ember-data/-private/system/internal-model-map', ['exports', 'ember-data/
|
|
1962
1960
|
};
|
1963
1961
|
|
1964
1962
|
InternalModelMap.prototype.remove = function remove(internalModel, id) {
|
1965
|
-
|
1966
|
-
delete this._idToModel[id];
|
1967
|
-
}
|
1963
|
+
delete this._idToModel[id];
|
1968
1964
|
|
1969
1965
|
var loc = this._models.indexOf(internalModel);
|
1970
1966
|
|
@@ -1978,35 +1974,18 @@ define('ember-data/-private/system/internal-model-map', ['exports', 'ember-data/
|
|
1978
1974
|
};
|
1979
1975
|
|
1980
1976
|
InternalModelMap.prototype.clear = function clear() {
|
1981
|
-
|
1982
|
-
|
1983
|
-
this._models = [];
|
1977
|
+
var models = this._models;
|
1978
|
+
this._models = [];
|
1984
1979
|
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
}
|
1980
|
+
for (var i = 0; i < models.length; i++) {
|
1981
|
+
var model = models[i];
|
1982
|
+
model.unloadRecord();
|
1989
1983
|
}
|
1990
1984
|
|
1991
1985
|
this._metadata = null;
|
1992
1986
|
};
|
1993
1987
|
|
1994
|
-
InternalModelMap.prototype.destroy = function destroy() {
|
1995
|
-
this._store = null;
|
1996
|
-
this._modelClass = null;
|
1997
|
-
};
|
1998
|
-
|
1999
1988
|
_createClass(InternalModelMap, [{
|
2000
|
-
key: 'idToRecord',
|
2001
|
-
get: function () {
|
2002
|
-
(false && !(false) && Ember.deprecate('Use of InternalModelMap.idToRecord is deprecated, use InternalModelMap.get(id) instead.', false, {
|
2003
|
-
id: 'ds.record-map.idToRecord',
|
2004
|
-
until: '2.13'
|
2005
|
-
}));
|
2006
|
-
|
2007
|
-
return this._idToModel;
|
2008
|
-
}
|
2009
|
-
}, {
|
2010
1989
|
key: 'length',
|
2011
1990
|
get: function () {
|
2012
1991
|
return this._models.length;
|
@@ -2305,94 +2284,11 @@ define('ember-data/-private/system/model/errors', ['exports', 'ember'], function
|
|
2305
2284
|
'use strict';
|
2306
2285
|
|
2307
2286
|
exports.__esModule = true;
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
var makeArray = _ember.default.makeArray;
|
2314
|
-
|
2315
|
-
var MapWithDefault = _ember.default.MapWithDefault;
|
2316
|
-
|
2317
|
-
/**
|
2318
|
-
@module ember-data
|
2319
|
-
*/
|
2320
|
-
|
2321
|
-
/**
|
2322
|
-
Holds validation errors for a given record, organized by attribute names.
|
2323
|
-
|
2324
|
-
Every `DS.Model` has an `errors` property that is an instance of
|
2325
|
-
`DS.Errors`. This can be used to display validation error
|
2326
|
-
messages returned from the server when a `record.save()` rejects.
|
2327
|
-
|
2328
|
-
For Example, if you had a `User` model that looked like this:
|
2329
|
-
|
2330
|
-
```app/models/user.js
|
2331
|
-
import DS from 'ember-data';
|
2332
|
-
|
2333
|
-
export default DS.Model.extend({
|
2334
|
-
username: DS.attr('string'),
|
2335
|
-
email: DS.attr('string')
|
2336
|
-
});
|
2337
|
-
```
|
2338
|
-
And you attempted to save a record that did not validate on the backend:
|
2339
|
-
|
2340
|
-
```javascript
|
2341
|
-
let user = store.createRecord('user', {
|
2342
|
-
username: 'tomster',
|
2343
|
-
email: 'invalidEmail'
|
2344
|
-
});
|
2345
|
-
user.save();
|
2346
|
-
```
|
2347
|
-
|
2348
|
-
Your backend would be expected to return an error response that described
|
2349
|
-
the problem, so that error messages can be generated on the app.
|
2350
|
-
|
2351
|
-
API responses will be translated into instances of `DS.Errors` differently,
|
2352
|
-
depending on the specific combination of adapter and serializer used. You
|
2353
|
-
may want to check the documentation or the source code of the libraries
|
2354
|
-
that you are using, to know how they expect errors to be communicated.
|
2355
|
-
|
2356
|
-
Errors can be displayed to the user by accessing their property name
|
2357
|
-
to get an array of all the error objects for that property. Each
|
2358
|
-
error object is a JavaScript object with two keys:
|
2359
|
-
|
2360
|
-
- `message` A string containing the error message from the backend
|
2361
|
-
- `attribute` The name of the property associated with this error message
|
2362
|
-
|
2363
|
-
```handlebars
|
2364
|
-
<label>Username: {{input value=username}} </label>
|
2365
|
-
{{#each model.errors.username as |error|}}
|
2366
|
-
<div class="error">
|
2367
|
-
{{error.message}}
|
2368
|
-
</div>
|
2369
|
-
{{/each}}
|
2370
|
-
|
2371
|
-
<label>Email: {{input value=email}} </label>
|
2372
|
-
{{#each model.errors.email as |error|}}
|
2373
|
-
<div class="error">
|
2374
|
-
{{error.message}}
|
2375
|
-
</div>
|
2376
|
-
{{/each}}
|
2377
|
-
```
|
2378
|
-
|
2379
|
-
You can also access the special `messages` property on the error
|
2380
|
-
object to get an array of all the error strings.
|
2381
|
-
|
2382
|
-
```handlebars
|
2383
|
-
{{#each model.errors.messages as |message|}}
|
2384
|
-
<div class="error">
|
2385
|
-
{{message}}
|
2386
|
-
</div>
|
2387
|
-
{{/each}}
|
2388
|
-
```
|
2389
|
-
|
2390
|
-
@class Errors
|
2391
|
-
@namespace DS
|
2392
|
-
@extends Ember.Object
|
2393
|
-
@uses Ember.Enumerable
|
2394
|
-
@uses Ember.Evented
|
2395
|
-
*/
|
2287
|
+
var get = _ember.default.get,
|
2288
|
+
set = _ember.default.set,
|
2289
|
+
isEmpty = _ember.default.isEmpty,
|
2290
|
+
makeArray = _ember.default.makeArray,
|
2291
|
+
MapWithDefault = _ember.default.MapWithDefault;
|
2396
2292
|
exports.default = _ember.default.ArrayProxy.extend(_ember.default.Evented, {
|
2397
2293
|
/**
|
2398
2294
|
Register with target handler
|
@@ -3066,7 +2962,11 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember', '
|
|
3066
2962
|
this.dematerializeRecord();
|
3067
2963
|
|
3068
2964
|
if (this._scheduledDestroy === null) {
|
3069
|
-
|
2965
|
+
// TODO: use run.schedule once we drop 1.13
|
2966
|
+
if (!_ember.default.run.currentRunLoop) {
|
2967
|
+
(false && _ember.default.assert('You have turned on testing mode, which disabled the run-loop\'s autorun.\n You will need to wrap any code with asynchronous side-effects in a run', _ember.default.testing));
|
2968
|
+
}
|
2969
|
+
this._scheduledDestroy = _ember.default.run.backburner.schedule('destroy', this, '_checkForOrphanedInternalModels');
|
3070
2970
|
}
|
3071
2971
|
};
|
3072
2972
|
|
@@ -4502,7 +4402,7 @@ define('ember-data/-private/system/model/model', ['exports', 'ember', 'ember-dat
|
|
4502
4402
|
} else {
|
4503
4403
|
//No inverse was specified manually, we need to use a heuristic to guess one
|
4504
4404
|
if (propertyMeta.parentType && propertyMeta.type === propertyMeta.parentType.modelName) {
|
4505
|
-
(false && _ember.default.warn('Detected a reflexive relationship by the name of \'' + name + '\' without an inverse option. Look at
|
4405
|
+
(false && _ember.default.warn('Detected a reflexive relationship by the name of \'' + name + '\' without an inverse option. Look at https://emberjs.com/guides/models/defining-models/#toc_reflexive-relation for how to explicitly specify inverses.', false, {
|
4506
4406
|
id: 'ds.model.reflexive-relationship-without-inverse'
|
4507
4407
|
}));
|
4508
4408
|
}
|
@@ -4518,14 +4418,14 @@ define('ember-data/-private/system/model/model', ['exports', 'ember', 'ember-dat
|
|
4518
4418
|
return name === optionsForRelationship.inverse;
|
4519
4419
|
});
|
4520
4420
|
|
4521
|
-
(false && _ember.default.assert("You defined the '" + name + "' relationship on " + this + ", but you defined the inverse relationships of type " + inverseType.toString() + " multiple times. Look at
|
4421
|
+
(false && _ember.default.assert("You defined the '" + name + "' relationship on " + this + ", but you defined the inverse relationships of type " + inverseType.toString() + " multiple times. Look at https://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses", filteredRelationships.length < 2));
|
4522
4422
|
|
4523
4423
|
|
4524
4424
|
if (filteredRelationships.length === 1) {
|
4525
4425
|
possibleRelationships = filteredRelationships;
|
4526
4426
|
}
|
4527
4427
|
|
4528
|
-
(false && _ember.default.assert("You defined the '" + name + "' relationship on " + this + ", but multiple possible inverse relationships of type " + this + " were found on " + inverseType + ". Look at
|
4428
|
+
(false && _ember.default.assert("You defined the '" + name + "' relationship on " + this + ", but multiple possible inverse relationships of type " + this + " were found on " + inverseType + ". Look at https://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses", possibleRelationships.length === 1));
|
4529
4429
|
|
4530
4430
|
|
4531
4431
|
inverseName = possibleRelationships[0].name;
|
@@ -4902,10 +4802,6 @@ define('ember-data/-private/system/model/model', ['exports', 'ember', 'ember-dat
|
|
4902
4802
|
// the computed property.
|
4903
4803
|
var meta = value.meta();
|
4904
4804
|
|
4905
|
-
/*
|
4906
|
-
This is buggy because if the parent has never been looked up
|
4907
|
-
via `modelFor` it will not have `modelName` set.
|
4908
|
-
*/
|
4909
4805
|
meta.parentType = proto.constructor;
|
4910
4806
|
}
|
4911
4807
|
}
|
@@ -6180,7 +6076,7 @@ define("ember-data/-private/system/record-array-manager", ["exports", "ember", "
|
|
6180
6076
|
|
6181
6077
|
RecordArrayManager.prototype.destroy = function destroy() {
|
6182
6078
|
this.isDestroying = true;
|
6183
|
-
|
6079
|
+
emberRun.schedule('actions', this, this.willDestroy);
|
6184
6080
|
};
|
6185
6081
|
|
6186
6082
|
return RecordArrayManager;
|
@@ -6985,6 +6881,7 @@ define('ember-data/-private/system/references/belongs-to', ['exports', 'ember-da
|
|
6985
6881
|
userRef.load().then(function(user) {
|
6986
6882
|
userRef.value() === user
|
6987
6883
|
});
|
6884
|
+
```
|
6988
6885
|
|
6989
6886
|
@method load
|
6990
6887
|
@return {Promise} a promise that resolves with the record in this belongs-to relationship.
|
@@ -7033,6 +6930,7 @@ define('ember-data/-private/system/references/belongs-to', ['exports', 'ember-da
|
|
7033
6930
|
userRef.reload().then(function(user) {
|
7034
6931
|
userRef.value() === user
|
7035
6932
|
});
|
6933
|
+
```
|
7036
6934
|
|
7037
6935
|
@method reload
|
7038
6936
|
@return {Promise} a promise that resolves with the record in this belongs-to relationship after the reload has completed.
|
@@ -7360,7 +7258,7 @@ define('ember-data/-private/system/references/has-many', ['exports', 'ember', 'e
|
|
7360
7258
|
};
|
7361
7259
|
|
7362
7260
|
/**
|
7363
|
-
`value()`
|
7261
|
+
`value()` synchronously returns the current value of the has-many
|
7364
7262
|
relationship. Unlike `record.get('relationshipName')`, calling
|
7365
7263
|
`value()` on a reference does not trigger a fetch if the async
|
7366
7264
|
relationship is not yet loaded. If the relationship is not loaded
|
@@ -7693,7 +7591,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7693
7591
|
}
|
7694
7592
|
|
7695
7593
|
function relationshipFromMeta(meta) {
|
7696
|
-
|
7594
|
+
var result = {
|
7697
7595
|
key: meta.key,
|
7698
7596
|
kind: meta.kind,
|
7699
7597
|
type: typeForRelationshipMeta(meta),
|
@@ -7702,6 +7600,12 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7702
7600
|
parentType: meta.parentType,
|
7703
7601
|
isRelationship: true
|
7704
7602
|
};
|
7603
|
+
|
7604
|
+
if (false) {
|
7605
|
+
result.parentType = meta.parentType;
|
7606
|
+
}
|
7607
|
+
|
7608
|
+
return result;
|
7705
7609
|
}
|
7706
7610
|
});
|
7707
7611
|
define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember', 'ember-data/-private/system/normalize-model-name'], function (exports, _ember, _normalizeModelName) {
|
@@ -7815,13 +7719,13 @@ define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember
|
|
7815
7719
|
return _ember.default.computed({
|
7816
7720
|
get: function (key) {
|
7817
7721
|
if (opts.hasOwnProperty('serialize')) {
|
7818
|
-
(false && _ember.default.warn('You provided a serialize option on the "' + key + '" property in the "' + this._internalModel.modelName + '" class, this belongs in the serializer. See DS.Serializer and it\'s implementations
|
7722
|
+
(false && _ember.default.warn('You provided a serialize option on the "' + key + '" property in the "' + this._internalModel.modelName + '" class, this belongs in the serializer. See DS.Serializer and it\'s implementations https://emberjs.com/api/data/classes/DS.Serializer.html', false, {
|
7819
7723
|
id: 'ds.model.serialize-option-in-belongs-to'
|
7820
7724
|
}));
|
7821
7725
|
}
|
7822
7726
|
|
7823
7727
|
if (opts.hasOwnProperty('embedded')) {
|
7824
|
-
(false && _ember.default.warn('You provided an embedded option on the "' + key + '" property in the "' + this._internalModel.modelName + '" class, this belongs in the serializer. See DS.EmbeddedRecordsMixin
|
7728
|
+
(false && _ember.default.warn('You provided an embedded option on the "' + key + '" property in the "' + this._internalModel.modelName + '" class, this belongs in the serializer. See DS.EmbeddedRecordsMixin https://emberjs.com/api/data/classes/DS.EmbeddedRecordsMixin.html', false, {
|
7825
7729
|
id: 'ds.model.embedded-option-in-belongs-to'
|
7826
7730
|
}));
|
7827
7731
|
}
|
@@ -8107,8 +8011,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8107
8011
|
}
|
8108
8012
|
}
|
8109
8013
|
|
8110
|
-
var
|
8111
|
-
var assert = _ember.default.assert;
|
8014
|
+
var _get = _ember.default.get;
|
8112
8015
|
|
8113
8016
|
/**
|
8114
8017
|
Manages relationship payloads for a given store, for uninitialized
|
@@ -8171,7 +8074,6 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8171
8074
|
this._store = store;
|
8172
8075
|
// cache of `RelationshipPayload`s
|
8173
8076
|
this._cache = Object.create(null);
|
8174
|
-
this._inverseLookupCache = new _relationshipPayloads.TypeCache();
|
8175
8077
|
}
|
8176
8078
|
|
8177
8079
|
/**
|
@@ -8192,7 +8094,9 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8192
8094
|
|
8193
8095
|
|
8194
8096
|
RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
|
8195
|
-
var
|
8097
|
+
var modelClass = this._store._modelFor(modelName);
|
8098
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8099
|
+
var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8196
8100
|
return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
|
8197
8101
|
};
|
8198
8102
|
|
@@ -8203,8 +8107,10 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8203
8107
|
return;
|
8204
8108
|
}
|
8205
8109
|
|
8110
|
+
var modelClass = this._store._modelFor(modelName);
|
8111
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8206
8112
|
Object.keys(relationshipsData).forEach(function (key) {
|
8207
|
-
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
|
8113
|
+
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
|
8208
8114
|
if (relationshipPayloads) {
|
8209
8115
|
relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
|
8210
8116
|
}
|
@@ -8215,153 +8121,51 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8215
8121
|
var _this2 = this;
|
8216
8122
|
|
8217
8123
|
var modelClass = this._store._modelFor(modelName);
|
8218
|
-
var relationshipsByName =
|
8124
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8219
8125
|
relationshipsByName.forEach(function (_, relationshipName) {
|
8220
|
-
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
|
8126
|
+
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8221
8127
|
if (relationshipPayloads) {
|
8222
8128
|
relationshipPayloads.unload(modelName, id, relationshipName);
|
8223
8129
|
}
|
8224
8130
|
});
|
8225
8131
|
};
|
8226
8132
|
|
8227
|
-
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
|
8228
|
-
|
8229
|
-
|
8230
|
-
if (relInfo === null) {
|
8133
|
+
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
|
8134
|
+
if (!relationshipsByName.has(relationshipName)) {
|
8231
8135
|
return;
|
8232
8136
|
}
|
8233
8137
|
|
8234
|
-
var
|
8235
|
-
|
8236
|
-
|
8237
|
-
return this._initializeRelationshipPayloads(relInfo);
|
8138
|
+
var key = modelName + ':' + relationshipName;
|
8139
|
+
if (!this._cache[key] && init) {
|
8140
|
+
return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
|
8238
8141
|
}
|
8239
8142
|
|
8240
|
-
return
|
8143
|
+
return this._cache[key];
|
8241
8144
|
};
|
8242
8145
|
|
8243
|
-
RelationshipPayloadsManager.prototype.
|
8244
|
-
var inverseCache = this._inverseLookupCache;
|
8245
|
-
var store = this._store;
|
8246
|
-
var cached = inverseCache.get(modelName, relationshipName);
|
8247
|
-
|
8248
|
-
// CASE: We have a cached resolution (null if no relationship exists)
|
8249
|
-
if (cached !== undefined) {
|
8250
|
-
return cached;
|
8251
|
-
}
|
8252
|
-
|
8253
|
-
var modelClass = store._modelFor(modelName);
|
8254
|
-
var relationshipsByName = get(modelClass, 'relationshipsByName');
|
8255
|
-
|
8256
|
-
// CASE: We don't have a relationship at all
|
8257
|
-
if (!relationshipsByName.has(relationshipName)) {
|
8258
|
-
inverseCache.set(modelName, relationshipName, null);
|
8259
|
-
return null;
|
8260
|
-
}
|
8261
|
-
|
8262
|
-
var inverseMeta = modelClass.inverseFor(relationshipName, store);
|
8146
|
+
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
|
8263
8147
|
var relationshipMeta = relationshipsByName.get(relationshipName);
|
8264
|
-
var
|
8265
|
-
|
8266
|
-
|
8267
|
-
|
8268
|
-
|
8269
|
-
|
8270
|
-
|
8271
|
-
|
8272
|
-
|
8273
|
-
|
8274
|
-
|
8275
|
-
|
8276
|
-
|
8277
|
-
|
8278
|
-
|
8279
|
-
|
8280
|
-
|
8281
|
-
rhs_isPolymorphic: false,
|
8282
|
-
hasInverse: false,
|
8283
|
-
isSelfReferential: false, // modelName === inverseBaseModelName,
|
8284
|
-
isReflexive: false
|
8285
|
-
};
|
8286
|
-
|
8287
|
-
inverseCache.set(modelName, relationshipName, _info);
|
8288
|
-
|
8289
|
-
return _info;
|
8290
|
-
}
|
8291
|
-
|
8292
|
-
// CASE: We do have an inverse
|
8293
|
-
|
8294
|
-
var inverseRelationshipName = inverseMeta.name;
|
8295
|
-
var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8296
|
-
var baseModelName = inverseRelationshipMeta.type;
|
8297
|
-
var isSelfReferential = baseModelName === inverseBaseModelName;
|
8298
|
-
|
8299
|
-
// TODO we want to assert this but this breaks all of our shoddily written tests
|
8300
|
-
/*
|
8301
|
-
if (DEBUG) {
|
8302
|
-
let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
|
8303
|
-
assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
|
8148
|
+
var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
|
8149
|
+
|
8150
|
+
var inverseModelName = void 0;
|
8151
|
+
var inverseRelationshipName = void 0;
|
8152
|
+
var inverseRelationshipMeta = void 0;
|
8153
|
+
|
8154
|
+
// figure out the inverse relationship; we need two things
|
8155
|
+
// a) the inverse model name
|
8156
|
+
//- b) the name of the inverse relationship
|
8157
|
+
if (inverseMeta) {
|
8158
|
+
inverseRelationshipName = inverseMeta.name;
|
8159
|
+
inverseModelName = relationshipMeta.type;
|
8160
|
+
inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8161
|
+
} else {
|
8162
|
+
// relationship has no inverse
|
8163
|
+
inverseModelName = inverseRelationshipName = '';
|
8164
|
+
inverseRelationshipMeta = null;
|
8304
8165
|
}
|
8305
|
-
*/
|
8306
8166
|
|
8307
|
-
|
8308
|
-
|
8309
|
-
cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
|
8310
|
-
if (cached) {
|
8311
|
-
// TODO this assert can be removed if the above assert is enabled
|
8312
|
-
assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false);
|
8313
|
-
|
8314
|
-
var isLHS = cached.lhs_baseModelName === baseModelName;
|
8315
|
-
var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
|
8316
|
-
// make this lookup easier in the future by caching the key
|
8317
|
-
modelNames.push(modelName);
|
8318
|
-
inverseCache.set(modelName, relationshipName, cached);
|
8319
|
-
|
8320
|
-
return cached;
|
8321
|
-
}
|
8322
|
-
|
8323
|
-
var info = {
|
8324
|
-
lhs_key: baseModelName + ':' + relationshipName,
|
8325
|
-
lhs_modelNames: [modelName],
|
8326
|
-
lhs_baseModelName: baseModelName,
|
8327
|
-
lhs_relationshipName: relationshipName,
|
8328
|
-
lhs_relationshipMeta: relationshipMeta,
|
8329
|
-
lhs_isPolymorphic: selfIsPolymorphic,
|
8330
|
-
rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
|
8331
|
-
rhs_modelNames: [],
|
8332
|
-
rhs_baseModelName: inverseBaseModelName,
|
8333
|
-
rhs_relationshipName: inverseRelationshipName,
|
8334
|
-
rhs_relationshipMeta: inverseRelationshipMeta,
|
8335
|
-
rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
|
8336
|
-
hasInverse: true,
|
8337
|
-
isSelfReferential: isSelfReferential,
|
8338
|
-
isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
|
8339
|
-
};
|
8340
|
-
|
8341
|
-
// Create entries for the baseModelName as well as modelName to speed up
|
8342
|
-
// inverse lookups
|
8343
|
-
inverseCache.set(baseModelName, relationshipName, info);
|
8344
|
-
inverseCache.set(modelName, relationshipName, info);
|
8345
|
-
|
8346
|
-
// Greedily populate the inverse
|
8347
|
-
inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
|
8348
|
-
|
8349
|
-
return info;
|
8350
|
-
};
|
8351
|
-
|
8352
|
-
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
|
8353
|
-
var lhsKey = relInfo.lhs_key;
|
8354
|
-
var rhsKey = relInfo.rhs_key;
|
8355
|
-
var existingPayloads = this._cache[lhsKey];
|
8356
|
-
|
8357
|
-
if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
|
8358
|
-
existingPayloads = this._cache[rhsKey];
|
8359
|
-
|
8360
|
-
if (existingPayloads !== undefined) {
|
8361
|
-
this._cache[lhsKey] = existingPayloads;
|
8362
|
-
return existingPayloads;
|
8363
|
-
}
|
8364
|
-
}
|
8167
|
+
var lhsKey = modelName + ':' + relationshipName;
|
8168
|
+
var rhsKey = inverseModelName + ':' + inverseRelationshipName;
|
8365
8169
|
|
8366
8170
|
// populate the cache for both sides of the relationship, as they both use
|
8367
8171
|
// the same `RelationshipPayloads`.
|
@@ -8369,13 +8173,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8369
8173
|
// This works out better than creating a single common key, because to
|
8370
8174
|
// compute that key we would need to do work to look up the inverse
|
8371
8175
|
//
|
8372
|
-
|
8373
|
-
|
8374
|
-
if (relInfo.hasInverse === true) {
|
8375
|
-
this._cache[rhsKey] = cache;
|
8376
|
-
}
|
8377
|
-
|
8378
|
-
return cache;
|
8176
|
+
return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
|
8379
8177
|
};
|
8380
8178
|
|
8381
8179
|
return RelationshipPayloadsManager;
|
@@ -8388,6 +8186,12 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8388
8186
|
|
8389
8187
|
exports.__esModule = true;
|
8390
8188
|
|
8189
|
+
function _classCallCheck(instance, Constructor) {
|
8190
|
+
if (!(instance instanceof Constructor)) {
|
8191
|
+
throw new TypeError("Cannot call a class as a function");
|
8192
|
+
}
|
8193
|
+
}
|
8194
|
+
|
8391
8195
|
var _createClass = function () {
|
8392
8196
|
function defineProperties(target, props) {
|
8393
8197
|
for (var i = 0; i < props.length; i++) {
|
@@ -8406,61 +8210,37 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8406
8210
|
};
|
8407
8211
|
}();
|
8408
8212
|
|
8409
|
-
function _classCallCheck(instance, Constructor) {
|
8410
|
-
if (!(instance instanceof Constructor)) {
|
8411
|
-
throw new TypeError("Cannot call a class as a function");
|
8412
|
-
}
|
8413
|
-
}
|
8414
|
-
|
8415
|
-
var TypeCache = exports.TypeCache = function () {
|
8416
|
-
function TypeCache() {
|
8417
|
-
_classCallCheck(this, TypeCache);
|
8418
|
-
|
8419
|
-
this.types = Object.create(null);
|
8420
|
-
}
|
8421
|
-
|
8422
|
-
TypeCache.prototype.get = function get(modelName, id) {
|
8423
|
-
var types = this.types;
|
8424
|
-
|
8425
|
-
|
8426
|
-
if (types[modelName] !== undefined) {
|
8427
|
-
return types[modelName][id];
|
8428
|
-
}
|
8429
|
-
};
|
8430
|
-
|
8431
|
-
TypeCache.prototype.set = function set(modelName, id, payload) {
|
8432
|
-
var types = this.types;
|
8433
|
-
|
8434
|
-
var typeMap = types[modelName];
|
8435
|
-
|
8436
|
-
if (typeMap === undefined) {
|
8437
|
-
typeMap = types[modelName] = Object.create(null);
|
8438
|
-
}
|
8439
|
-
|
8440
|
-
typeMap[id] = payload;
|
8441
|
-
};
|
8442
|
-
|
8443
|
-
TypeCache.prototype.delete = function _delete(modelName, id) {
|
8444
|
-
var types = this.types;
|
8445
|
-
|
8446
|
-
|
8447
|
-
if (types[modelName] !== undefined) {
|
8448
|
-
delete types[modelName][id];
|
8449
|
-
}
|
8450
|
-
};
|
8451
|
-
|
8452
|
-
return TypeCache;
|
8453
|
-
}();
|
8454
|
-
|
8455
8213
|
var RelationshipPayloads = function () {
|
8456
|
-
function RelationshipPayloads(
|
8214
|
+
function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
|
8457
8215
|
_classCallCheck(this, RelationshipPayloads);
|
8458
8216
|
|
8459
|
-
this.
|
8217
|
+
this._store = store;
|
8218
|
+
|
8219
|
+
this._lhsModelName = modelName;
|
8220
|
+
this._lhsRelationshipName = relationshipName;
|
8221
|
+
this._lhsRelationshipMeta = relationshipMeta;
|
8222
|
+
|
8223
|
+
this._rhsModelName = inverseModelName;
|
8224
|
+
this._rhsRelationshipName = inverseRelationshipName;
|
8225
|
+
this._rhsRelationshipMeta = inverseRelationshipMeta;
|
8460
8226
|
|
8461
8227
|
// a map of id -> payloads for the left hand side of the relationship.
|
8462
|
-
this.
|
8463
|
-
|
8228
|
+
this._lhsPayloads = Object.create(null);
|
8229
|
+
if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
|
8230
|
+
// The common case of a non-reflexive relationship, or a reflexive
|
8231
|
+
// relationship whose inverse is not itself
|
8232
|
+
this._rhsPayloads = Object.create(null);
|
8233
|
+
this._isReflexive = false;
|
8234
|
+
} else {
|
8235
|
+
// Edge case when we have a reflexive relationship to itself
|
8236
|
+
// eg user hasMany friends inverse friends
|
8237
|
+
//
|
8238
|
+
// In this case there aren't really two sides to the relationship, but
|
8239
|
+
// we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
|
8240
|
+
// about
|
8241
|
+
this._rhsPayloads = this._lhsPayloads;
|
8242
|
+
this._isReflexive = true;
|
8243
|
+
}
|
8464
8244
|
|
8465
8245
|
// When we push relationship payloads, just stash them in a queue until
|
8466
8246
|
// somebody actually asks for one of them.
|
@@ -8471,22 +8251,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8471
8251
|
}
|
8472
8252
|
|
8473
8253
|
/**
|
8474
|
-
|
8475
|
-
|
8476
|
-
|
8477
|
-
|
8478
|
-
|
8254
|
+
Get the payload for the relationship of an individual record.
|
8255
|
+
This might return the raw payload as pushed into the store, or one computed
|
8256
|
+
from the payload of the inverse relationship.
|
8257
|
+
@method
|
8258
|
+
*/
|
8479
8259
|
|
8480
8260
|
|
8481
8261
|
RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
|
8482
8262
|
this._flushPending();
|
8483
8263
|
|
8484
8264
|
if (this._isLHS(modelName, relationshipName)) {
|
8485
|
-
return this.
|
8265
|
+
return this._lhsPayloads[id];
|
8486
8266
|
} else {
|
8487
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8267
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8488
8268
|
|
8489
|
-
return this.
|
8269
|
+
return this._rhsPayloads[id];
|
8490
8270
|
}
|
8491
8271
|
};
|
8492
8272
|
|
@@ -8498,40 +8278,20 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8498
8278
|
this._flushPending();
|
8499
8279
|
|
8500
8280
|
if (this._isLHS(modelName, relationshipName)) {
|
8501
|
-
delete this.
|
8281
|
+
delete this._lhsPayloads[id];
|
8502
8282
|
} else {
|
8503
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8283
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8504
8284
|
|
8505
|
-
delete this.
|
8285
|
+
delete this._rhsPayloads[id];
|
8506
8286
|
}
|
8507
8287
|
};
|
8508
8288
|
|
8509
8289
|
RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
|
8510
|
-
|
8511
|
-
var isSelfReferential = relInfo.isSelfReferential;
|
8512
|
-
var isRelationship = relationshipName === relInfo.lhs_relationshipName;
|
8513
|
-
|
8514
|
-
if (isRelationship === true) {
|
8515
|
-
return isSelfReferential === true || // itself
|
8516
|
-
modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
|
8517
|
-
relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8518
|
-
}
|
8519
|
-
|
8520
|
-
return false;
|
8290
|
+
return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
|
8521
8291
|
};
|
8522
8292
|
|
8523
8293
|
RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
|
8524
|
-
|
8525
|
-
var isSelfReferential = relInfo.isSelfReferential;
|
8526
|
-
var isRelationship = relationshipName === relInfo.rhs_relationshipName;
|
8527
|
-
|
8528
|
-
if (isRelationship === true) {
|
8529
|
-
return isSelfReferential === true || // itself
|
8530
|
-
modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
|
8531
|
-
relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8532
|
-
}
|
8533
|
-
|
8534
|
-
return false;
|
8294
|
+
return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
|
8535
8295
|
};
|
8536
8296
|
|
8537
8297
|
RelationshipPayloads.prototype._flushPending = function _flushPending() {
|
@@ -8552,28 +8312,26 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8552
8312
|
id: id,
|
8553
8313
|
type: modelName
|
8554
8314
|
}
|
8555
|
-
};
|
8556
8315
|
|
8557
|
-
|
8558
|
-
|
8559
|
-
|
8560
|
-
|
8561
|
-
var previousPayload = void 0;
|
8562
|
-
var
|
8563
|
-
var
|
8316
|
+
// start flushing this individual payload. The logic is the same whether
|
8317
|
+
// it's for the left hand side of the relationship or the right hand side,
|
8318
|
+
// except the role of primary and inverse idToPayloads is reversed
|
8319
|
+
//
|
8320
|
+
};var previousPayload = void 0;
|
8321
|
+
var idToPayloads = void 0;
|
8322
|
+
var inverseIdToPayloads = void 0;
|
8564
8323
|
var inverseIsMany = void 0;
|
8565
|
-
|
8566
8324
|
if (this._isLHS(modelName, relationshipName)) {
|
8567
|
-
previousPayload = this.
|
8568
|
-
|
8569
|
-
|
8325
|
+
previousPayload = this._lhsPayloads[id];
|
8326
|
+
idToPayloads = this._lhsPayloads;
|
8327
|
+
inverseIdToPayloads = this._rhsPayloads;
|
8570
8328
|
inverseIsMany = this._rhsRelationshipIsMany;
|
8571
8329
|
} else {
|
8572
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8330
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8573
8331
|
|
8574
|
-
previousPayload = this.
|
8575
|
-
|
8576
|
-
|
8332
|
+
previousPayload = this._rhsPayloads[id];
|
8333
|
+
idToPayloads = this._rhsPayloads;
|
8334
|
+
inverseIdToPayloads = this._lhsPayloads;
|
8577
8335
|
inverseIsMany = this._lhsRelationshipIsMany;
|
8578
8336
|
}
|
8579
8337
|
|
@@ -8617,14 +8375,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8617
8375
|
// * undefined is NOT considered new information, we should keep original state
|
8618
8376
|
// * anything else is considered new information, and it should win
|
8619
8377
|
if (relationshipData.data !== undefined) {
|
8620
|
-
this._removeInverse(id, previousPayload,
|
8378
|
+
this._removeInverse(id, previousPayload, inverseIdToPayloads);
|
8621
8379
|
}
|
8622
|
-
|
8623
|
-
this._populateInverse(relationshipData, inverseRelationshipData,
|
8380
|
+
idToPayloads[id] = relationshipData;
|
8381
|
+
this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
|
8624
8382
|
}
|
8625
8383
|
};
|
8626
8384
|
|
8627
|
-
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload,
|
8385
|
+
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
|
8628
8386
|
if (!relationshipData.data) {
|
8629
8387
|
// This id doesn't have an inverse, eg a belongsTo with a payload
|
8630
8388
|
// { data: null }, so there's nothing to populate
|
@@ -8633,24 +8391,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8633
8391
|
|
8634
8392
|
if (Array.isArray(relationshipData.data)) {
|
8635
8393
|
for (var i = 0; i < relationshipData.data.length; ++i) {
|
8636
|
-
var
|
8637
|
-
this._addToInverse(inversePayload,
|
8394
|
+
var inverseId = relationshipData.data[i].id;
|
8395
|
+
this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
|
8638
8396
|
}
|
8639
8397
|
} else {
|
8640
|
-
var
|
8641
|
-
this._addToInverse(inversePayload,
|
8398
|
+
var _inverseId = relationshipData.data.id;
|
8399
|
+
this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
|
8642
8400
|
}
|
8643
8401
|
};
|
8644
8402
|
|
8645
|
-
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload,
|
8646
|
-
|
8647
|
-
|
8648
|
-
if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
|
8403
|
+
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
|
8404
|
+
if (this._isReflexive && inversePayload.data.id === inverseId) {
|
8649
8405
|
// eg <user:1>.friends = [{ id: 1, type: 'user' }]
|
8650
8406
|
return;
|
8651
8407
|
}
|
8652
8408
|
|
8653
|
-
var existingPayload =
|
8409
|
+
var existingPayload = inverseIdToPayloads[inverseId];
|
8654
8410
|
var existingData = existingPayload && existingPayload.data;
|
8655
8411
|
|
8656
8412
|
if (existingData) {
|
@@ -8660,22 +8416,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8660
8416
|
if (Array.isArray(existingData)) {
|
8661
8417
|
existingData.push(inversePayload.data);
|
8662
8418
|
} else {
|
8663
|
-
|
8419
|
+
inverseIdToPayloads[inverseId] = inversePayload;
|
8664
8420
|
}
|
8665
8421
|
} else {
|
8666
8422
|
// first time we're populating the inverse side
|
8667
8423
|
//
|
8668
8424
|
if (inverseIsMany) {
|
8669
|
-
|
8425
|
+
inverseIdToPayloads[inverseId] = {
|
8670
8426
|
data: [inversePayload.data]
|
8671
|
-
}
|
8427
|
+
};
|
8672
8428
|
} else {
|
8673
|
-
|
8429
|
+
inverseIdToPayloads[inverseId] = inversePayload;
|
8674
8430
|
}
|
8675
8431
|
}
|
8676
8432
|
};
|
8677
8433
|
|
8678
|
-
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload,
|
8434
|
+
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
|
8679
8435
|
var data = previousPayload && previousPayload.data;
|
8680
8436
|
if (!data) {
|
8681
8437
|
// either this is the first time we've seen a payload for this id, or its
|
@@ -8690,16 +8446,15 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8690
8446
|
if (Array.isArray(data)) {
|
8691
8447
|
// TODO: diff rather than removeall addall?
|
8692
8448
|
for (var i = 0; i < data.length; ++i) {
|
8693
|
-
|
8694
|
-
this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
|
8449
|
+
this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
|
8695
8450
|
}
|
8696
8451
|
} else {
|
8697
|
-
this._removeFromInverse(id, data,
|
8452
|
+
this._removeFromInverse(id, data.id, inverseIdToPayloads);
|
8698
8453
|
}
|
8699
8454
|
};
|
8700
8455
|
|
8701
|
-
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id,
|
8702
|
-
var inversePayload = inversePayloads
|
8456
|
+
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
|
8457
|
+
var inversePayload = inversePayloads[inverseId];
|
8703
8458
|
var data = inversePayload && inversePayload.data;
|
8704
8459
|
|
8705
8460
|
if (!data) {
|
@@ -8711,23 +8466,21 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8711
8466
|
return x.id !== id;
|
8712
8467
|
});
|
8713
8468
|
} else {
|
8714
|
-
inversePayloads
|
8469
|
+
inversePayloads[inverseId] = {
|
8715
8470
|
data: null
|
8716
|
-
}
|
8471
|
+
};
|
8717
8472
|
}
|
8718
8473
|
};
|
8719
8474
|
|
8720
8475
|
_createClass(RelationshipPayloads, [{
|
8721
8476
|
key: '_lhsRelationshipIsMany',
|
8722
8477
|
get: function () {
|
8723
|
-
|
8724
|
-
return meta !== null && meta.kind === 'hasMany';
|
8478
|
+
return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
|
8725
8479
|
}
|
8726
8480
|
}, {
|
8727
8481
|
key: '_rhsRelationshipIsMany',
|
8728
8482
|
get: function () {
|
8729
|
-
|
8730
|
-
return meta !== null && meta.kind === 'hasMany';
|
8483
|
+
return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
|
8731
8484
|
}
|
8732
8485
|
}]);
|
8733
8486
|
|
@@ -9183,7 +8936,7 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
|
|
9183
8936
|
}
|
9184
8937
|
this.__loadingPromise.set('promise', promise);
|
9185
8938
|
} else {
|
9186
|
-
this.__loadingPromise =
|
8939
|
+
this.__loadingPromise = _promiseProxies.PromiseManyArray.create({
|
9187
8940
|
promise: promise,
|
9188
8941
|
content: content
|
9189
8942
|
});
|
@@ -9380,6 +9133,7 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
|
|
9380
9133
|
_this2.store._backburner.join(function () {
|
9381
9134
|
_this2.updateInternalModelsFromAdapter(records);
|
9382
9135
|
_this2.manyArray.set('isLoaded', true);
|
9136
|
+
_this2.setHasData(true);
|
9383
9137
|
});
|
9384
9138
|
return _this2.manyArray;
|
9385
9139
|
});
|
@@ -9827,6 +9581,7 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
|
|
9827
9581
|
};
|
9828
9582
|
|
9829
9583
|
Relationship.prototype.updateInternalModelsFromAdapter = function updateInternalModelsFromAdapter(internalModels) {
|
9584
|
+
this.setHasData(true);
|
9830
9585
|
//TODO(Igor) move this to a proper place
|
9831
9586
|
//TODO Once we have adapter support, we need to handle updated and canonical changes
|
9832
9587
|
this.computeChanges(internalModels);
|
@@ -10289,16 +10044,16 @@ define("ember-data/-private/system/snapshot", ["exports", "ember"], function (ex
|
|
10289
10044
|
|
10290
10045
|
exports.default = Snapshot;
|
10291
10046
|
});
|
10292
|
-
define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/model/model', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/system/identity-map', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/store/finders', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/store/container-instance-cache', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/features'], function (exports, _ember, _errors, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _containerInstanceCache, _internalModel5, _features) {
|
10047
|
+
define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-private/adapters/errors', 'ember-data/-debug', 'ember-data/-private/system/model/model', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/system/identity-map', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/store/finders', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/store/container-instance-cache', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/features'], function (exports, _ember, _errors, _debug, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _containerInstanceCache, _internalModel5, _features) {
|
10293
10048
|
'use strict';
|
10294
10049
|
|
10295
10050
|
exports.__esModule = true;
|
10296
10051
|
exports.Store = undefined;
|
10052
|
+
/**
|
10053
|
+
@module ember-data
|
10054
|
+
*/
|
10297
10055
|
|
10298
|
-
|
10299
|
-
var badIdFormatAssertion = '`id` passed to `findRecord()` has to be non-empty string or number'; /**
|
10300
|
-
@module ember-data
|
10301
|
-
*/
|
10056
|
+
var badIdFormatAssertion = '`id` passed to `findRecord()` has to be non-empty string or number';
|
10302
10057
|
|
10303
10058
|
var A = _ember.default.A,
|
10304
10059
|
Backburner = _ember.default._Backburner,
|
@@ -10411,7 +10166,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
10411
10166
|
|
10412
10167
|
Note: When creating a new record using any of the above methods
|
10413
10168
|
Ember Data will update `DS.RecordArray`s such as those returned by
|
10414
|
-
`store#peekAll()
|
10169
|
+
`store#peekAll()` or `store#findAll()`. This means any
|
10415
10170
|
data bindings or computed properties that depend on the RecordArray
|
10416
10171
|
will automatically be synced to include the new or updated record
|
10417
10172
|
values.
|
@@ -10809,7 +10564,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
10809
10564
|
See [peekRecord](#method_peekRecord) to get the cached version of a record.
|
10810
10565
|
### Retrieving Related Model Records
|
10811
10566
|
If you use an adapter such as Ember's default
|
10812
|
-
[`JSONAPIAdapter`](
|
10567
|
+
[`JSONAPIAdapter`](https://emberjs.com/api/data/classes/DS.JSONAPIAdapter.html)
|
10813
10568
|
that supports the [JSON API specification](http://jsonapi.org/) and if your server
|
10814
10569
|
endpoint supports the use of an
|
10815
10570
|
['include' query parameter](http://jsonapi.org/format/#fetching-includes),
|
@@ -11380,7 +11135,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
11380
11135
|
Parameters: { "ids" => ["1", "2", "3"] }
|
11381
11136
|
```
|
11382
11137
|
This method returns a promise, which is resolved with an
|
11383
|
-
[`AdapterPopulatedRecordArray`](
|
11138
|
+
[`AdapterPopulatedRecordArray`](https://emberjs.com/api/data/classes/DS.AdapterPopulatedRecordArray.html)
|
11384
11139
|
once the server returns.
|
11385
11140
|
@since 1.13.0
|
11386
11141
|
@method query
|
@@ -11631,7 +11386,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
11631
11386
|
store, without waiting until a reload is finished.
|
11632
11387
|
### Retrieving Related Model Records
|
11633
11388
|
If you use an adapter such as Ember's default
|
11634
|
-
[`JSONAPIAdapter`](
|
11389
|
+
[`JSONAPIAdapter`](https://emberjs.com/api/data/classes/DS.JSONAPIAdapter.html)
|
11635
11390
|
that supports the [JSON API specification](http://jsonapi.org/) and if your server
|
11636
11391
|
endpoint supports the use of an
|
11637
11392
|
['include' query parameter](http://jsonapi.org/format/#fetching-includes),
|
@@ -11932,7 +11687,8 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
11932
11687
|
var operation = void 0;
|
11933
11688
|
|
11934
11689
|
if (internalModel.currentState.stateName === 'root.deleted.saved') {
|
11935
|
-
|
11690
|
+
resolver.resolve();
|
11691
|
+
continue;
|
11936
11692
|
} else if (internalModel.isNew()) {
|
11937
11693
|
operation = 'createRecord';
|
11938
11694
|
} else if (internalModel.isDeleted()) {
|
@@ -12133,7 +11889,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
12133
11889
|
Returns the model class for the particular `modelName`.
|
12134
11890
|
The class of a model might be useful if you want to get a list of all the
|
12135
11891
|
relationship names of the model, see
|
12136
|
-
[`relationshipNames`](
|
11892
|
+
[`relationshipNames`](https://emberjs.com/api/data/classes/DS.Model.html#property_relationshipNames)
|
12137
11893
|
for example.
|
12138
11894
|
@method modelFor
|
12139
11895
|
@param {String} modelName
|
@@ -12466,9 +12222,10 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
12466
12222
|
// payload push. In the common case where we are pushing many more
|
12467
12223
|
// instances than types we want to minimize the cost of looking up the
|
12468
12224
|
// inverse map and the overhead of Ember.get adds up.
|
12469
|
-
var modelNameToInverseMap =
|
12225
|
+
var modelNameToInverseMap = void 0;
|
12470
12226
|
|
12471
12227
|
for (var i = 0, l = pushed.length; i < l; i += 2) {
|
12228
|
+
modelNameToInverseMap = modelNameToInverseMap || Object.create(null);
|
12472
12229
|
// This will convert relationships specified as IDs into DS.Model instances
|
12473
12230
|
// (possibly unloaded) and also create the data structures used to track
|
12474
12231
|
// relationships.
|
@@ -12888,13 +12645,8 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/-pri
|
|
12888
12645
|
}
|
12889
12646
|
|
12890
12647
|
function setupRelationships(store, internalModel, data, modelNameToInverseMap) {
|
12891
|
-
|
12892
|
-
|
12893
|
-
internalModel.type.eachRelationship(function (relationshipName) {
|
12894
|
-
if (!data.relationships[relationshipName]) {
|
12895
|
-
return;
|
12896
|
-
}
|
12897
|
-
|
12648
|
+
Object.keys(data.relationships).forEach(function (relationshipName) {
|
12649
|
+
var relationships = internalModel._relationships;
|
12898
12650
|
var relationshipRequiresNotification = relationships.has(relationshipName) || isInverseRelationshipInitialized(store, internalModel, data, relationshipName, modelNameToInverseMap);
|
12899
12651
|
|
12900
12652
|
if (relationshipRequiresNotification) {
|
@@ -13105,7 +12857,7 @@ define('ember-data/-private/system/store/finders', ['exports', 'ember', 'ember-d
|
|
13105
12857
|
var serializer = (0, _serializers.serializerForAdapter)(store, adapter, modelName);
|
13106
12858
|
var payload = (0, _serializerResponse.normalizeResponseHelper)(serializer, store, modelClass, adapterPayload, id, 'findRecord');
|
13107
12859
|
(false && _ember.default.assert('Ember Data expected the primary data returned from a \'findRecord\' response to be an object but instead it found an array.', !Array.isArray(payload.data)));
|
13108
|
-
(false && _ember.default.warn('You requested a record of type \'' + modelName + '\' with id \'' + id + '\' but the adapter returned a payload with primary data having an id of \'' + payload.data.id + '\'. Use \'store.findRecord()\' when the requested id is the same as the one returned by the adapter. In other cases use \'store.queryRecord()\' instead
|
12860
|
+
(false && _ember.default.warn('You requested a record of type \'' + modelName + '\' with id \'' + id + '\' but the adapter returned a payload with primary data having an id of \'' + payload.data.id + '\'. Use \'store.findRecord()\' when the requested id is the same as the one returned by the adapter. In other cases use \'store.queryRecord()\' instead https://emberjs.com/api/data/classes/DS.Store.html#method_queryRecord', payload.data.id === id, {
|
13109
12861
|
id: 'ds.store.findRecord.id-mismatch'
|
13110
12862
|
}));
|
13111
12863
|
|
@@ -13413,7 +13165,12 @@ define('ember-data/-private/utils', ['exports', 'ember'], function (exports, _em
|
|
13413
13165
|
|
13414
13166
|
if (owner && owner.lookupFactory && !owner._lookupFactory) {
|
13415
13167
|
// `owner` is a container, we are just making this work
|
13416
|
-
owner._lookupFactory =
|
13168
|
+
owner._lookupFactory = function () {
|
13169
|
+
var _owner;
|
13170
|
+
|
13171
|
+
return (_owner = owner).lookupFactory.apply(_owner, arguments);
|
13172
|
+
};
|
13173
|
+
|
13417
13174
|
owner.register = function () {
|
13418
13175
|
var registry = owner.registry || owner._registry || owner;
|
13419
13176
|
|
@@ -14066,7 +13823,7 @@ define('ember-data/adapters/errors', ['exports', 'ember-data/-private'], functio
|
|
14066
13823
|
}
|
14067
13824
|
});
|
14068
13825
|
});
|
14069
|
-
define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters/rest', 'ember-data/-private'], function (exports, _ember, _rest, _private) {
|
13826
|
+
define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-inflector', 'ember-data/adapters/rest', 'ember-data/-private', 'ember-data/-debug'], function (exports, _ember, _emberInflector, _rest, _private, _debug) {
|
14070
13827
|
'use strict';
|
14071
13828
|
|
14072
13829
|
exports.__esModule = true;
|
@@ -14286,7 +14043,7 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
|
|
14286
14043
|
},
|
14287
14044
|
pathForType: function (modelName) {
|
14288
14045
|
var dasherized = _ember.default.String.dasherize(modelName);
|
14289
|
-
return
|
14046
|
+
return (0, _emberInflector.pluralize)(dasherized);
|
14290
14047
|
},
|
14291
14048
|
updateRecord: function (store, type, snapshot) {
|
14292
14049
|
if ((0, _private.isEnabled)('ds-improved-ajax') && !this._hasCustomizedAjax()) {
|
@@ -14385,12 +14142,13 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
|
|
14385
14142
|
|
14386
14143
|
exports.default = JSONAPIAdapter;
|
14387
14144
|
});
|
14388
|
-
define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'ember-data/-private'], function (exports, _ember, _adapter, _private) {
|
14145
|
+
define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'ember-data/-private', 'ember-data/-debug'], function (exports, _ember, _adapter, _private, _debug) {
|
14389
14146
|
'use strict';
|
14390
14147
|
|
14391
14148
|
exports.__esModule = true;
|
14392
14149
|
var MapWithDefault = _ember.default.MapWithDefault,
|
14393
|
-
get = _ember.default.get
|
14150
|
+
get = _ember.default.get,
|
14151
|
+
run = _ember.default.run;
|
14394
14152
|
|
14395
14153
|
|
14396
14154
|
var Promise = _ember.default.RSVP.Promise;
|
@@ -14995,7 +14753,7 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
14995
14753
|
|
14996
14754
|
hash.success = function (payload, textStatus, jqXHR) {
|
14997
14755
|
var response = ajaxSuccess(adapter, jqXHR, payload, requestData);
|
14998
|
-
|
14756
|
+
run.join(null, resolve, response);
|
14999
14757
|
};
|
15000
14758
|
|
15001
14759
|
hash.error = function (jqXHR, textStatus, errorThrown) {
|
@@ -15004,7 +14762,7 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
15004
14762
|
errorThrown: errorThrown
|
15005
14763
|
};
|
15006
14764
|
var error = ajaxError(adapter, jqXHR, requestData, responseData);
|
15007
|
-
|
14765
|
+
run.join(null, reject, error);
|
15008
14766
|
};
|
15009
14767
|
|
15010
14768
|
adapter._ajaxRequest(hash);
|
@@ -15280,11 +15038,11 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
15280
15038
|
|
15281
15039
|
var requestData = { method: method, url: url };
|
15282
15040
|
|
15283
|
-
return new
|
15041
|
+
return new Promise(function (resolve, reject) {
|
15284
15042
|
|
15285
15043
|
hash.success = function (payload, textStatus, jqXHR) {
|
15286
15044
|
var response = ajaxSuccess(adapter, jqXHR, payload, requestData);
|
15287
|
-
|
15045
|
+
run.join(null, resolve, response);
|
15288
15046
|
};
|
15289
15047
|
|
15290
15048
|
hash.error = function (jqXHR, textStatus, errorThrown) {
|
@@ -15293,7 +15051,7 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
15293
15051
|
errorThrown: errorThrown
|
15294
15052
|
};
|
15295
15053
|
var error = ajaxError(adapter, jqXHR, requestData, responseData);
|
15296
|
-
|
15054
|
+
run.join(null, reject, error);
|
15297
15055
|
};
|
15298
15056
|
|
15299
15057
|
adapter._ajaxRequest(hash);
|
@@ -15923,102 +15681,9 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember'], fu
|
|
15923
15681
|
}
|
15924
15682
|
}
|
15925
15683
|
|
15926
|
-
var get = _ember.default.get
|
15927
|
-
|
15684
|
+
var get = _ember.default.get,
|
15685
|
+
set = _ember.default.set;
|
15928
15686
|
var camelize = _ember.default.String.camelize;
|
15929
|
-
|
15930
|
-
/**
|
15931
|
-
## Using Embedded Records
|
15932
|
-
|
15933
|
-
`DS.EmbeddedRecordsMixin` supports serializing embedded records.
|
15934
|
-
|
15935
|
-
To set up embedded records, include the mixin when extending a serializer,
|
15936
|
-
then define and configure embedded (model) relationships.
|
15937
|
-
|
15938
|
-
Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.
|
15939
|
-
|
15940
|
-
Below is an example of a per-type serializer (`post` type).
|
15941
|
-
|
15942
|
-
```app/serializers/post.js
|
15943
|
-
import DS from 'ember-data';
|
15944
|
-
|
15945
|
-
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
|
15946
|
-
attrs: {
|
15947
|
-
author: { embedded: 'always' },
|
15948
|
-
comments: { serialize: 'ids' }
|
15949
|
-
}
|
15950
|
-
});
|
15951
|
-
```
|
15952
|
-
Note that this use of `{ embedded: 'always' }` is unrelated to
|
15953
|
-
the `{ embedded: 'always' }` that is defined as an option on `DS.attr` as part of
|
15954
|
-
defining a model while working with the `ActiveModelSerializer`. Nevertheless,
|
15955
|
-
using `{ embedded: 'always' }` as an option to `DS.attr` is not a valid way to setup
|
15956
|
-
embedded records.
|
15957
|
-
|
15958
|
-
The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:
|
15959
|
-
|
15960
|
-
```js
|
15961
|
-
{
|
15962
|
-
serialize: 'records',
|
15963
|
-
deserialize: 'records'
|
15964
|
-
}
|
15965
|
-
```
|
15966
|
-
|
15967
|
-
### Configuring Attrs
|
15968
|
-
|
15969
|
-
A resource's `attrs` option may be set to use `ids`, `records` or false for the
|
15970
|
-
`serialize` and `deserialize` settings.
|
15971
|
-
|
15972
|
-
The `attrs` property can be set on the `ApplicationSerializer` or a per-type
|
15973
|
-
serializer.
|
15974
|
-
|
15975
|
-
In the case where embedded JSON is expected while extracting a payload (reading)
|
15976
|
-
the setting is `deserialize: 'records'`, there is no need to use `ids` when
|
15977
|
-
extracting as that is the default behavior without this mixin if you are using
|
15978
|
-
the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while
|
15979
|
-
serializing `serialize: 'records'` is the setting to use. There is an option of
|
15980
|
-
not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you
|
15981
|
-
do not want the relationship sent at all, you can use `serialize: false`.
|
15982
|
-
|
15983
|
-
|
15984
|
-
### EmbeddedRecordsMixin defaults
|
15985
|
-
If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin`
|
15986
|
-
will behave in the following way:
|
15987
|
-
|
15988
|
-
BelongsTo: `{ serialize: 'id', deserialize: 'id' }`
|
15989
|
-
HasMany: `{ serialize: false, deserialize: 'ids' }`
|
15990
|
-
|
15991
|
-
### Model Relationships
|
15992
|
-
|
15993
|
-
Embedded records must have a model defined to be extracted and serialized. Note that
|
15994
|
-
when defining any relationships on your model such as `belongsTo` and `hasMany`, you
|
15995
|
-
should not both specify `async: true` and also indicate through the serializer's
|
15996
|
-
`attrs` attribute that the related model should be embedded for deserialization.
|
15997
|
-
If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`),
|
15998
|
-
then do not use `async: true`.
|
15999
|
-
|
16000
|
-
To successfully extract and serialize embedded records the model relationships
|
16001
|
-
must be setup correcty. See the
|
16002
|
-
[defining relationships](/guides/models/defining-models/#toc_defining-relationships)
|
16003
|
-
section of the **Defining Models** guide page.
|
16004
|
-
|
16005
|
-
Records without an `id` property are not considered embedded records, model
|
16006
|
-
instances must have an `id` property to be used with Ember Data.
|
16007
|
-
|
16008
|
-
### Example JSON payloads, Models and Serializers
|
16009
|
-
|
16010
|
-
**When customizing a serializer it is important to grok what the customizations
|
16011
|
-
are. Please read the docs for the methods this mixin provides, in case you need
|
16012
|
-
to modify it to fit your specific needs.**
|
16013
|
-
|
16014
|
-
For example review the docs for each method of this mixin:
|
16015
|
-
* [normalize](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_normalize)
|
16016
|
-
* [serializeBelongsTo](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_serializeBelongsTo)
|
16017
|
-
* [serializeHasMany](/api/data/classes/DS.EmbeddedRecordsMixin.html#method_serializeHasMany)
|
16018
|
-
|
16019
|
-
@class EmbeddedRecordsMixin
|
16020
|
-
@namespace DS
|
16021
|
-
*/
|
16022
15687
|
exports.default = _ember.default.Mixin.create({
|
16023
15688
|
|
16024
15689
|
/**
|
@@ -17044,7 +16709,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-inflector'
|
|
17044
16709
|
JSONAPISerializer.reopen({
|
17045
16710
|
willMergeMixin: function (props) {
|
17046
16711
|
var constructor = this.constructor;
|
17047
|
-
(false && _ember.default.warn('You\'ve defined \'extractMeta\' in ' + constructor.toString() + ' which is not used for serializers extending JSONAPISerializer. Read more at
|
16712
|
+
(false && _ember.default.warn('You\'ve defined \'extractMeta\' in ' + constructor.toString() + ' which is not used for serializers extending JSONAPISerializer. Read more at https://emberjs.com/api/data/classes/DS.JSONAPISerializer.html#toc_customizing-meta on how to customize meta when using JSON API.', _ember.default.isNone(props.extractMeta) || props.extractMeta === _json.default.prototype.extractMeta, {
|
17048
16713
|
id: 'ds.serializer.json-api.extractMeta'
|
17049
16714
|
}));
|
17050
16715
|
(false && _ember.default.warn('The JSONAPISerializer does not work with the EmbeddedRecordsMixin because the JSON API spec does not describe how to format embedded resources.', !props.isEmbeddedRecordsMixin, {
|
@@ -17778,6 +17443,7 @@ define('ember-data/serializers/rest', ['exports', 'ember', 'ember-inflector', 'e
|
|
17778
17443
|
|
17779
17444
|
var camelize = _ember.default.String.camelize;
|
17780
17445
|
|
17446
|
+
|
17781
17447
|
/**
|
17782
17448
|
Normally, applications will use the `RESTSerializer` by implementing
|
17783
17449
|
the `normalize` method.
|
@@ -18593,7 +18259,7 @@ define("ember-data/version", ["exports"], function (exports) {
|
|
18593
18259
|
"use strict";
|
18594
18260
|
|
18595
18261
|
exports.__esModule = true;
|
18596
|
-
exports.default = "2.
|
18262
|
+
exports.default = "2.16.0-beta.1";
|
18597
18263
|
});
|
18598
18264
|
define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) {
|
18599
18265
|
"use strict";
|