@ember-data/model 4.12.8 → 4.13.0-alpha.1

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