@ember-data/model 5.3.3 → 5.3.4

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.
Files changed (92) hide show
  1. package/README.md +19 -0
  2. package/addon-main.cjs +5 -0
  3. package/blueprints/model/index.js +18 -5
  4. package/blueprints/model-test/index.js +16 -10
  5. package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
  6. package/{addon → dist}/-private.js +2 -2
  7. package/dist/has-many-78F2FHCC.js +674 -0
  8. package/dist/has-many-78F2FHCC.js.map +1 -0
  9. package/dist/hooks-BgrTI_ff.js +75 -0
  10. package/dist/hooks-BgrTI_ff.js.map +1 -0
  11. package/dist/hooks.js +2 -0
  12. package/{addon → dist}/hooks.js.map +1 -1
  13. package/dist/index.js +4 -0
  14. package/{addon → dist}/index.js.map +1 -1
  15. package/dist/migration-support.js +210 -0
  16. package/dist/migration-support.js.map +1 -0
  17. package/{addon/model-YsOraZ6y.js → dist/model-BFnMMaye.js} +889 -424
  18. package/dist/model-BFnMMaye.js.map +1 -0
  19. package/dist/schema-provider-Cgpcwfn7.js +256 -0
  20. package/dist/schema-provider-Cgpcwfn7.js.map +1 -0
  21. package/ember-data-logo-dark.svg +12 -0
  22. package/ember-data-logo-light.svg +12 -0
  23. package/package.json +54 -74
  24. package/unstable-preview-types/-private/attr.d.ts +174 -0
  25. package/unstable-preview-types/-private/attr.d.ts.map +1 -0
  26. package/unstable-preview-types/-private/attr.type-test.d.ts +4 -0
  27. package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
  28. package/unstable-preview-types/-private/belongs-to.d.ts +180 -0
  29. package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
  30. package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -0
  31. package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
  32. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -0
  33. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  34. package/unstable-preview-types/-private/errors.d.ts +305 -0
  35. package/unstable-preview-types/-private/errors.d.ts.map +1 -0
  36. package/unstable-preview-types/-private/has-many.d.ts +169 -0
  37. package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
  38. package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -0
  39. package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
  40. package/unstable-preview-types/-private/hooks.d.ts +13 -0
  41. package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
  42. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
  43. package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
  44. package/unstable-preview-types/-private/many-array.d.ts +196 -0
  45. package/unstable-preview-types/-private/many-array.d.ts.map +1 -0
  46. package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -0
  47. package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
  48. package/unstable-preview-types/-private/model-methods.d.ts +37 -0
  49. package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
  50. package/unstable-preview-types/-private/model.d.ts +1306 -0
  51. package/unstable-preview-types/-private/model.d.ts.map +1 -0
  52. package/unstable-preview-types/-private/model.type-test.d.ts +4 -0
  53. package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
  54. package/unstable-preview-types/-private/notify-changes.d.ts +8 -0
  55. package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
  56. package/unstable-preview-types/-private/promise-belongs-to.d.ts +48 -0
  57. package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
  58. package/unstable-preview-types/-private/promise-many-array.d.ts +131 -0
  59. package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
  60. package/unstable-preview-types/-private/record-state.d.ts +90 -0
  61. package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
  62. package/unstable-preview-types/-private/references/belongs-to.d.ts +503 -0
  63. package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
  64. package/unstable-preview-types/-private/references/has-many.d.ts +515 -0
  65. package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
  66. package/unstable-preview-types/-private/schema-provider.d.ts +64 -0
  67. package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
  68. package/unstable-preview-types/-private/type-utils.d.ts +64 -0
  69. package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
  70. package/unstable-preview-types/-private/util.d.ts +11 -0
  71. package/unstable-preview-types/-private/util.d.ts.map +1 -0
  72. package/unstable-preview-types/-private.d.ts +13 -0
  73. package/unstable-preview-types/-private.d.ts.map +1 -0
  74. package/unstable-preview-types/hooks.d.ts +5 -0
  75. package/unstable-preview-types/hooks.d.ts.map +1 -0
  76. package/unstable-preview-types/index.d.ts +76 -0
  77. package/unstable-preview-types/index.d.ts.map +1 -0
  78. package/unstable-preview-types/migration-support.d.ts +56 -0
  79. package/unstable-preview-types/migration-support.d.ts.map +1 -0
  80. package/addon/has-many-PdQBns8a.js +0 -323
  81. package/addon/has-many-PdQBns8a.js.map +0 -1
  82. package/addon/hooks-dXmQbIOF.js +0 -176
  83. package/addon/hooks-dXmQbIOF.js.map +0 -1
  84. package/addon/hooks.js +0 -1
  85. package/addon/index.js +0 -3
  86. package/addon/migration-support.js +0 -118
  87. package/addon/migration-support.js.map +0 -1
  88. package/addon/model-YsOraZ6y.js.map +0 -1
  89. package/addon/util-3DHZJC9h.js +0 -38
  90. package/addon/util-3DHZJC9h.js.map +0 -1
  91. package/addon-main.js +0 -93
  92. /package/{addon → dist}/-private.js.map +0 -0
