@ember-data/model 5.5.0-alpha.2 → 5.5.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +19 -7
- package/README.md +21 -2
- package/addon-main.cjs +5 -0
- package/blueprints/model/index.js +18 -5
- package/blueprints/model-test/index.js +16 -10
- package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
- package/dist/-private.js +3 -0
- package/{addon → dist}/-private.js.map +1 -1
- package/dist/has-many-CwEZBhUG.js +682 -0
- package/dist/has-many-CwEZBhUG.js.map +1 -0
- package/dist/hooks-C6_7V3O3.js +75 -0
- package/dist/hooks-C6_7V3O3.js.map +1 -0
- package/dist/hooks.js +2 -0
- package/{addon → dist}/hooks.js.map +1 -1
- package/dist/index.js +5 -0
- package/{addon → dist}/index.js.map +1 -1
- package/dist/migration-support.js +213 -0
- package/dist/migration-support.js.map +1 -0
- package/{addon/model-b638e17c.js → dist/model-B9PHp6Pe.js} +2555 -2455
- package/dist/model-B9PHp6Pe.js.map +1 -0
- package/dist/schema-provider-WdyaNQ3o.js +259 -0
- package/dist/schema-provider-WdyaNQ3o.js.map +1 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/ember-data-logo-dark.svg +12 -0
- package/logos/ember-data-logo-light.svg +12 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +62 -58
- package/unstable-preview-types/-private/attr.d.ts +175 -0
- package/unstable-preview-types/-private/attr.d.ts.map +1 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.d.ts +181 -0
- package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
- package/unstable-preview-types/-private/errors.d.ts +303 -0
- package/unstable-preview-types/-private/errors.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.d.ts +169 -0
- package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/hooks.d.ts +13 -0
- package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-methods.d.ts +37 -0
- package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.d.ts +1303 -0
- package/unstable-preview-types/-private/model.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/notify-changes.d.ts +8 -0
- package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +46 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts +132 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-proxy-base.d.ts +5 -0
- package/unstable-preview-types/-private/promise-proxy-base.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-state.d.ts +80 -0
- package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts +503 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/has-many.d.ts +515 -0
- package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/schema-provider.d.ts +65 -0
- package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
- package/unstable-preview-types/-private/type-utils.d.ts +64 -0
- package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/util.d.ts +8 -0
- package/unstable-preview-types/-private/util.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +13 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/hooks.d.ts +5 -0
- package/unstable-preview-types/hooks.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +76 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
- package/unstable-preview-types/migration-support.d.ts +64 -0
- package/unstable-preview-types/migration-support.d.ts.map +1 -0
- package/addon/-private.js +0 -2
- package/addon/has-many-774c4c4b.js +0 -507
- package/addon/has-many-774c4c4b.js.map +0 -1
- package/addon/hooks-6d5c2fc2.js +0 -157
- package/addon/hooks-6d5c2fc2.js.map +0 -1
- package/addon/hooks.js +0 -1
- package/addon/index.js +0 -3
- package/addon/model-b638e17c.js.map +0 -1
- package/addon-main.js +0 -93
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
import { macroCondition, getOwnConfig } from '@embroider/macros';
|
|
2
|
-
import { assert, warn, deprecate } from '@ember/debug';
|
|
3
|
-
import { computed } from '@ember/object';
|
|
4
|
-
import { recordIdentifierFor } from '@ember-data/store';
|
|
5
|
-
import { peekCache } from '@ember-data/store/-private';
|
|
6
|
-
import { c as computedMacroWithOptionalParams, n as normalizeModelName, l as lookupLegacySupport } from "./model-b638e17c";
|
|
7
|
-
import { A } from '@ember/array';
|
|
8
|
-
import { dasherize } from '@ember/string';
|
|
9
|
-
import { singularize } from 'ember-inflector';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
@module @ember-data/model
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
`attr` defines an attribute on a [Model](/ember-data/release/classes/Model).
|
|
17
|
-
By default, attributes are passed through as-is, however you can specify an
|
|
18
|
-
optional type to have the value automatically transformed.
|
|
19
|
-
Ember Data ships with four basic transform types: `string`, `number`,
|
|
20
|
-
`boolean` and `date`. You can define your own transforms by subclassing
|
|
21
|
-
[Transform](/ember-data/release/classes/Transform).
|
|
22
|
-
|
|
23
|
-
Note that you cannot use `attr` to define an attribute of `id`.
|
|
24
|
-
|
|
25
|
-
`attr` takes an optional hash as a second parameter, currently
|
|
26
|
-
supported options are:
|
|
27
|
-
|
|
28
|
-
- `defaultValue`: Pass a string or a function to be called to set the attribute
|
|
29
|
-
to a default value if and only if the key is absent from the payload response.
|
|
30
|
-
|
|
31
|
-
Example
|
|
32
|
-
|
|
33
|
-
```app/models/user.js
|
|
34
|
-
import Model, { attr } from '@ember-data/model';
|
|
35
|
-
|
|
36
|
-
export default class UserModel extends Model {
|
|
37
|
-
@attr('string') username;
|
|
38
|
-
@attr('string') email;
|
|
39
|
-
@attr('boolean', { defaultValue: false }) verified;
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Default value can also be a function. This is useful it you want to return
|
|
44
|
-
a new object for each attribute.
|
|
45
|
-
|
|
46
|
-
```app/models/user.js
|
|
47
|
-
import Model, { attr } from '@ember-data/model';
|
|
48
|
-
|
|
49
|
-
export default class UserModel extends Model {
|
|
50
|
-
@attr('string') username;
|
|
51
|
-
@attr('string') email;
|
|
52
|
-
|
|
53
|
-
@attr({
|
|
54
|
-
defaultValue() {
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
settings;
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
The `options` hash is passed as second argument to a transforms'
|
|
63
|
-
`serialize` and `deserialize` method. This allows to configure a
|
|
64
|
-
transformation and adapt the corresponding value, based on the config:
|
|
65
|
-
|
|
66
|
-
```app/models/post.js
|
|
67
|
-
import Model, { attr } from '@ember-data/model';
|
|
68
|
-
|
|
69
|
-
export default class PostModel extends Model {
|
|
70
|
-
@attr('text', {
|
|
71
|
-
uppercase: true
|
|
72
|
-
})
|
|
73
|
-
text;
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
```app/transforms/text.js
|
|
78
|
-
export default class TextTransform {
|
|
79
|
-
serialize(value, options) {
|
|
80
|
-
if (options.uppercase) {
|
|
81
|
-
return value.toUpperCase();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
deserialize(value) {
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static create() {
|
|
92
|
-
return new this();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
@method attr
|
|
98
|
-
@public
|
|
99
|
-
@static
|
|
100
|
-
@for @ember-data/model
|
|
101
|
-
@param {String|Object} type the attribute type
|
|
102
|
-
@param {Object} options a hash of options
|
|
103
|
-
@return {Attribute}
|
|
104
|
-
*/
|
|
105
|
-
function attr(type, options) {
|
|
106
|
-
if (typeof type === 'object') {
|
|
107
|
-
options = type;
|
|
108
|
-
type = undefined;
|
|
109
|
-
} else {
|
|
110
|
-
options = options || {};
|
|
111
|
-
}
|
|
112
|
-
let meta = {
|
|
113
|
-
type: type,
|
|
114
|
-
isAttribute: true,
|
|
115
|
-
options: options
|
|
116
|
-
};
|
|
117
|
-
return computed({
|
|
118
|
-
get(key) {
|
|
119
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
120
|
-
if (['currentState'].indexOf(key) !== -1) {
|
|
121
|
-
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (this.isDestroyed || this.isDestroying) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
return peekCache(this).getAttr(recordIdentifierFor(this), key);
|
|
128
|
-
},
|
|
129
|
-
set(key, value) {
|
|
130
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
131
|
-
if (['currentState'].indexOf(key) !== -1) {
|
|
132
|
-
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
assert(`Attempted to set '${key}' on the deleted record ${recordIdentifierFor(this)}`, !this.currentState.isDeleted);
|
|
136
|
-
const identifier = recordIdentifierFor(this);
|
|
137
|
-
const cache = peekCache(this);
|
|
138
|
-
let currentValue = cache.getAttr(identifier, key);
|
|
139
|
-
if (currentValue !== value) {
|
|
140
|
-
cache.setAttr(identifier, key, value);
|
|
141
|
-
if (!this.isValid) {
|
|
142
|
-
const {
|
|
143
|
-
errors
|
|
144
|
-
} = this;
|
|
145
|
-
if (errors.get(key)) {
|
|
146
|
-
errors.remove(key);
|
|
147
|
-
this.currentState.cleanErrorRequests();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return value;
|
|
152
|
-
}
|
|
153
|
-
}).meta(meta);
|
|
154
|
-
}
|
|
155
|
-
var attr$1 = computedMacroWithOptionalParams(attr);
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
@module @ember-data/model
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
`belongsTo` is used to define One-To-One and One-To-Many
|
|
163
|
-
relationships on a [Model](/ember-data/release/classes/Model).
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
`belongsTo` takes an optional hash as a second parameter, currently
|
|
167
|
-
supported options are:
|
|
168
|
-
|
|
169
|
-
- `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.
|
|
170
|
-
- `inverse`: A string used to identify the inverse property on a
|
|
171
|
-
related model in a One-To-Many relationship. See [Explicit Inverses](#explicit-inverses)
|
|
172
|
-
- `polymorphic` A boolean value to mark the relationship as polymorphic
|
|
173
|
-
|
|
174
|
-
#### One-To-One
|
|
175
|
-
To declare a one-to-one relationship between two models, use
|
|
176
|
-
`belongsTo`:
|
|
177
|
-
|
|
178
|
-
```app/models/user.js
|
|
179
|
-
import Model, { belongsTo } from '@ember-data/model';
|
|
180
|
-
|
|
181
|
-
export default class UserModel extends Model {
|
|
182
|
-
@belongsTo('profile') profile;
|
|
183
|
-
}
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
```app/models/profile.js
|
|
187
|
-
import Model, { belongsTo } from '@ember-data/model';
|
|
188
|
-
|
|
189
|
-
export default class ProfileModel extends Model {
|
|
190
|
-
@belongsTo('user') user;
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
#### One-To-Many
|
|
195
|
-
|
|
196
|
-
To declare a one-to-many relationship between two models, use
|
|
197
|
-
`belongsTo` in combination with `hasMany`, like this:
|
|
198
|
-
|
|
199
|
-
```app/models/post.js
|
|
200
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
201
|
-
|
|
202
|
-
export default class PostModel extends Model {
|
|
203
|
-
@hasMany('comment', { async: false, inverse: 'post' }) comments;
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
```app/models/comment.js
|
|
208
|
-
import Model, { belongsTo } from '@ember-data/model';
|
|
209
|
-
|
|
210
|
-
export default class CommentModel extends Model {
|
|
211
|
-
@belongsTo('post', { async: false, inverse: 'comments' }) post;
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
#### Sync relationships
|
|
216
|
-
|
|
217
|
-
Ember Data resolves sync relationships with the related resources
|
|
218
|
-
available in its local store, hence it is expected these resources
|
|
219
|
-
to be loaded before or along-side the primary resource.
|
|
220
|
-
|
|
221
|
-
```app/models/comment.js
|
|
222
|
-
import Model, { belongsTo } from '@ember-data/model';
|
|
223
|
-
|
|
224
|
-
export default class CommentModel extends Model {
|
|
225
|
-
@belongsTo('post', {
|
|
226
|
-
async: false,
|
|
227
|
-
inverse: null
|
|
228
|
-
})
|
|
229
|
-
post;
|
|
230
|
-
}
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
In contrast to async relationship, accessing a sync relationship
|
|
234
|
-
will always return the record (Model instance) for the existing
|
|
235
|
-
local resource, or null. But it will error on access when
|
|
236
|
-
a related resource is known to exist and it has not been loaded.
|
|
237
|
-
|
|
238
|
-
```
|
|
239
|
-
let post = comment.post;
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
@method belongsTo
|
|
244
|
-
@public
|
|
245
|
-
@static
|
|
246
|
-
@for @ember-data/model
|
|
247
|
-
@param {String} modelName (optional) type of the relationship
|
|
248
|
-
@param {Object} options (optional) a hash of options
|
|
249
|
-
@return {Ember.computed} relationship
|
|
250
|
-
*/
|
|
251
|
-
function belongsTo(modelName, options) {
|
|
252
|
-
let opts = options;
|
|
253
|
-
let userEnteredModelName = modelName;
|
|
254
|
-
assert(`Expected options.async from @belongsTo('${userEnteredModelName}', options) to be a boolean`, opts && typeof opts.async === 'boolean');
|
|
255
|
-
assert(`Expected options.inverse from @belongsTo('${userEnteredModelName}', options) to be either null or the string type of the related resource.`, opts.inverse === null || typeof opts.inverse === 'string' && opts.inverse.length > 0);
|
|
256
|
-
let meta = {
|
|
257
|
-
type: normalizeModelName(userEnteredModelName),
|
|
258
|
-
isRelationship: true,
|
|
259
|
-
options: opts,
|
|
260
|
-
kind: 'belongsTo',
|
|
261
|
-
name: 'Belongs To',
|
|
262
|
-
key: null
|
|
263
|
-
};
|
|
264
|
-
return computed({
|
|
265
|
-
get(key) {
|
|
266
|
-
// this is a legacy behavior we may not carry into a new model setup
|
|
267
|
-
// it's better to error on disconnected records so users find errors
|
|
268
|
-
// in their logic.
|
|
269
|
-
if (this.isDestroying || this.isDestroyed) {
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
const support = lookupLegacySupport(this);
|
|
273
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
274
|
-
if (['currentState'].indexOf(key) !== -1) {
|
|
275
|
-
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`);
|
|
276
|
-
}
|
|
277
|
-
if (Object.prototype.hasOwnProperty.call(opts, 'serialize')) {
|
|
278
|
-
warn(`You provided a serialize option on the "${key}" property in the "${support.identifier.type}" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`, false, {
|
|
279
|
-
id: 'ds.model.serialize-option-in-belongs-to'
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
if (Object.prototype.hasOwnProperty.call(opts, 'embedded')) {
|
|
283
|
-
warn(`You provided an embedded option on the "${key}" property in the "${support.identifier.type}" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`, false, {
|
|
284
|
-
id: 'ds.model.embedded-option-in-belongs-to'
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return support.getBelongsTo(key);
|
|
289
|
-
},
|
|
290
|
-
set(key, value) {
|
|
291
|
-
const support = lookupLegacySupport(this);
|
|
292
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
293
|
-
if (['currentState'].indexOf(key) !== -1) {
|
|
294
|
-
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
this.store._join(() => {
|
|
298
|
-
support.setDirtyBelongsTo(key, value);
|
|
299
|
-
});
|
|
300
|
-
return support.getBelongsTo(key);
|
|
301
|
-
}
|
|
302
|
-
}).meta(meta);
|
|
303
|
-
}
|
|
304
|
-
var belongsTo$1 = computedMacroWithOptionalParams(belongsTo);
|
|
305
|
-
function normalizeType(type) {
|
|
306
|
-
if (macroCondition(getOwnConfig().deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
307
|
-
const result = singularize(dasherize(type));
|
|
308
|
-
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
309
|
-
id: 'ember-data:deprecate-non-strict-types',
|
|
310
|
-
until: '6.0',
|
|
311
|
-
for: 'ember-data',
|
|
312
|
-
since: {
|
|
313
|
-
available: '5.3',
|
|
314
|
-
enabled: '5.3'
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
return result;
|
|
318
|
-
}
|
|
319
|
-
return type;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
`hasMany` is used to define One-To-Many and Many-To-Many
|
|
324
|
-
relationships on a [Model](/ember-data/release/classes/Model).
|
|
325
|
-
|
|
326
|
-
`hasMany` takes an optional hash as a second parameter, currently
|
|
327
|
-
supported options are:
|
|
328
|
-
|
|
329
|
-
- `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.
|
|
330
|
-
- `inverse`: A string used to identify the inverse property on a related model.
|
|
331
|
-
- `polymorphic` A boolean value to mark the relationship as polymorphic
|
|
332
|
-
|
|
333
|
-
#### One-To-Many
|
|
334
|
-
To declare a one-to-many relationship between two models, use
|
|
335
|
-
`belongsTo` in combination with `hasMany`, like this:
|
|
336
|
-
|
|
337
|
-
```app/models/post.js
|
|
338
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
339
|
-
|
|
340
|
-
export default class PostModel extends Model {
|
|
341
|
-
@hasMany('comment') comments;
|
|
342
|
-
}
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
```app/models/comment.js
|
|
346
|
-
import Model, { belongsTo } from '@ember-data/model';
|
|
347
|
-
|
|
348
|
-
export default class CommentModel extends Model {
|
|
349
|
-
@belongsTo('post') post;
|
|
350
|
-
}
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
#### Many-To-Many
|
|
354
|
-
To declare a many-to-many relationship between two models, use
|
|
355
|
-
`hasMany`:
|
|
356
|
-
|
|
357
|
-
```app/models/post.js
|
|
358
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
359
|
-
|
|
360
|
-
export default class PostModel extends Model {
|
|
361
|
-
@hasMany('tag') tags;
|
|
362
|
-
}
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
```app/models/tag.js
|
|
366
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
367
|
-
|
|
368
|
-
export default class TagModel extends Model {
|
|
369
|
-
@hasMany('post') posts;
|
|
370
|
-
}
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
You can avoid passing a string as the first parameter. In that case Ember Data
|
|
374
|
-
will infer the type from the singularized key name.
|
|
375
|
-
|
|
376
|
-
```app/models/post.js
|
|
377
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
378
|
-
|
|
379
|
-
export default class PostModel extends Model {
|
|
380
|
-
@hasMany tags;
|
|
381
|
-
}
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
will lookup for a Tag type.
|
|
385
|
-
|
|
386
|
-
#### Explicit Inverses
|
|
387
|
-
|
|
388
|
-
Ember Data will do its best to discover which relationships map to
|
|
389
|
-
one another. In the one-to-many code above, for example, Ember Data
|
|
390
|
-
can figure out that changing the `comments` relationship should update
|
|
391
|
-
the `post` relationship on the inverse because post is the only
|
|
392
|
-
relationship to that model.
|
|
393
|
-
|
|
394
|
-
However, sometimes you may have multiple `belongsTo`/`hasMany` for the
|
|
395
|
-
same type. You can specify which property on the related model is
|
|
396
|
-
the inverse using `hasMany`'s `inverse` option:
|
|
397
|
-
|
|
398
|
-
```app/models/comment.js
|
|
399
|
-
import Model, { belongsTo } from '@ember-data/model';
|
|
400
|
-
|
|
401
|
-
export default class CommentModel extends Model {
|
|
402
|
-
@belongsTo('post') onePost;
|
|
403
|
-
@belongsTo('post') twoPost
|
|
404
|
-
@belongsTo('post') redPost;
|
|
405
|
-
@belongsTo('post') bluePost;
|
|
406
|
-
}
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
```app/models/post.js
|
|
410
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
411
|
-
|
|
412
|
-
export default class PostModel extends Model {
|
|
413
|
-
@hasMany('comment', {
|
|
414
|
-
inverse: 'redPost'
|
|
415
|
-
})
|
|
416
|
-
comments;
|
|
417
|
-
}
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
You can also specify an inverse on a `belongsTo`, which works how
|
|
421
|
-
you'd expect.
|
|
422
|
-
|
|
423
|
-
#### Sync relationships
|
|
424
|
-
|
|
425
|
-
Ember Data resolves sync relationships with the related resources
|
|
426
|
-
available in its local store, hence it is expected these resources
|
|
427
|
-
to be loaded before or along-side the primary resource.
|
|
428
|
-
|
|
429
|
-
```app/models/post.js
|
|
430
|
-
import Model, { hasMany } from '@ember-data/model';
|
|
431
|
-
|
|
432
|
-
export default class PostModel extends Model {
|
|
433
|
-
@hasMany('comment', {
|
|
434
|
-
async: false
|
|
435
|
-
})
|
|
436
|
-
comments;
|
|
437
|
-
}
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
In contrast to async relationship, accessing a sync relationship
|
|
441
|
-
will always return a [ManyArray](/ember-data/release/classes/ManyArray) instance
|
|
442
|
-
containing the existing local resources. But it will error on access
|
|
443
|
-
when any of the known related resources have not been loaded.
|
|
444
|
-
|
|
445
|
-
```
|
|
446
|
-
post.comments.forEach((comment) => {
|
|
447
|
-
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
If you are using `links` with sync relationships, you have to use
|
|
453
|
-
`ref.reload` to fetch the resources.
|
|
454
|
-
|
|
455
|
-
@method hasMany
|
|
456
|
-
@public
|
|
457
|
-
@static
|
|
458
|
-
@for @ember-data/model
|
|
459
|
-
@param {String} type (optional) type of the relationship
|
|
460
|
-
@param {Object} options (optional) a hash of options
|
|
461
|
-
@return {Ember.computed} relationship
|
|
462
|
-
*/
|
|
463
|
-
function hasMany(type, options) {
|
|
464
|
-
assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');
|
|
465
|
-
|
|
466
|
-
// Metadata about relationships is stored on the meta of
|
|
467
|
-
// the relationship. This is used for introspection and
|
|
468
|
-
// serialization. Note that `key` is populated lazily
|
|
469
|
-
// the first time the CP is called.
|
|
470
|
-
let meta = {
|
|
471
|
-
type: normalizeType(type),
|
|
472
|
-
options,
|
|
473
|
-
isRelationship: true,
|
|
474
|
-
kind: 'hasMany',
|
|
475
|
-
name: 'Has Many',
|
|
476
|
-
key: null
|
|
477
|
-
};
|
|
478
|
-
return computed({
|
|
479
|
-
get(key) {
|
|
480
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
481
|
-
if (['currentState'].indexOf(key) !== -1) {
|
|
482
|
-
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
if (this.isDestroying || this.isDestroyed) {
|
|
486
|
-
return A();
|
|
487
|
-
}
|
|
488
|
-
return lookupLegacySupport(this).getHasMany(key);
|
|
489
|
-
},
|
|
490
|
-
set(key, records) {
|
|
491
|
-
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
492
|
-
if (['currentState'].indexOf(key) !== -1) {
|
|
493
|
-
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
const support = lookupLegacySupport(this);
|
|
497
|
-
const manyArray = support.getManyArray(key);
|
|
498
|
-
assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));
|
|
499
|
-
this.store._join(() => {
|
|
500
|
-
manyArray.splice(0, manyArray.length, ...records);
|
|
501
|
-
});
|
|
502
|
-
return support.getHasMany(key);
|
|
503
|
-
}
|
|
504
|
-
}).meta(meta);
|
|
505
|
-
}
|
|
506
|
-
var hasMany$1 = computedMacroWithOptionalParams(hasMany);
|
|
507
|
-
export { attr$1 as a, belongsTo$1 as b, hasMany$1 as h };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"has-many-774c4c4b.js","sources":["../src/-private/attr.js","../src/-private/belongs-to.js","../src/-private/has-many.js"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@ember-data/env';\nimport { recordIdentifierFor } from '@ember-data/store';\nimport { peekCache } from '@ember-data/store/-private';\n\nimport { computedMacroWithOptionalParams } from './util';\n\n/**\n @module @ember-data/model\n*/\n\n/**\n `attr` defines an attribute on a [Model](/ember-data/release/classes/Model).\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n Ember Data ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n [Transform](/ember-data/release/classes/Transform).\n\n Note that you cannot use `attr` to define an attribute of `id`.\n\n `attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if and only if the key is absent from the payload response.\n\n Example\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n @attr('boolean', { defaultValue: false }) verified;\n }\n ```\n\n Default value can also be a function. This is useful it you want to return\n a new object for each attribute.\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n\n @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n }\n ```\n\n The `options` hash is passed as second argument to a transforms'\n `serialize` and `deserialize` method. This allows to configure a\n transformation and adapt the corresponding value, based on the config:\n\n ```app/models/post.js\n import Model, { attr } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n }\n ```\n\n ```app/transforms/text.js\n export default class TextTransform {\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n }\n\n deserialize(value) {\n return value;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @method attr\n @public\n @static\n @for @ember-data/model\n @param {String|Object} type the attribute type\n @param {Object} options a hash of options\n @return {Attribute}\n*/\nfunction attr(type, options) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n options = options || {};\n }\n\n let meta = {\n type: type,\n isAttribute: true,\n options: options,\n };\n\n return computed({\n get(key) {\n if (DEBUG) {\n if (['currentState'].indexOf(key) !== -1) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n return peekCache(this).getAttr(recordIdentifierFor(this), key);\n },\n set(key, value) {\n if (DEBUG) {\n if (['currentState'].indexOf(key) !== -1) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n assert(\n `Attempted to set '${key}' on the deleted record ${recordIdentifierFor(this)}`,\n !this.currentState.isDeleted\n );\n const identifier = recordIdentifierFor(this);\n const cache = peekCache(this);\n\n let currentValue = cache.getAttr(identifier, key);\n if (currentValue !== value) {\n cache.setAttr(identifier, key, value);\n\n if (!this.isValid) {\n const { errors } = this;\n if (errors.get(key)) {\n errors.remove(key);\n this.currentState.cleanErrorRequests();\n }\n }\n }\n\n return value;\n },\n }).meta(meta);\n}\n\nexport default computedMacroWithOptionalParams(attr);\n","import { assert, warn } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@ember-data/env';\n\nimport { lookupLegacySupport } from './model';\nimport { computedMacroWithOptionalParams, normalizeModelName } from './util';\n\n/**\n @module @ember-data/model\n*/\n\n/**\n `belongsTo` is used to define One-To-One and One-To-Many\n relationships on a [Model](/ember-data/release/classes/Model).\n\n\n `belongsTo` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.\n - `inverse`: A string used to identify the inverse property on a\n related model in a One-To-Many relationship. See [Explicit Inverses](#explicit-inverses)\n - `polymorphic` A boolean value to mark the relationship as polymorphic\n\n #### One-To-One\n To declare a one-to-one relationship between two models, use\n `belongsTo`:\n\n ```app/models/user.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @belongsTo('profile') profile;\n }\n ```\n\n ```app/models/profile.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class ProfileModel extends Model {\n @belongsTo('user') user;\n }\n ```\n\n #### One-To-Many\n\n To declare a one-to-many relationship between two models, use\n `belongsTo` in combination with `hasMany`, like this:\n\n ```app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n ```\n\n ```app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class CommentModel extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n ```\n\n #### Sync relationships\n\n Ember Data resolves sync relationships with the related resources\n available in its local store, hence it is expected these resources\n to be loaded before or along-side the primary resource.\n\n ```app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class CommentModel extends Model {\n @belongsTo('post', {\n async: false,\n inverse: null\n })\n post;\n }\n ```\n\n In contrast to async relationship, accessing a sync relationship\n will always return the record (Model instance) for the existing\n local resource, or null. But it will error on access when\n a related resource is known to exist and it has not been loaded.\n\n ```\n let post = comment.post;\n\n ```\n\n @method belongsTo\n @public\n @static\n @for @ember-data/model\n @param {String} modelName (optional) type of the relationship\n @param {Object} options (optional) a hash of options\n @return {Ember.computed} relationship\n*/\nfunction belongsTo(modelName, options) {\n let opts = options;\n let userEnteredModelName = modelName;\n\n assert(\n `Expected options.async from @belongsTo('${userEnteredModelName}', options) to be a boolean`,\n opts && typeof opts.async === 'boolean'\n );\n assert(\n `Expected options.inverse from @belongsTo('${userEnteredModelName}', options) to be either null or the string type of the related resource.`,\n opts.inverse === null || (typeof opts.inverse === 'string' && opts.inverse.length > 0)\n );\n\n let meta = {\n type: normalizeModelName(userEnteredModelName),\n isRelationship: true,\n options: opts,\n kind: 'belongsTo',\n name: 'Belongs To',\n key: null,\n };\n\n return computed({\n get(key) {\n // this is a legacy behavior we may not carry into a new model setup\n // it's better to error on disconnected records so users find errors\n // in their logic.\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n\n if (DEBUG) {\n if (['currentState'].indexOf(key) !== -1) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n if (Object.prototype.hasOwnProperty.call(opts, 'serialize')) {\n warn(\n `You provided a serialize option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`,\n false,\n {\n id: 'ds.model.serialize-option-in-belongs-to',\n }\n );\n }\n\n if (Object.prototype.hasOwnProperty.call(opts, 'embedded')) {\n warn(\n `You provided an embedded option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`,\n false,\n {\n id: 'ds.model.embedded-option-in-belongs-to',\n }\n );\n }\n }\n\n return support.getBelongsTo(key);\n },\n set(key, value) {\n const support = lookupLegacySupport(this);\n if (DEBUG) {\n if (['currentState'].indexOf(key) !== -1) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n }\n this.store._join(() => {\n support.setDirtyBelongsTo(key, value);\n });\n\n return support.getBelongsTo(key);\n },\n }).meta(meta);\n}\n\nexport default computedMacroWithOptionalParams(belongsTo);\n","/**\n @module @ember-data/model\n*/\nimport { A } from '@ember/array';\nimport { assert, deprecate } from '@ember/debug';\nimport { computed } from '@ember/object';\nimport { dasherize } from '@ember/string';\n\nimport { singularize } from 'ember-inflector';\n\nimport { DEPRECATE_NON_STRICT_TYPES } from '@ember-data/deprecations';\nimport { DEBUG } from '@ember-data/env';\n\nimport { lookupLegacySupport } from './model';\nimport { computedMacroWithOptionalParams } from './util';\n\nfunction normalizeType(type) {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = singularize(dasherize(type));\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '5.3',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n\n/**\n `hasMany` is used to define One-To-Many and Many-To-Many\n relationships on a [Model](/ember-data/release/classes/Model).\n\n `hasMany` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.\n - `inverse`: A string used to identify the inverse property on a related model.\n - `polymorphic` A boolean value to mark the relationship as polymorphic\n\n #### One-To-Many\n To declare a one-to-many relationship between two models, use\n `belongsTo` in combination with `hasMany`, like this:\n\n ```app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @hasMany('comment') comments;\n }\n ```\n\n ```app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class CommentModel extends Model {\n @belongsTo('post') post;\n }\n ```\n\n #### Many-To-Many\n To declare a many-to-many relationship between two models, use\n `hasMany`:\n\n ```app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @hasMany('tag') tags;\n }\n ```\n\n ```app/models/tag.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class TagModel extends Model {\n @hasMany('post') posts;\n }\n ```\n\n You can avoid passing a string as the first parameter. In that case Ember Data\n will infer the type from the singularized key name.\n\n ```app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @hasMany tags;\n }\n ```\n\n will lookup for a Tag type.\n\n #### Explicit Inverses\n\n Ember Data will do its best to discover which relationships map to\n one another. In the one-to-many code above, for example, Ember Data\n can figure out that changing the `comments` relationship should update\n the `post` relationship on the inverse because post is the only\n relationship to that model.\n\n However, sometimes you may have multiple `belongsTo`/`hasMany` for the\n same type. You can specify which property on the related model is\n the inverse using `hasMany`'s `inverse` option:\n\n ```app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class CommentModel extends Model {\n @belongsTo('post') onePost;\n @belongsTo('post') twoPost\n @belongsTo('post') redPost;\n @belongsTo('post') bluePost;\n }\n ```\n\n ```app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', {\n inverse: 'redPost'\n })\n comments;\n }\n ```\n\n You can also specify an inverse on a `belongsTo`, which works how\n you'd expect.\n\n #### Sync relationships\n\n Ember Data resolves sync relationships with the related resources\n available in its local store, hence it is expected these resources\n to be loaded before or along-side the primary resource.\n\n ```app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', {\n async: false\n })\n comments;\n }\n ```\n\n In contrast to async relationship, accessing a sync relationship\n will always return a [ManyArray](/ember-data/release/classes/ManyArray) instance\n containing the existing local resources. But it will error on access\n when any of the known related resources have not been loaded.\n\n ```\n post.comments.forEach((comment) => {\n\n });\n\n ```\n\n If you are using `links` with sync relationships, you have to use\n `ref.reload` to fetch the resources.\n\n @method hasMany\n @public\n @static\n @for @ember-data/model\n @param {String} type (optional) type of the relationship\n @param {Object} options (optional) a hash of options\n @return {Ember.computed} relationship\n*/\nfunction hasMany(type, options) {\n assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');\n\n // Metadata about relationships is stored on the meta of\n // the relationship. This is used for introspection and\n // serialization. Note that `key` is populated lazily\n // the first time the CP is called.\n let meta = {\n type: normalizeType(type),\n options,\n isRelationship: true,\n kind: 'hasMany',\n name: 'Has Many',\n key: null,\n };\n\n return computed({\n get(key) {\n if (DEBUG) {\n if (['currentState'].indexOf(key) !== -1) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroying || this.isDestroyed) {\n return A();\n }\n return lookupLegacySupport(this).getHasMany(key);\n },\n set(key, records) {\n if (DEBUG) {\n if (['currentState'].indexOf(key) !== -1) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n const support = lookupLegacySupport(this);\n const manyArray = support.getManyArray(key);\n assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));\n this.store._join(() => {\n manyArray.splice(0, manyArray.length, ...records);\n });\n\n return support.getHasMany(key);\n },\n }).meta(meta);\n}\n\nexport default computedMacroWithOptionalParams(hasMany);\n"],"names":["attr","type","options","undefined","meta","isAttribute","computed","get","key","macroCondition","getOwnConfig","env","DEBUG","indexOf","Error","constructor","toString","isDestroyed","isDestroying","peekCache","getAttr","recordIdentifierFor","set","value","assert","currentState","isDeleted","identifier","cache","currentValue","setAttr","isValid","errors","remove","cleanErrorRequests","computedMacroWithOptionalParams","belongsTo","modelName","opts","userEnteredModelName","async","inverse","length","normalizeModelName","isRelationship","kind","name","support","lookupLegacySupport","Object","prototype","hasOwnProperty","call","warn","id","getBelongsTo","store","_join","setDirtyBelongsTo","normalizeType","deprecations","DEPRECATE_NON_STRICT_TYPES","result","singularize","dasherize","deprecate","until","for","since","available","enabled","hasMany","A","getHasMany","records","manyArray","getManyArray","Array","isArray","splice"],"mappings":";;;;;;;;;;AASA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAIA,CAACC,IAAI,EAAEC,OAAO,EAAE;AAC3B,EAAA,IAAI,OAAOD,IAAI,KAAK,QAAQ,EAAE;AAC5BC,IAAAA,OAAO,GAAGD,IAAI,CAAA;AACdA,IAAAA,IAAI,GAAGE,SAAS,CAAA;AAClB,GAAC,MAAM;AACLD,IAAAA,OAAO,GAAGA,OAAO,IAAI,EAAE,CAAA;AACzB,GAAA;AAEA,EAAA,IAAIE,IAAI,GAAG;AACTH,IAAAA,IAAI,EAAEA,IAAI;AACVI,IAAAA,WAAW,EAAE,IAAI;AACjBH,IAAAA,OAAO,EAAEA,OAAAA;GACV,CAAA;AAED,EAAA,OAAOI,QAAQ,CAAC;IACdC,GAAGA,CAACC,GAAG,EAAE;AACP,MAAA,IAAAC,cAAA,CAAAC,YAAA,GAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;QACT,IAAI,CAAC,cAAc,CAAC,CAACC,OAAO,CAACL,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;AACxC,UAAA,MAAM,IAAIM,KAAK,CACZ,CAAA,CAAA,EAAGN,GAAI,CAAkI,gIAAA,EAAA,IAAI,CAACO,WAAW,CAAC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,WAAC,GAAG,IAAI,CAAA;AACvB,UAAA,IAAIA,MAAM,CAACzB,GAAG,CAACC,GAAG,CAAC,EAAE;AACnBwB,YAAAA,MAAM,CAACC,MAAM,CAACzB,GAAG,CAAC,CAAA;AAClB,YAAA,IAAI,CAACiB,YAAY,CAACS,kBAAkB,EAAE,CAAA;AACxC,WAAA;AACF,SAAA;AACF,OAAA;AAEA,MAAA,OAAOX,KAAK,CAAA;AACd,KAAA;AACF,GAAC,CAAC,CAACnB,IAAI,CAACA,IAAI,CAAC,CAAA;AACf,CAAA;AAEA,aAAe+B,+BAA+B,CAACnC,IAAI,CAAC;;AC5JpD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASoC,SAASA,CAACC,SAAS,EAAEnC,OAAO,EAAE;EACrC,IAAIoC,IAAI,GAAGpC,OAAO,CAAA;EAClB,IAAIqC,oBAAoB,GAAGF,SAAS,CAAA;AAEpCb,EAAAA,MAAM,CACH,CAAA,wCAAA,EAA0Ce,oBAAqB,CAAA,2BAAA,CAA4B,EAC5FD,IAAI,IAAI,OAAOA,IAAI,CAACE,KAAK,KAAK,SAChC,CAAC,CAAA;EACDhB,MAAM,CACH,CAA4Ce,0CAAAA,EAAAA,oBAAqB,CAA0E,yEAAA,CAAA,EAC5ID,IAAI,CAACG,OAAO,KAAK,IAA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C3B,EAAA,IAAAQ,cAAA,CAAAC,YAAA,GAAAkD,YAAA,CAAAC,0BAAA,CAAgC,EAAA;IAC9B,MAAMC,MAAM,GAAGC,WAAW,CAACC,SAAS,CAAC/D,IAAI,CAAC,CAAC,CAAA;AAE3CgE,IAAAA,SAAS,CACN,CAAA,mBAAA,EAAqBhE,IAAK,CAAA,0DAAA,EAA4D6D,MAAO,CAAA,cAAA,EAAgB7D,IAAK,CAAA,EAAA,CAAG,EACtH6D,MAAM,KAAK7D,IAAI,EACf;AACEqD,MAAAA,EAAE,EAAE,uCAAuC;AAC3CY,MAAAA,KAAK,EAAE,KAAK;AACZC,MAAAA,GAAG,EAAE,YAAY;AACjBC,MAAAA,KAAK,EAAE;AACLC,QAAAA,SAAS,EAAE,KAAK;AAChBC,QAAAA,OAAO,EAAE,KAAA;AACX,OAAA;AACF,KACF,CAAC,CAAA;AAED,IAAA,OAAOR,MAAM,CAAA;AACf,GAAA;AAEA,EAAA,OAAO7D,IAAI,CAAA;AACb,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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