@warp-drive/legacy 5.6.0-alpha.15 → 5.6.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
- package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
- package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
- package/declarations/adapter/-private.d.ts +5 -6
- package/declarations/adapter/error.d.ts +206 -178
- package/declarations/adapter/json-api.d.ts +206 -207
- package/declarations/adapter/rest.d.ts +805 -808
- package/declarations/adapter.d.ts +742 -766
- package/declarations/compat/-private.d.ts +10 -11
- package/declarations/compat/builders/find-all.d.ts +26 -24
- package/declarations/compat/builders/find-record.d.ts +41 -39
- package/declarations/compat/builders/query.d.ts +50 -45
- package/declarations/compat/builders/save-record.d.ts +26 -24
- package/declarations/compat/builders/utils.d.ts +1 -2
- package/declarations/compat/builders.d.ts +10 -11
- package/declarations/compat/extensions.d.ts +52 -106
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
- package/declarations/compat/utils.d.ts +118 -119
- package/declarations/compat.d.ts +106 -104
- package/declarations/model/-private/attr.d.ts +164 -145
- package/declarations/model/-private/belongs-to.d.ts +135 -122
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/model/-private/errors.d.ts +272 -267
- package/declarations/model/-private/has-many.d.ts +119 -116
- package/declarations/model/-private/hooks.d.ts +5 -6
- package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
- package/declarations/model/-private/model-for-mixin.d.ts +18 -3
- package/declarations/model/-private/model-methods.d.ts +29 -24
- package/declarations/model/-private/model.d.ts +1306 -1254
- package/declarations/model/-private/notify-changes.d.ts +3 -4
- package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
- package/declarations/model/-private/promise-many-array.d.ts +125 -116
- package/declarations/model/-private/record-state.d.ts +63 -60
- package/declarations/model/-private/references/belongs-to.d.ts +491 -487
- package/declarations/model/-private/references/has-many.d.ts +495 -492
- package/declarations/model/-private/schema-provider.d.ts +53 -56
- package/declarations/model/-private/type-utils.d.ts +41 -41
- package/declarations/model/-private/util.d.ts +1 -2
- package/declarations/model/-private.d.ts +8 -8
- package/declarations/model/migration-support.d.ts +281 -279
- package/declarations/model.d.ts +48 -49
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
- package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
- package/declarations/serializer/-private/transforms/date.d.ts +22 -22
- package/declarations/serializer/-private/transforms/number.d.ts +22 -22
- package/declarations/serializer/-private/transforms/string.d.ts +22 -22
- package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
- package/declarations/serializer/-private/utils.d.ts +0 -1
- package/declarations/serializer/json-api.d.ts +124 -494
- package/declarations/serializer/json.d.ts +62 -1031
- package/declarations/serializer/rest.d.ts +52 -552
- package/declarations/serializer/transform.d.ts +5 -6
- package/declarations/serializer.d.ts +217 -218
- package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +17 -0
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +5 -7
- package/dist/adapter.js +6 -35
- package/dist/compat/-private.js +1 -1
- package/dist/compat/extensions.js +0 -2
- package/dist/compat.js +3 -4
- package/dist/{errors-_QQ7xpSn.js → errors-BX5wowuz.js} +11 -10
- package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +3 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-D_P8ReX6.js → schema-provider-BdQhkT-Q.js} +20 -13
- package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
- package/dist/serializer/json-api.js +42 -2
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +46 -41
- package/dist/serializer/transform.js +0 -44
- package/package.json +7 -7
- package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
- package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
- package/declarations/adapter/-private.d.ts.map +0 -1
- package/declarations/adapter/error.d.ts.map +0 -1
- package/declarations/adapter/json-api.d.ts.map +0 -1
- package/declarations/adapter/rest.d.ts.map +0 -1
- package/declarations/adapter.d.ts.map +0 -1
- package/declarations/compat/-private.d.ts.map +0 -1
- package/declarations/compat/builders/find-all.d.ts.map +0 -1
- package/declarations/compat/builders/find-record.d.ts.map +0 -1
- package/declarations/compat/builders/query.d.ts.map +0 -1
- package/declarations/compat/builders/save-record.d.ts.map +0 -1
- package/declarations/compat/builders/utils.d.ts.map +0 -1
- package/declarations/compat/builders.d.ts.map +0 -1
- package/declarations/compat/extensions.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
- package/declarations/compat/utils.d.ts.map +0 -1
- package/declarations/compat.d.ts.map +0 -1
- package/declarations/model/-private/attr.d.ts.map +0 -1
- package/declarations/model/-private/attr.type-test.d.ts +0 -2
- package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
- package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/model/-private/errors.d.ts.map +0 -1
- package/declarations/model/-private/has-many.d.ts.map +0 -1
- package/declarations/model/-private/has-many.type-test.d.ts +0 -2
- package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
- package/declarations/model/-private/hooks.d.ts.map +0 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
- package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
- package/declarations/model/-private/model-methods.d.ts.map +0 -1
- package/declarations/model/-private/model.d.ts.map +0 -1
- package/declarations/model/-private/model.type-test.d.ts +0 -2
- package/declarations/model/-private/model.type-test.d.ts.map +0 -1
- package/declarations/model/-private/notify-changes.d.ts.map +0 -1
- package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
- package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
- package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
- package/declarations/model/-private/record-state.d.ts.map +0 -1
- package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/references/has-many.d.ts.map +0 -1
- package/declarations/model/-private/schema-provider.d.ts.map +0 -1
- package/declarations/model/-private/type-utils.d.ts.map +0 -1
- package/declarations/model/-private/util.d.ts.map +0 -1
- package/declarations/model/-private.d.ts.map +0 -1
- package/declarations/model/migration-support.d.ts.map +0 -1
- package/declarations/model/migration-support.type-test.d.ts +0 -2
- package/declarations/model/migration-support.type-test.d.ts.map +0 -1
- package/declarations/model.d.ts.map +0 -1
- package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
- package/declarations/serializer/-private/utils.d.ts.map +0 -1
- package/declarations/serializer/json-api.d.ts.map +0 -1
- package/declarations/serializer/json.d.ts.map +0 -1
- package/declarations/serializer/rest.d.ts.map +0 -1
- package/declarations/serializer/transform.d.ts.map +0 -1
- package/declarations/serializer.d.ts.map +0 -1
- package/dist/-private-DFfBszo5.js.map +0 -1
- package/dist/adapter/-private.js.map +0 -1
- package/dist/adapter/error.js.map +0 -1
- package/dist/adapter/json-api.js.map +0 -1
- package/dist/adapter/rest.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/compat/-private.js.map +0 -1
- package/dist/compat/builders.js.map +0 -1
- package/dist/compat/extensions.js.map +0 -1
- package/dist/compat/utils.js.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/errors-_QQ7xpSn.js.map +0 -1
- package/dist/json-DSOlH9A8.js.map +0 -1
- package/dist/model/-private.js.map +0 -1
- package/dist/model/migration-support.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
- package/dist/schema-provider-D_P8ReX6.js.map +0 -1
- package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
- package/dist/serializer/json-api.js.map +0 -1
- package/dist/serializer/json.js.map +0 -1
- package/dist/serializer/rest.js.map +0 -1
- package/dist/serializer/transform.js.map +0 -1
- package/dist/serializer.js.map +0 -1
|
@@ -1,237 +1,236 @@
|
|
|
1
|
-
import type { Store } from
|
|
2
|
-
import type { FindRecordOptions } from
|
|
3
|
-
import type { ChangedAttributesHash } from
|
|
4
|
-
import type { StableRecordIdentifier } from
|
|
5
|
-
import type { TypedRecordInstance, TypeFromInstance } from
|
|
6
|
-
import type { LegacyAttributeField, LegacyRelationshipField } from
|
|
7
|
-
import type { SerializerOptions } from
|
|
1
|
+
import type { Store } from "@warp-drive/core";
|
|
2
|
+
import type { FindRecordOptions } from "@warp-drive/core/types";
|
|
3
|
+
import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
4
|
+
import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
|
|
5
|
+
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
6
|
+
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
7
|
+
import type { SerializerOptions } from "./minimum-serializer-interface.js";
|
|
8
8
|
type RecordId = string | null;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Snapshot is not directly instantiable.
|
|
11
|
+
Instances are provided to a consuming application's
|
|
12
|
+
adapters and serializers for certain requests.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Snapshots are only available when using `@ember-data/legacy-compat`
|
|
15
|
+
for legacy compatibility with adapters and serializers.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
@class Snapshot
|
|
18
|
+
@public
|
|
19
19
|
*/
|
|
20
20
|
export declare class Snapshot<R = unknown> {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
21
|
+
__attributes: Record<keyof R & string, unknown> | null;
|
|
22
|
+
_belongsToRelationships: Record<string, Snapshot>;
|
|
23
|
+
_belongsToIds: Record<string, RecordId>;
|
|
24
|
+
_hasManyRelationships: Record<string, Snapshot[]>;
|
|
25
|
+
_hasManyIds: Record<string, RecordId[]>;
|
|
26
|
+
_changedAttributes: ChangedAttributesHash;
|
|
27
|
+
identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
|
|
28
|
+
modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;
|
|
29
|
+
id: string | null;
|
|
30
|
+
include?: string | string[];
|
|
31
|
+
adapterOptions?: Record<string, unknown>;
|
|
32
|
+
_store: Store;
|
|
33
|
+
/**
|
|
34
|
+
* @constructor
|
|
35
|
+
* @private
|
|
36
|
+
* @param options
|
|
37
|
+
* @param identifier
|
|
38
|
+
* @param _store
|
|
39
|
+
*/
|
|
40
|
+
constructor(options: FindRecordOptions, identifier: StableRecordIdentifier<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
|
|
41
|
+
/**
|
|
42
|
+
The underlying record for this snapshot. Can be used to access methods and
|
|
43
|
+
properties defined on the record.
|
|
44
|
+
|
|
45
|
+
Example
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
let json = snapshot.record.toJSON();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
@property record
|
|
52
|
+
@type {Model}
|
|
53
|
+
@public
|
|
54
|
+
*/
|
|
55
|
+
get record(): R | null;
|
|
56
|
+
get _attributes(): Record<keyof R & string, unknown>;
|
|
57
|
+
get isNew(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
Returns the value of an attribute.
|
|
60
|
+
|
|
61
|
+
Example
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
65
|
+
postSnapshot.attr('author'); // => 'Tomster'
|
|
66
|
+
postSnapshot.attr('title'); // => 'Ember.js rocks'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Note: Values are loaded eagerly and cached when the snapshot is created.
|
|
70
|
+
|
|
71
|
+
@param {String} keyName
|
|
72
|
+
@return {Object} The attribute value or undefined
|
|
73
|
+
@public
|
|
74
|
+
*/
|
|
75
|
+
attr(keyName: keyof R & string): unknown;
|
|
76
|
+
/**
|
|
77
|
+
Returns all attributes and their corresponding values.
|
|
78
|
+
|
|
79
|
+
Example
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
83
|
+
postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
@return {Object} All attributes of the current snapshot
|
|
87
|
+
@public
|
|
88
|
+
*/
|
|
89
|
+
attributes(): Record<keyof R & string, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
Returns all changed attributes and their old and new values.
|
|
92
|
+
|
|
93
|
+
Example
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
97
|
+
postModel.set('title', 'Ember.js rocks!');
|
|
98
|
+
postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
@return {Object} All changed attributes of the current snapshot
|
|
102
|
+
@public
|
|
103
|
+
*/
|
|
104
|
+
changedAttributes(): ChangedAttributesHash;
|
|
105
|
+
/**
|
|
106
|
+
Returns the current value of a belongsTo relationship.
|
|
107
|
+
|
|
108
|
+
`belongsTo` takes an optional hash of options as a second parameter,
|
|
109
|
+
currently supported options are:
|
|
110
|
+
|
|
111
|
+
- `id`: set to `true` if you only want the ID of the related record to be
|
|
112
|
+
returned.
|
|
113
|
+
|
|
114
|
+
Example
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
// store.push('post', { id: 1, title: 'Hello World' });
|
|
118
|
+
// store.createRecord('comment', { body: 'Lorem ipsum', post: post });
|
|
119
|
+
commentSnapshot.belongsTo('post'); // => Snapshot
|
|
120
|
+
commentSnapshot.belongsTo('post', { id: true }); // => '1'
|
|
121
|
+
|
|
122
|
+
// store.push('comment', { id: 1, body: 'Lorem ipsum' });
|
|
123
|
+
commentSnapshot.belongsTo('post'); // => undefined
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Calling `belongsTo` will return a new Snapshot as long as there's any known
|
|
127
|
+
data for the relationship available, such as an ID. If the relationship is
|
|
128
|
+
known but unset, `belongsTo` will return `null`. If the contents of the
|
|
129
|
+
relationship is unknown `belongsTo` will return `undefined`.
|
|
130
|
+
|
|
131
|
+
Note: Relationships are loaded lazily and cached upon first access.
|
|
132
|
+
|
|
133
|
+
@param {String} keyName
|
|
134
|
+
@param {Object} [options]
|
|
135
|
+
@public
|
|
136
|
+
@return {(Snapshot|String|null|undefined)} A snapshot or ID of a known
|
|
137
|
+
relationship or null if the relationship is known but unset. undefined
|
|
138
|
+
will be returned if the contents of the relationship is unknown.
|
|
139
|
+
*/
|
|
140
|
+
belongsTo(keyName: string, options?: {
|
|
141
|
+
id?: boolean;
|
|
142
|
+
}): Snapshot | RecordId | undefined;
|
|
143
|
+
/**
|
|
144
|
+
Returns the current value of a hasMany relationship.
|
|
145
|
+
|
|
146
|
+
`hasMany` takes an optional hash of options as a second parameter,
|
|
147
|
+
currently supported options are:
|
|
148
|
+
|
|
149
|
+
- `ids`: set to `true` if you only want the IDs of the related records to be
|
|
150
|
+
returned.
|
|
151
|
+
|
|
152
|
+
Example
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
// store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });
|
|
156
|
+
postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]
|
|
157
|
+
postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']
|
|
158
|
+
|
|
159
|
+
// store.push('post', { id: 1, title: 'Hello World' });
|
|
160
|
+
postSnapshot.hasMany('comments'); // => undefined
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Note: Relationships are loaded lazily and cached upon first access.
|
|
164
|
+
|
|
165
|
+
@param {String} keyName
|
|
166
|
+
@param {Object} [options]
|
|
167
|
+
@public
|
|
168
|
+
@return {(Array|undefined)} An array of snapshots or IDs of a known
|
|
169
|
+
relationship or an empty array if the relationship is known but unset.
|
|
170
|
+
undefined will be returned if the contents of the relationship is unknown.
|
|
171
|
+
*/
|
|
172
|
+
hasMany(keyName: string, options?: {
|
|
173
|
+
ids?: boolean;
|
|
174
|
+
}): RecordId[] | Snapshot[] | undefined;
|
|
175
|
+
/**
|
|
176
|
+
Iterates through all the attributes of the model, calling the passed
|
|
177
|
+
function on each attribute.
|
|
178
|
+
|
|
179
|
+
Example
|
|
180
|
+
|
|
181
|
+
```javascript
|
|
182
|
+
snapshot.eachAttribute(function(name, meta) {
|
|
183
|
+
// ...
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
@param {Function} callback the callback to execute
|
|
188
|
+
@param {Object} [binding] the value to which the callback's `this` should be bound
|
|
189
|
+
@public
|
|
190
|
+
*/
|
|
191
|
+
eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
|
|
192
|
+
/**
|
|
193
|
+
Iterates through all the relationships of the model, calling the passed
|
|
194
|
+
function on each relationship.
|
|
195
|
+
|
|
196
|
+
Example
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
snapshot.eachRelationship(function(name, relationship) {
|
|
200
|
+
// ...
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
@param {Function} callback the callback to execute
|
|
205
|
+
@param {Object} [binding] the value to which the callback's `this` should be bound
|
|
206
|
+
@public
|
|
207
|
+
*/
|
|
208
|
+
eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
|
|
209
|
+
/**
|
|
210
|
+
Serializes the snapshot using the serializer for the model.
|
|
211
|
+
|
|
212
|
+
Example
|
|
213
|
+
|
|
214
|
+
```js [app/adapters/application.js]
|
|
215
|
+
import Adapter from '@ember-data/adapter';
|
|
216
|
+
|
|
217
|
+
export default Adapter.extend({
|
|
218
|
+
createRecord(store, type, snapshot) {
|
|
219
|
+
let data = snapshot.serialize({ includeId: true });
|
|
220
|
+
let url = `/${type.modelName}`;
|
|
221
|
+
|
|
222
|
+
return fetch(url, {
|
|
223
|
+
method: 'POST',
|
|
224
|
+
body: data,
|
|
225
|
+
}).then((response) => response.json())
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
@param {Object} options
|
|
231
|
+
@return {Object} an object whose values are primitive JSON values only
|
|
232
|
+
@public
|
|
233
|
+
*/
|
|
234
|
+
serialize(options?: SerializerOptions): unknown;
|
|
235
235
|
}
|
|
236
236
|
export {};
|
|
237
|
-
//# sourceMappingURL=snapshot.d.ts.map
|