@@ -0,0 +1,1306 @@
1
+ declare module '@ember-data/model/-private/model' {
2
+ /**
3
+ @module @ember-data/model
4
+ */
5
+ /// <reference types="ember-source/types" />
6
+ import EmberObject from '@ember/object';
7
+ import type { Snapshot } from '@ember-data/legacy-compat/-private';
8
+ import type Store from '@ember-data/store';
9
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
10
+ import type { Cache, ChangedAttributesHash } from '@warp-drive/core-types/cache';
11
+ import type { LegacyAttributeField, LegacyRelationshipSchema } from '@warp-drive/core-types/schema/fields';
12
+ import { RecordStore } from '@warp-drive/core-types/symbols';
13
+ import { Errors } from '@ember-data/model/-private/errors';
14
+ import type { MinimalLegacyRecord } from '@ember-data/model/-private/model-methods';
15
+ import RecordState from '@ember-data/model/-private/record-state';
16
+ import type BelongsToReference from '@ember-data/model/-private/references/belongs-to';
17
+ import type HasManyReference from '@ember-data/model/-private/references/has-many';
18
+ import type { _MaybeBelongsToFields, isSubClass, MaybeAttrFields, MaybeHasManyFields, MaybeRelationshipFields } from '@ember-data/model/-private/type-utils';
19
+ export type ModelCreateArgs = {
20
+ _createProps: Record<string, unknown>;
21
+ _secretInit: {
22
+ identifier: StableRecordIdentifier;
23
+ cache: Cache;
24
+ store: Store;
25
+ cb: (record: Model, cache: Cache, identifier: StableRecordIdentifier, store: Store) => void;
26
+ };
27
+ };
28
+ export type StaticModel = typeof Model & {
29
+ create(options: ModelCreateArgs): Model;
30
+ };
31
+ export type ModelFactory = {
32
+ class: StaticModel;
33
+ };
34
+ export type FactoryCache = Record<string, ModelFactory>;
35
+ export type ModelStore = Store & {
36
+ _modelFactoryCache: FactoryCache;
37
+ };
38
+ /**
39
+ Base class from which Models can be defined.
40
+
41
+ ```js
42
+ import Model, { attr } from '@ember-data/model';
43
+
44
+ export default class User extends Model {
45
+ @attr name;
46
+ }
47
+ ```
48
+
49
+ Models are used both to define the static schema for a
50
+ particular resource type as well as the class to instantiate
51
+ to present that data from cache.
52
+
53
+ @class Model
54
+ @public
55
+ @extends Ember.EmberObject
56
+ */
57
+ interface Model {
58
+ serialize<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown> | undefined): unknown;
59
+ destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
60
+ unloadRecord<T extends MinimalLegacyRecord>(this: T): void;
61
+ changedAttributes<T extends MinimalLegacyRecord>(this: T): ChangedAttributesHash;
62
+ rollbackAttributes<T extends MinimalLegacyRecord>(this: T): void;
63
+ _createSnapshot<T extends MinimalLegacyRecord>(this: T): Snapshot<T>;
64
+ save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
65
+ reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
66
+ belongsTo<T extends Model, K extends keyof T & string>(this: T, prop: K & (K extends _MaybeBelongsToFields<T> ? K : never)): BelongsToReference<T, K>;
67
+ hasMany<T extends MinimalLegacyRecord, K extends MaybeHasManyFields<T>>(this: T, prop: K): HasManyReference<T, K>;
68
+ deleteRecord<T extends MinimalLegacyRecord>(this: T): void;
69
+ }
70
+ class Model extends EmberObject implements MinimalLegacyRecord {
71
+ store: Store;
72
+ ___recordState: RecordState;
73
+ ___private_notifications: object;
74
+ [RecordStore]: Store;
75
+ init(options: ModelCreateArgs): void;
76
+ destroy(): this;
77
+ /**
78
+ If this property is `true` the record is in the `empty`
79
+ state. Empty is the first state all records enter after they have
80
+ been created. Most records created by the store will quickly
81
+ transition to the `loading` state if data needs to be fetched from
82
+ the server or the `created` state if the record is created on the
83
+ client. A record can also enter the empty state if the adapter is
84
+ unable to locate the record.
85
+
86
+ @property isEmpty
87
+ @public
88
+ @type {Boolean}
89
+ @readOnly
90
+ */
91
+ get isEmpty(): boolean;
92
+ /**
93
+ If this property is `true` the record is in the `loading` state. A
94
+ record enters this state when the store asks the adapter for its
95
+ data. It remains in this state until the adapter provides the
96
+ requested data.
97
+
98
+ @property isLoading
99
+ @public
100
+ @type {Boolean}
101
+ @readOnly
102
+ */
103
+ get isLoading(): boolean;
104
+ /**
105
+ If this property is `true` the record is in the `loaded` state. A
106
+ record enters this state when its data is populated. Most of a
107
+ record's lifecycle is spent inside substates of the `loaded`
108
+ state.
109
+
110
+ Example
111
+
112
+ ```javascript
113
+ let record = store.createRecord('model');
114
+ record.isLoaded; // true
115
+
116
+ store.findRecord('model', 1).then(function(model) {
117
+ model.isLoaded; // true
118
+ });
119
+ ```
120
+
121
+ @property isLoaded
122
+ @public
123
+ @type {Boolean}
124
+ @readOnly
125
+ */
126
+ get isLoaded(): boolean;
127
+ /**
128
+ If this property is `true` the record is in the `dirty` state. The
129
+ record has local changes that have not yet been saved by the
130
+ adapter. This includes records that have been created (but not yet
131
+ saved) or deleted.
132
+
133
+ Example
134
+
135
+ ```javascript
136
+ let record = store.createRecord('model');
137
+ record.hasDirtyAttributes; // true
138
+
139
+ store.findRecord('model', 1).then(function(model) {
140
+ model.hasDirtyAttributes; // false
141
+ model.set('foo', 'some value');
142
+ model.hasDirtyAttributes; // true
143
+ });
144
+ ```
145
+
146
+ @since 1.13.0
147
+ @property hasDirtyAttributes
148
+ @public
149
+ @type {Boolean}
150
+ @readOnly
151
+ */
152
+ get hasDirtyAttributes(): boolean;
153
+ /**
154
+ If this property is `true` the record is in the `saving` state. A
155
+ record enters the saving state when `save` is called, but the
156
+ adapter has not yet acknowledged that the changes have been
157
+ persisted to the backend.
158
+
159
+ Example
160
+
161
+ ```javascript
162
+ let record = store.createRecord('model');
163
+ record.isSaving; // false
164
+ let promise = record.save();
165
+ record.isSaving; // true
166
+ promise.then(function() {
167
+ record.isSaving; // false
168
+ });
169
+ ```
170
+
171
+ @property isSaving
172
+ @public
173
+ @type {Boolean}
174
+ @readOnly
175
+ */
176
+ get isSaving(): boolean;
177
+ /**
178
+ If this property is `true` the record is in the `deleted` state
179
+ and has been marked for deletion. When `isDeleted` is true and
180
+ `hasDirtyAttributes` is true, the record is deleted locally but the deletion
181
+ was not yet persisted. When `isSaving` is true, the change is
182
+ in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the
183
+ change has persisted.
184
+
185
+ Example
186
+
187
+ ```javascript
188
+ let record = store.createRecord('model');
189
+ record.isDeleted; // false
190
+ record.deleteRecord();
191
+
192
+ // Locally deleted
193
+ record.isDeleted; // true
194
+ record.hasDirtyAttributes; // true
195
+ record.isSaving; // false
196
+
197
+ // Persisting the deletion
198
+ let promise = record.save();
199
+ record.isDeleted; // true
200
+ record.isSaving; // true
201
+
202
+ // Deletion Persisted
203
+ promise.then(function() {
204
+ record.isDeleted; // true
205
+ record.isSaving; // false
206
+ record.hasDirtyAttributes; // false
207
+ });
208
+ ```
209
+
210
+ @property isDeleted
211
+ @public
212
+ @type {Boolean}
213
+ @readOnly
214
+ */
215
+ get isDeleted(): boolean;
216
+ /**
217
+ If this property is `true` the record is in the `new` state. A
218
+ record will be in the `new` state when it has been created on the
219
+ client and the adapter has not yet report that it was successfully
220
+ saved.
221
+
222
+ Example
223
+
224
+ ```javascript
225
+ let record = store.createRecord('model');
226
+ record.isNew; // true
227
+
228
+ record.save().then(function(model) {
229
+ model.isNew; // false
230
+ });
231
+ ```
232
+
233
+ @property isNew
234
+ @public
235
+ @type {Boolean}
236
+ @readOnly
237
+ */
238
+ get isNew(): boolean;
239
+ /**
240
+ If this property is `true` the record is in the `valid` state.
241
+
242
+ A record will be in the `valid` state when the adapter did not report any
243
+ server-side validation failures.
244
+
245
+ @property isValid
246
+ @public
247
+ @type {Boolean}
248
+ @readOnly
249
+ */
250
+ get isValid(): boolean;
251
+ /**
252
+ If the record is in the dirty state this property will report what
253
+ kind of change has caused it to move into the dirty
254
+ state. Possible values are:
255
+
256
+ - `created` The record has been created by the client and not yet saved to the adapter.
257
+ - `updated` The record has been updated by the client and not yet saved to the adapter.
258
+ - `deleted` The record has been deleted by the client and not yet saved to the adapter.
259
+
260
+ Example
261
+
262
+ ```javascript
263
+ let record = store.createRecord('model');
264
+ record.dirtyType; // 'created'
265
+ ```
266
+
267
+ @property dirtyType
268
+ @public
269
+ @type {String}
270
+ @readOnly
271
+ */
272
+ get dirtyType(): 'created' | 'updated' | 'deleted' | '';
273
+ /**
274
+ If `true` the adapter reported that it was unable to save local
275
+ changes to the backend for any reason other than a server-side
276
+ validation error.
277
+
278
+ Example
279
+
280
+ ```javascript
281
+ record.isError; // false
282
+ record.set('foo', 'valid value');
283
+ record.save().then(null, function() {
284
+ record.isError; // true
285
+ });
286
+ ```
287
+
288
+ @property isError
289
+ @public
290
+ @type {Boolean}
291
+ @readOnly
292
+ */
293
+ get isError(): boolean;
294
+ set isError(v: boolean);
295
+ /**
296
+ If `true` the store is attempting to reload the record from the adapter.
297
+
298
+ Example
299
+
300
+ ```javascript
301
+ record.isReloading; // false
302
+ record.reload();
303
+ record.isReloading; // true
304
+ ```
305
+
306
+ @property isReloading
307
+ @public
308
+ @type {Boolean}
309
+ @readOnly
310
+ */
311
+ isReloading: boolean;
312
+ /**
313
+ All ember models have an id property. This is an identifier
314
+ managed by an external source. These are always coerced to be
315
+ strings before being used internally. Note when declaring the
316
+ attributes for a model it is an error to an id
317
+ attribute.
318
+
319
+ ```javascript
320
+ let record = store.createRecord('model');
321
+ record.id; // null
322
+
323
+ store.findRecord('model', 1).then(function(model) {
324
+ model.id; // '1'
325
+ });
326
+ ```
327
+
328
+ @property id
329
+ @public
330
+ @type {String}
331
+ */
332
+ get id(): string | null;
333
+ set id(id: string | null);
334
+ toString(): string;
335
+ /**
336
+ @property currentState
337
+ @private
338
+ @type {Object}
339
+ */
340
+ get currentState(): RecordState;
341
+ set currentState(_v: RecordState);
342
+ /**
343
+ The store service instance which created this record instance
344
+
345
+ @property store
346
+ @public
347
+ */
348
+ /**
349
+ When the record is in the `invalid` state this object will contain
350
+ any errors returned by the adapter. When present the errors hash
351
+ contains keys corresponding to the invalid property names
352
+ and values which are arrays of Javascript objects with two keys:
353
+
354
+ - `message` A string containing the error message from the backend
355
+ - `attribute` The name of the property associated with this error message
356
+
357
+ ```javascript
358
+ record.errors.length; // 0
359
+ record.set('foo', 'invalid value');
360
+ record.save().catch(function() {
361
+ record.errors.foo;
362
+ // [{message: 'foo should be a number.', attribute: 'foo'}]
363
+ });
364
+ ```
365
+
366
+ The `errors` property is useful for displaying error messages to
367
+ the user.
368
+
369
+ ```handlebars
370
+ <label>Username: <Input @value={{@model.username}} /> </label>
371
+ {{#each @model.errors.username as |error|}}
372
+ <div class="error">
373
+ {{error.message}}
374
+ </div>
375
+ {{/each}}
376
+ <label>Email: <Input @value={{@model.email}} /> </label>
377
+ {{#each @model.errors.email as |error|}}
378
+ <div class="error">
379
+ {{error.message}}
380
+ </div>
381
+ {{/each}}
382
+ ```
383
+
384
+
385
+ You can also access the special `messages` property on the error
386
+ object to get an array of all the error strings.
387
+
388
+ ```handlebars
389
+ {{#each @model.errors.messages as |message|}}
390
+ <div class="error">
391
+ {{message}}
392
+ </div>
393
+ {{/each}}
394
+ ```
395
+
396
+ @property errors
397
+ @public
398
+ @type {Errors}
399
+ */
400
+ get errors(): Errors;
401
+ /**
402
+ This property holds the `AdapterError` object with which
403
+ last adapter operation was rejected.
404
+
405
+ @property adapterError
406
+ @public
407
+ @type {AdapterError}
408
+ */
409
+ get adapterError(): unknown;
410
+ set adapterError(v: unknown);
411
+ /**
412
+ Create a JSON representation of the record, using the serialization
413
+ strategy of the store's adapter.
414
+
415
+ `serialize` takes an optional hash as a parameter, currently
416
+ supported options are:
417
+
418
+ - `includeId`: `true` if the record's ID should be included in the
419
+ JSON representation.
420
+
421
+ @method serialize
422
+ @public
423
+ @param {Object} options
424
+ @return {Object} an object whose values are primitive JSON values only
425
+ */
426
+ notifyPropertyChange(prop: string): this;
427
+ /**
428
+ Marks the record as deleted but does not save it. You must call
429
+ `save` afterwards if you want to persist it. You might use this
430
+ method if you want to allow the user to still `rollbackAttributes()`
431
+ after a delete was made.
432
+
433
+ Example
434
+
435
+ ```js
436
+ import Component from '@glimmer/component';
437
+
438
+ export default class extends Component {
439
+ softDelete = () => {
440
+ this.args.model.deleteRecord();
441
+ }
442
+
443
+ confirm = () => {
444
+ this.args.model.save();
445
+ }
446
+
447
+ undo = () => {
448
+ this.args.model.rollbackAttributes();
449
+ }
450
+ }
451
+ ```
452
+
453
+ @method deleteRecord
454
+ @public
455
+ */
456
+ /**
457
+ Same as `deleteRecord`, but saves the record immediately.
458
+
459
+ Example
460
+
461
+ ```js
462
+ import Component from '@glimmer/component';
463
+
464
+ export default class extends Component {
465
+ delete = () => {
466
+ this.args.model.destroyRecord().then(function() {
467
+ this.transitionToRoute('model.index');
468
+ });
469
+ }
470
+ }
471
+ ```
472
+
473
+ If you pass an object on the `adapterOptions` property of the options
474
+ argument it will be passed to your adapter via the snapshot
475
+
476
+ ```js
477
+ record.destroyRecord({ adapterOptions: { subscribe: false } });
478
+ ```
479
+
480
+ ```app/adapters/post.js
481
+ import MyCustomAdapter from './custom-adapter';
482
+
483
+ export default class PostAdapter extends MyCustomAdapter {
484
+ deleteRecord(store, type, snapshot) {
485
+ if (snapshot.adapterOptions.subscribe) {
486
+ // ...
487
+ }
488
+ // ...
489
+ }
490
+ }
491
+ ```
492
+
493
+ @method destroyRecord
494
+ @public
495
+ @param {Object} options
496
+ @return {Promise} a promise that will be resolved when the adapter returns
497
+ successfully or rejected if the adapter returns with an error.
498
+ */
499
+ /**
500
+ Unloads the record from the store. This will not send a delete request
501
+ to your server, it just unloads the record from memory.
502
+
503
+ @method unloadRecord
504
+ @public
505
+ */
506
+ /**
507
+ Returns an object, whose keys are changed properties, and value is
508
+ an [oldProp, newProp] array.
509
+
510
+ The array represents the diff of the canonical state with the local state
511
+ of the model. Note: if the model is created locally, the canonical state is
512
+ empty since the adapter hasn't acknowledged the attributes yet:
513
+
514
+ Example
515
+
516
+ ```app/models/mascot.js
517
+ import Model, { attr } from '@ember-data/model';
518
+
519
+ export default class MascotModel extends Model {
520
+ @attr('string') name;
521
+ @attr('boolean', {
522
+ defaultValue: false
523
+ })
524
+ isAdmin;
525
+ }
526
+ ```
527
+
528
+ ```javascript
529
+ let mascot = store.createRecord('mascot');
530
+
531
+ mascot.changedAttributes(); // {}
532
+
533
+ mascot.set('name', 'Tomster');
534
+ mascot.changedAttributes(); // { name: [undefined, 'Tomster'] }
535
+
536
+ mascot.set('isAdmin', true);
537
+ mascot.changedAttributes(); // { isAdmin: [undefined, true], name: [undefined, 'Tomster'] }
538
+
539
+ mascot.save().then(function() {
540
+ mascot.changedAttributes(); // {}
541
+
542
+ mascot.set('isAdmin', false);
543
+ mascot.changedAttributes(); // { isAdmin: [true, false] }
544
+ });
545
+ ```
546
+
547
+ @method changedAttributes
548
+ @public
549
+ @return {Object} an object, whose keys are changed properties,
550
+ and value is an [oldProp, newProp] array.
551
+ */
552
+ /**
553
+ If the model `hasDirtyAttributes` this function will discard any unsaved
554
+ changes. If the model `isNew` it will be removed from the store.
555
+
556
+ Example
557
+
558
+ ```javascript
559
+ record.name; // 'Untitled Document'
560
+ record.set('name', 'Doc 1');
561
+ record.name; // 'Doc 1'
562
+ record.rollbackAttributes();
563
+ record.name; // 'Untitled Document'
564
+ ```
565
+
566
+ @since 1.13.0
567
+ @method rollbackAttributes
568
+ @public
569
+ */
570
+ /**
571
+ @method _createSnapshot
572
+ @private
573
+ */
574
+ /**
575
+ Save the record and persist any changes to the record to an
576
+ external source via the adapter.
577
+
578
+ Example
579
+
580
+ ```javascript
581
+ record.set('name', 'Tomster');
582
+ record.save().then(function() {
583
+ // Success callback
584
+ }, function() {
585
+ // Error callback
586
+ });
587
+ ```
588
+
589
+ If you pass an object using the `adapterOptions` property of the options
590
+ argument it will be passed to your adapter via the snapshot.
591
+
592
+ ```js
593
+ record.save({ adapterOptions: { subscribe: false } });
594
+ ```
595
+
596
+ ```app/adapters/post.js
597
+ import MyCustomAdapter from './custom-adapter';
598
+
599
+ export default class PostAdapter extends MyCustomAdapter {
600
+ updateRecord(store, type, snapshot) {
601
+ if (snapshot.adapterOptions.subscribe) {
602
+ // ...
603
+ }
604
+ // ...
605
+ }
606
+ }
607
+ ```
608
+
609
+ @method save
610
+ @public
611
+ @param {Object} options
612
+ @return {Promise} a promise that will be resolved when the adapter returns
613
+ successfully or rejected if the adapter returns with an error.
614
+ */
615
+ /**
616
+ Reload the record from the adapter.
617
+
618
+ This will only work if the record has already finished loading.
619
+
620
+ Example
621
+
622
+ ```js
623
+ import Component from '@glimmer/component';
624
+
625
+ export default class extends Component {
626
+ async reload = () => {
627
+ await this.args.model.reload();
628
+ // do something with the reloaded model
629
+ }
630
+ }
631
+ ```
632
+
633
+ @method reload
634
+ @public
635
+ @param {Object} options optional, may include `adapterOptions` hash which will be passed to adapter request
636
+
637
+ @return {Promise} a promise that will be resolved with the record when the
638
+ adapter returns successfully or rejected if the adapter returns
639
+ with an error.
640
+ */
641
+ attr(): void;
642
+ /**
643
+ Get the reference for the specified belongsTo relationship.
644
+
645
+ For instance, given the following model
646
+
647
+ ```app/models/blog-post.js
648
+ import Model, { belongsTo } from '@ember-data/model';
649
+
650
+ export default class BlogPost extends Model {
651
+ @belongsTo('user', { async: true, inverse: null }) author;
652
+ }
653
+ ```
654
+
655
+ Then the reference for the author relationship would be
656
+ retrieved from a record instance like so:
657
+
658
+ ```js
659
+ blogPost.belongsTo('author');
660
+ ```
661
+
662
+ A `BelongsToReference` is a low-level API that allows access
663
+ and manipulation of a belongsTo relationship.
664
+
665
+ It is especially useful when you're dealing with `async` relationships
666
+ as it allows synchronous access to the relationship data if loaded, as
667
+ well as APIs for loading, reloading the data or accessing available
668
+ information without triggering a load.
669
+
670
+ It may also be useful when using `sync` relationships that need to be
671
+ loaded/reloaded with more precise timing than marking the
672
+ relationship as `async` and relying on autofetch would have allowed.
673
+
674
+ However,keep in mind that marking a relationship as `async: false` will introduce
675
+ bugs into your application if the data is not always guaranteed to be available
676
+ by the time the relationship is accessed. Ergo, it is recommended when using this
677
+ approach to utilize `links` for unloaded relationship state instead of identifiers.
678
+
679
+ Reference APIs are entangled with the relationship's underlying state,
680
+ thus any getters or cached properties that utilize these will properly
681
+ invalidate if the relationship state changes.
682
+
683
+ References are "stable", meaning that multiple calls to retrieve the reference
684
+ for a given relationship will always return the same HasManyReference.
685
+
686
+ @method belongsTo
687
+ @public
688
+ @param {String} name of the relationship
689
+ @since 2.5.0
690
+ @return {BelongsToReference} reference for this relationship
691
+ */
692
+ /**
693
+ Get the reference for the specified hasMany relationship.
694
+
695
+ For instance, given the following model
696
+
697
+ ```app/models/blog-post.js
698
+ import Model, { hasMany } from '@ember-data/model';
699
+
700
+ export default class BlogPost extends Model {
701
+ @hasMany('comment', { async: true, inverse: null }) comments;
702
+ }
703
+ ```
704
+
705
+ Then the reference for the comments relationship would be
706
+ retrieved from a record instance like so:
707
+
708
+ ```js
709
+ blogPost.hasMany('comments');
710
+ ```
711
+
712
+ A `HasManyReference` is a low-level API that allows access
713
+ and manipulation of a hasMany relationship.
714
+
715
+ It is especially useful when you are dealing with `async` relationships
716
+ as it allows synchronous access to the relationship data if loaded, as
717
+ well as APIs for loading, reloading the data or accessing available
718
+ information without triggering a load.
719
+
720
+ It may also be useful when using `sync` relationships with `@ember-data/model`
721
+ that need to be loaded/reloaded with more precise timing than marking the
722
+ relationship as `async` and relying on autofetch would have allowed.
723
+
724
+ However,keep in mind that marking a relationship as `async: false` will introduce
725
+ bugs into your application if the data is not always guaranteed to be available
726
+ by the time the relationship is accessed. Ergo, it is recommended when using this
727
+ approach to utilize `links` for unloaded relationship state instead of identifiers.
728
+
729
+ Reference APIs are entangled with the relationship's underlying state,
730
+ thus any getters or cached properties that utilize these will properly
731
+ invalidate if the relationship state changes.
732
+
733
+ References are "stable", meaning that multiple calls to retrieve the reference
734
+ for a given relationship will always return the same HasManyReference.
735
+
736
+ @method hasMany
737
+ @public
738
+ @param {String} name of the relationship
739
+ @since 2.5.0
740
+ @return {HasManyReference} reference for this relationship
741
+ */
742
+ /**
743
+ Given a callback, iterates over each of the relationships in the model,
744
+ invoking the callback with the name of each relationship and its relationship
745
+ descriptor.
746
+
747
+
748
+ The callback method you provide should have the following signature (all
749
+ parameters are optional):
750
+
751
+ ```javascript
752
+ function(name, descriptor);
753
+ ```
754
+
755
+ - `name` the name of the current property in the iteration
756
+ - `descriptor` the meta object that describes this relationship
757
+
758
+ The relationship descriptor argument is an object with the following properties.
759
+
760
+ - **name** <span class="type">String</span> the name of this relationship on the Model
761
+ - **kind** <span class="type">String</span> "hasMany" or "belongsTo"
762
+ - **options** <span class="type">Object</span> the original options hash passed when the relationship was declared
763
+ - **parentType** <span class="type">Model</span> the type of the Model that owns this relationship
764
+ - **type** <span class="type">String</span> the type name of the related Model
765
+
766
+ Note that in addition to a callback, you can also pass an optional target
767
+ object that will be set as `this` on the context.
768
+
769
+ Example
770
+
771
+ ```app/serializers/application.js
772
+ import JSONSerializer from '@ember-data/serializer/json';
773
+
774
+ export default class ApplicationSerializer extends JSONSerializer {
775
+ serialize(record, options) {
776
+ let json = {};
777
+
778
+ record.eachRelationship(function(name, descriptor) {
779
+ if (descriptor.kind === 'hasMany') {
780
+ let serializedHasManyName = name.toUpperCase() + '_IDS';
781
+ json[serializedHasManyName] = record.get(name).map(r => r.id);
782
+ }
783
+ });
784
+
785
+ return json;
786
+ }
787
+ }
788
+ ```
789
+
790
+ @method eachRelationship
791
+ @public
792
+ @param {Function} callback the callback to invoke
793
+ @param {any} binding the value to which the callback's `this` should be bound
794
+ */
795
+ eachRelationship<T>(callback: (this: NoInfer<T> | undefined, key: MaybeRelationshipFields<this>, meta: LegacyRelationshipSchema) => void, binding?: T): void;
796
+ relationshipFor(name: string): LegacyRelationshipSchema | undefined;
797
+ inverseFor(name: string): LegacyRelationshipSchema | null;
798
+ eachAttribute<T>(callback: (this: NoInfer<T> | undefined, key: isSubClass<this> extends true ? MaybeAttrFields<this> : string, meta: LegacyAttributeField) => void, binding?: T): void;
799
+ static isModel: boolean;
800
+ /**
801
+ Create should only ever be called by the store. To create an instance of a
802
+ `Model` in a dirty state use `store.createRecord`.
803
+
804
+ To create instances of `Model` in a clean state, use `store.push`
805
+
806
+ @method create
807
+ @private
808
+ @static
809
+ */
810
+ /**
811
+ Represents the model's class name as a string. This can be used to look up the model's class name through
812
+ `Store`'s modelFor method.
813
+
814
+ `modelName` is generated for you by EmberData. It will be a lowercased, dasherized string.
815
+ For example:
816
+
817
+ ```javascript
818
+ store.modelFor('post').modelName; // 'post'
819
+ store.modelFor('blog-post').modelName; // 'blog-post'
820
+ ```
821
+
822
+ The most common place you'll want to access `modelName` is in your serializer's `payloadKeyFromModelName` method. For example, to change payload
823
+ keys to underscore (instead of dasherized), you might use the following code:
824
+
825
+ ```javascript
826
+ import RESTSerializer from '@ember-data/serializer/rest';
827
+ import { underscore } from '<app-name>/utils/string-utils';
828
+
829
+ export default const PostSerializer = RESTSerializer.extend({
830
+ payloadKeyFromModelName(modelName) {
831
+ return underscore(modelName);
832
+ }
833
+ });
834
+ ```
835
+ @property modelName
836
+ @public
837
+ @type String
838
+ @readonly
839
+ @static
840
+ */
841
+ static modelName: string;
842
+ /**
843
+ For a given relationship name, returns the model type of the relationship.
844
+
845
+ For example, if you define a model like this:
846
+
847
+ ```app/models/post.js
848
+ import Model, { hasMany } from '@ember-data/model';
849
+
850
+ export default class PostModel extends Model {
851
+ @hasMany('comment') comments;
852
+ }
853
+ ```
854
+
855
+ Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.
856
+
857
+ @method typeForRelationship
858
+ @public
859
+ @static
860
+ @param {String} name the name of the relationship
861
+ @param {store} store an instance of Store
862
+ @return {Model} the type of the relationship, or undefined
863
+ */
864
+ static typeForRelationship(name: string, store: Store): import("@ember-data/store/types").ModelSchema<unknown> | undefined;
865
+ static get inverseMap(): Record<string, LegacyRelationshipSchema | null>;
866
+ /**
867
+ Find the relationship which is the inverse of the one asked for.
868
+
869
+ For example, if you define models like this:
870
+
871
+ ```app/models/post.js
872
+ import Model, { hasMany } from '@ember-data/model';
873
+
874
+ export default class PostModel extends Model {
875
+ @hasMany('message') comments;
876
+ }
877
+ ```
878
+
879
+ ```app/models/message.js
880
+ import Model, { belongsTo } from '@ember-data/model';
881
+
882
+ export default class MessageModel extends Model {
883
+ @belongsTo('post') owner;
884
+ }
885
+ ```
886
+
887
+ ``` js
888
+ store.modelFor('post').inverseFor('comments', store) // { type: 'message', name: 'owner', kind: 'belongsTo' }
889
+ store.modelFor('message').inverseFor('owner', store) // { type: 'post', name: 'comments', kind: 'hasMany' }
890
+ ```
891
+
892
+ @method inverseFor
893
+ @public
894
+ @static
895
+ @param {String} name the name of the relationship
896
+ @param {Store} store
897
+ @return {Object} the inverse relationship, or null
898
+ */
899
+ static inverseFor(name: string, store: Store): LegacyRelationshipSchema | null;
900
+ static _findInverseFor(name: string, store: Store): LegacyRelationshipSchema | null;
901
+ /**
902
+ The model's relationships as a map, keyed on the type of the
903
+ relationship. The value of each entry is an array containing a descriptor
904
+ for each relationship with that type, describing the name of the relationship
905
+ as well as the type.
906
+
907
+ For example, given the following model definition:
908
+
909
+ ```app/models/blog.js
910
+ import Model, { belongsTo, hasMany } from '@ember-data/model';
911
+
912
+ export default class BlogModel extends Model {
913
+ @hasMany('user') users;
914
+ @belongsTo('user') owner;
915
+ @hasMany('post') posts;
916
+ }
917
+ ```
918
+
919
+ This computed property would return a map describing these
920
+ relationships, like this:
921
+
922
+ ```javascript
923
+ import Blog from 'app/models/blog';
924
+ import User from 'app/models/user';
925
+ import Post from 'app/models/post';
926
+
927
+ let relationships = Blog.relationships;
928
+ relationships.user;
929
+ //=> [ { name: 'users', kind: 'hasMany' },
930
+ // { name: 'owner', kind: 'belongsTo' } ]
931
+ relationships.post;
932
+ //=> [ { name: 'posts', kind: 'hasMany' } ]
933
+ ```
934
+
935
+ @property relationships
936
+ @public
937
+ @static
938
+ @type Map
939
+ @readOnly
940
+ */
941
+ static get relationships(): Map<string, LegacyRelationshipSchema[]>;
942
+ /**
943
+ A hash containing lists of the model's relationships, grouped
944
+ by the relationship kind. For example, given a model with this
945
+ definition:
946
+
947
+ ```app/models/blog.js
948
+ import Model, { belongsTo, hasMany } from '@ember-data/model';
949
+
950
+ export default class BlogModel extends Model {
951
+ @hasMany('user') users;
952
+ @belongsTo('user') owner;
953
+
954
+ @hasMany('post') posts;
955
+ }
956
+ ```
957
+
958
+ This property would contain the following:
959
+
960
+ ```javascript
961
+ import Blog from 'app/models/blog';
962
+
963
+ let relationshipNames = Blog.relationshipNames;
964
+ relationshipNames.hasMany;
965
+ //=> ['users', 'posts']
966
+ relationshipNames.belongsTo;
967
+ //=> ['owner']
968
+ ```
969
+
970
+ @property relationshipNames
971
+ @public
972
+ @static
973
+ @type Object
974
+ @readOnly
975
+ */
976
+ static get relationshipNames(): {
977
+ hasMany: string[];
978
+ belongsTo: string[];
979
+ };
980
+ /**
981
+ An array of types directly related to a model. Each type will be
982
+ included once, regardless of the number of relationships it has with
983
+ the model.
984
+
985
+ For example, given a model with this definition:
986
+
987
+ ```app/models/blog.js
988
+ import Model, { belongsTo, hasMany } from '@ember-data/model';
989
+
990
+ export default class BlogModel extends Model {
991
+ @hasMany('user') users;
992
+ @belongsTo('user') owner;
993
+
994
+ @hasMany('post') posts;
995
+ }
996
+ ```
997
+
998
+ This property would contain the following:
999
+
1000
+ ```javascript
1001
+ import Blog from 'app/models/blog';
1002
+
1003
+ let relatedTypes = Blog.relatedTypes');
1004
+ //=> ['user', 'post']
1005
+ ```
1006
+
1007
+ @property relatedTypes
1008
+ @public
1009
+ @static
1010
+ @type Array
1011
+ @readOnly
1012
+ */
1013
+ static get relatedTypes(): string[];
1014
+ /**
1015
+ A map whose keys are the relationships of a model and whose values are
1016
+ relationship descriptors.
1017
+
1018
+ For example, given a model with this
1019
+ definition:
1020
+
1021
+ ```app/models/blog.js
1022
+ import Model, { belongsTo, hasMany } from '@ember-data/model';
1023
+
1024
+ export default class BlogModel extends Model {
1025
+ @hasMany('user') users;
1026
+ @belongsTo('user') owner;
1027
+
1028
+ @hasMany('post') posts;
1029
+ }
1030
+ ```
1031
+
1032
+ This property would contain the following:
1033
+
1034
+ ```javascript
1035
+ import Blog from 'app/models/blog';
1036
+
1037
+ let relationshipsByName = Blog.relationshipsByName;
1038
+ relationshipsByName.users;
1039
+ //=> { name: 'users', kind: 'hasMany', type: 'user', options: Object }
1040
+ relationshipsByName.owner;
1041
+ //=> { name: 'owner', kind: 'belongsTo', type: 'user', options: Object }
1042
+ ```
1043
+
1044
+ @property relationshipsByName
1045
+ @public
1046
+ @static
1047
+ @type Map
1048
+ @readOnly
1049
+ */
1050
+ static get relationshipsByName(): Map<string, LegacyRelationshipSchema>;
1051
+ static get relationshipsObject(): Record<string, LegacyRelationshipSchema>;
1052
+ /**
1053
+ A map whose keys are the fields of the model and whose values are strings
1054
+ describing the kind of the field. A model's fields are the union of all of its
1055
+ attributes and relationships.
1056
+
1057
+ For example:
1058
+
1059
+ ```app/models/blog.js
1060
+ import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
1061
+
1062
+ export default class BlogModel extends Model {
1063
+ @hasMany('user') users;
1064
+ @belongsTo('user') owner;
1065
+
1066
+ @hasMany('post') posts;
1067
+
1068
+ @attr('string') title;
1069
+ }
1070
+ ```
1071
+
1072
+ ```js
1073
+ import Blog from 'app/models/blog'
1074
+
1075
+ let fields = Blog.fields;
1076
+ fields.forEach(function(kind, field) {
1077
+ // do thing
1078
+ });
1079
+
1080
+ // prints:
1081
+ // users, hasMany
1082
+ // owner, belongsTo
1083
+ // posts, hasMany
1084
+ // title, attribute
1085
+ ```
1086
+
1087
+ @property fields
1088
+ @public
1089
+ @static
1090
+ @type Map
1091
+ @readOnly
1092
+ */
1093
+ static get fields(): Map<string, 'attribute' | 'belongsTo' | 'hasMany'>;
1094
+ /**
1095
+ Given a callback, iterates over each of the relationships in the model,
1096
+ invoking the callback with the name of each relationship and its relationship
1097
+ descriptor.
1098
+
1099
+ @method eachRelationship
1100
+ @public
1101
+ @static
1102
+ @param {Function} callback the callback to invoke
1103
+ @param {any} binding the value to which the callback's `this` should be bound
1104
+ */
1105
+ static eachRelationship<T, Schema extends Model>(callback: (this: T | undefined, key: MaybeRelationshipFields<Schema>, relationship: LegacyRelationshipSchema) => void, binding?: T): void;
1106
+ /**
1107
+ Given a callback, iterates over each of the types related to a model,
1108
+ invoking the callback with the related type's class. Each type will be
1109
+ returned just once, regardless of how many different relationships it has
1110
+ with a model.
1111
+
1112
+ @method eachRelatedType
1113
+ @public
1114
+ @static
1115
+ @param {Function} callback the callback to invoke
1116
+ @param {any} binding the value to which the callback's `this` should be bound
1117
+ */
1118
+ static eachRelatedType<T>(callback: (this: T | undefined, type: string) => void, binding?: T): void;
1119
+ /**
1120
+ *
1121
+ * @method determineRelationshipType
1122
+ * @private
1123
+ * @deprecated
1124
+ */
1125
+ static determineRelationshipType(knownSide: LegacyRelationshipSchema, store: Store): 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany' | 'oneToNone' | 'manyToNone';
1126
+ /**
1127
+ A map whose keys are the attributes of the model (properties
1128
+ described by attr) and whose values are the meta object for the
1129
+ property.
1130
+
1131
+ Example
1132
+
1133
+ ```app/models/person.js
1134
+ import Model, { attr } from '@ember-data/model';
1135
+
1136
+ export default class PersonModel extends Model {
1137
+ @attr('string') firstName;
1138
+ @attr('string') lastName;
1139
+ @attr('date') birthday;
1140
+ }
1141
+ ```
1142
+
1143
+ ```javascript
1144
+ import Person from 'app/models/person'
1145
+
1146
+ let attributes = Person.attributes
1147
+
1148
+ attributes.forEach(function(meta, name) {
1149
+ // do thing
1150
+ });
1151
+
1152
+ // prints:
1153
+ // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"}
1154
+ // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"}
1155
+ // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"}
1156
+ ```
1157
+
1158
+ @property attributes
1159
+ @public
1160
+ @static
1161
+ @type {Map}
1162
+ @readOnly
1163
+ */
1164
+ static get attributes(): Map<string, LegacyAttributeField>;
1165
+ /**
1166
+ A map whose keys are the attributes of the model (properties
1167
+ described by attr) and whose values are type of transformation
1168
+ applied to each attribute. This map does not include any
1169
+ attributes that do not have an transformation type.
1170
+
1171
+ Example
1172
+
1173
+ ```app/models/person.js
1174
+ import Model, { attr } from '@ember-data/model';
1175
+
1176
+ export default class PersonModel extends Model {
1177
+ @attr firstName;
1178
+ @attr('string') lastName;
1179
+ @attr('date') birthday;
1180
+ }
1181
+ ```
1182
+
1183
+ ```javascript
1184
+ import Person from 'app/models/person';
1185
+
1186
+ let transformedAttributes = Person.transformedAttributes
1187
+
1188
+ transformedAttributes.forEach(function(field, type) {
1189
+ // do thing
1190
+ });
1191
+
1192
+ // prints:
1193
+ // lastName string
1194
+ // birthday date
1195
+ ```
1196
+
1197
+ @property transformedAttributes
1198
+ @public
1199
+ @static
1200
+ @type {Map}
1201
+ @readOnly
1202
+ */
1203
+ static get transformedAttributes(): Map<string, string>;
1204
+ /**
1205
+ Iterates through the attributes of the model, calling the passed function on each
1206
+ attribute.
1207
+
1208
+ The callback method you provide should have the following signature (all
1209
+ parameters are optional):
1210
+
1211
+ ```javascript
1212
+ function(name, meta);
1213
+ ```
1214
+
1215
+ - `name` the name of the current property in the iteration
1216
+ - `meta` the meta object for the attribute property in the iteration
1217
+
1218
+ Note that in addition to a callback, you can also pass an optional target
1219
+ object that will be set as `this` on the context.
1220
+
1221
+ Example
1222
+
1223
+ ```javascript
1224
+ import Model, { attr } from '@ember-data/model';
1225
+
1226
+ class PersonModel extends Model {
1227
+ @attr('string') firstName;
1228
+ @attr('string') lastName;
1229
+ @attr('date') birthday;
1230
+ }
1231
+
1232
+ PersonModel.eachAttribute(function(name, meta) {
1233
+ // do thing
1234
+ });
1235
+
1236
+ // prints:
1237
+ // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"}
1238
+ // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"}
1239
+ // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"}
1240
+ ```
1241
+
1242
+ @method eachAttribute
1243
+ @public
1244
+ @param {Function} callback The callback to execute
1245
+ @param {Object} [binding] the value to which the callback's `this` should be bound
1246
+ @static
1247
+ */
1248
+ static eachAttribute<T, Schema extends Model>(callback: (this: T | undefined, key: MaybeAttrFields<Schema>, attribute: LegacyAttributeField) => void, binding?: T): void;
1249
+ /**
1250
+ Iterates through the transformedAttributes of the model, calling
1251
+ the passed function on each attribute. Note the callback will not be
1252
+ called for any attributes that do not have an transformation type.
1253
+
1254
+ The callback method you provide should have the following signature (all
1255
+ parameters are optional):
1256
+
1257
+ ```javascript
1258
+ function(name, type);
1259
+ ```
1260
+
1261
+ - `name` the name of the current property in the iteration
1262
+ - `type` a string containing the name of the type of transformed
1263
+ applied to the attribute
1264
+
1265
+ Note that in addition to a callback, you can also pass an optional target
1266
+ object that will be set as `this` on the context.
1267
+
1268
+ Example
1269
+
1270
+ ```javascript
1271
+ import Model, { attr } from '@ember-data/model';
1272
+
1273
+ let Person = Model.extend({
1274
+ firstName: attr(),
1275
+ lastName: attr('string'),
1276
+ birthday: attr('date')
1277
+ });
1278
+
1279
+ Person.eachTransformedAttribute(function(name, type) {
1280
+ // do thing
1281
+ });
1282
+
1283
+ // prints:
1284
+ // lastName string
1285
+ // birthday date
1286
+ ```
1287
+
1288
+ @method eachTransformedAttribute
1289
+ @public
1290
+ @param {Function} callback The callback to execute
1291
+ @param {Object} [binding] the value to which the callback's `this` should be bound
1292
+ @static
1293
+ */
1294
+ static eachTransformedAttribute<T, Schema extends Model>(callback: (this: T | undefined, key: Exclude<keyof Schema & string, keyof Model & string>, type: string) => void, binding?: T): void;
1295
+ /**
1296
+ Returns the name of the model class.
1297
+
1298
+ @method toString
1299
+ @public
1300
+ @static
1301
+ */
1302
+ static toString(): string;
1303
+ }
1304
+ export { Model };
1305
+ }
1306
+ //# sourceMappingURL=model.d.ts.map