@twin.org/entity-storage-models 0.0.3-next.3 → 0.0.3-next.31
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/README.md +2 -2
- package/dist/es/factories/schemaMigrationFactory.js +17 -0
- package/dist/es/factories/schemaMigrationFactory.js.map +1 -0
- package/dist/es/helpers/entityStorageHelper.js +126 -0
- package/dist/es/helpers/entityStorageHelper.js.map +1 -0
- package/dist/es/helpers/migrationHelper.js +232 -0
- package/dist/es/helpers/migrationHelper.js.map +1 -0
- package/dist/es/index.js +14 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEntityStorageComponent.js.map +1 -1
- package/dist/es/models/IEntityStorageConnector.js.map +1 -1
- package/dist/es/models/IEntityStorageMigrationConnector.js +2 -0
- package/dist/es/models/IEntityStorageMigrationConnector.js.map +1 -0
- package/dist/es/models/IMigrationOptions.js +4 -0
- package/dist/es/models/IMigrationOptions.js.map +1 -0
- package/dist/es/models/IResolvedMigrationStep.js +2 -0
- package/dist/es/models/IResolvedMigrationStep.js.map +1 -0
- package/dist/es/models/ISchemaMigration.js +2 -0
- package/dist/es/models/ISchemaMigration.js.map +1 -0
- package/dist/es/models/api/IEntityStorageCountRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageCountRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageCountResponse.js +4 -0
- package/dist/es/models/api/IEntityStorageCountResponse.js.map +1 -0
- package/dist/es/models/api/IEntityStorageEmptyRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageEmptyRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageGetRequest.js.map +1 -1
- package/dist/es/models/api/IEntityStorageRemoveBatchRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageRemoveBatchRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageRemoveRequest.js.map +1 -1
- package/dist/es/models/api/IEntityStorageSetBatchRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageSetBatchRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageSetRequest.js.map +1 -1
- package/dist/es/models/entityPropertyTransformer.js +2 -0
- package/dist/es/models/entityPropertyTransformer.js.map +1 -0
- package/dist/types/factories/schemaMigrationFactory.d.ts +14 -0
- package/dist/types/helpers/entityStorageHelper.d.ts +59 -0
- package/dist/types/helpers/migrationHelper.d.ts +65 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/models/IEntityStorageComponent.d.ts +38 -3
- package/dist/types/models/IEntityStorageConnector.d.ts +23 -0
- package/dist/types/models/IEntityStorageMigrationConnector.d.ts +35 -0
- package/dist/types/models/IMigrationOptions.d.ts +17 -0
- package/dist/types/models/IResolvedMigrationStep.d.ts +38 -0
- package/dist/types/models/ISchemaMigration.d.ts +30 -0
- package/dist/types/models/api/IEntityStorageCountRequest.d.ts +14 -0
- package/dist/types/models/api/IEntityStorageCountResponse.d.ts +14 -0
- package/dist/types/models/api/IEntityStorageEmptyRequest.d.ts +5 -0
- package/dist/types/models/api/IEntityStorageGetRequest.d.ts +4 -0
- package/dist/types/models/api/IEntityStorageRemoveBatchRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageRemoveRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageSetBatchRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageSetRequest.d.ts +9 -0
- package/dist/types/models/entityPropertyTransformer.d.ts +6 -0
- package/docs/changelog.md +315 -44
- package/docs/examples.md +87 -1
- package/docs/reference/classes/EntityStorageHelper.md +209 -0
- package/docs/reference/classes/MigrationHelper.md +198 -0
- package/docs/reference/index.md +19 -0
- package/docs/reference/interfaces/IEntityStorageComponent.md +105 -7
- package/docs/reference/interfaces/IEntityStorageConnector.md +89 -5
- package/docs/reference/interfaces/IEntityStorageCountRequest.md +17 -0
- package/docs/reference/interfaces/IEntityStorageCountResponse.md +17 -0
- package/docs/reference/interfaces/IEntityStorageEmptyRequest.md +3 -0
- package/docs/reference/interfaces/IEntityStorageGetRequest.md +10 -4
- package/docs/reference/interfaces/IEntityStorageGetResponse.md +1 -1
- package/docs/reference/interfaces/IEntityStorageListRequest.md +8 -8
- package/docs/reference/interfaces/IEntityStorageListResponse.md +2 -2
- package/docs/reference/interfaces/IEntityStorageMigrationConnector.md +402 -0
- package/docs/reference/interfaces/IEntityStorageRemoveBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageRemoveRequest.md +15 -1
- package/docs/reference/interfaces/IEntityStorageSetBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageSetRequest.md +15 -1
- package/docs/reference/interfaces/IMigrationOptions.md +49 -0
- package/docs/reference/interfaces/IResolvedMigrationStep.md +78 -0
- package/docs/reference/interfaces/ISchemaMigration.md +62 -0
- package/docs/reference/type-aliases/EntityPropertyTransformer.md +34 -0
- package/docs/reference/variables/SchemaMigrationFactory.md +13 -0
- package/locales/en.json +18 -1
- package/package.json +6 -4
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Class: EntityStorageHelper
|
|
2
|
+
|
|
3
|
+
Helper class for performing schema migrations between two connectors.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new EntityStorageHelper**(): `EntityStorageHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`EntityStorageHelper`
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### prepareEntity() {#prepareentity}
|
|
26
|
+
|
|
27
|
+
> `static` **prepareEntity**\<`T`\>(`entity`, `schema`, `additionalProperties?`, `options?`): `T`
|
|
28
|
+
|
|
29
|
+
Prepare the entity by handling undefined and null values and validating it against the schema.
|
|
30
|
+
|
|
31
|
+
#### Type Parameters
|
|
32
|
+
|
|
33
|
+
##### T
|
|
34
|
+
|
|
35
|
+
`T`
|
|
36
|
+
|
|
37
|
+
#### Parameters
|
|
38
|
+
|
|
39
|
+
##### entity
|
|
40
|
+
|
|
41
|
+
`T`
|
|
42
|
+
|
|
43
|
+
The entity to handle undefined and null values for.
|
|
44
|
+
|
|
45
|
+
##### schema
|
|
46
|
+
|
|
47
|
+
`IEntitySchema`\<`T`\>
|
|
48
|
+
|
|
49
|
+
The schema to validate the entity against.
|
|
50
|
+
|
|
51
|
+
##### additionalProperties?
|
|
52
|
+
|
|
53
|
+
`object`[]
|
|
54
|
+
|
|
55
|
+
Optional list of additional properties to set on the entity.
|
|
56
|
+
|
|
57
|
+
##### options?
|
|
58
|
+
|
|
59
|
+
Options controlling how null/undefined optional properties are stored.
|
|
60
|
+
|
|
61
|
+
###### nullBehavior?
|
|
62
|
+
|
|
63
|
+
`"omit"` \| `"nullify"`
|
|
64
|
+
|
|
65
|
+
"omit" strips null/undefined optional properties before writing
|
|
66
|
+
(NoSQL — avoids index-key type errors). "nullify" converts undefined to null (SQL — the default).
|
|
67
|
+
|
|
68
|
+
#### Returns
|
|
69
|
+
|
|
70
|
+
`T`
|
|
71
|
+
|
|
72
|
+
The entity with undefined and null values handled.
|
|
73
|
+
|
|
74
|
+
***
|
|
75
|
+
|
|
76
|
+
### unPrepareEntity() {#unprepareentity}
|
|
77
|
+
|
|
78
|
+
> `static` **unPrepareEntity**\<`T`\>(`entity`, `removeProperties?`): `T`
|
|
79
|
+
|
|
80
|
+
Un-prepare the entity by removing null values.
|
|
81
|
+
|
|
82
|
+
#### Type Parameters
|
|
83
|
+
|
|
84
|
+
##### T
|
|
85
|
+
|
|
86
|
+
`T`
|
|
87
|
+
|
|
88
|
+
#### Parameters
|
|
89
|
+
|
|
90
|
+
##### entity
|
|
91
|
+
|
|
92
|
+
`Partial`\<`T`\> \| `undefined`
|
|
93
|
+
|
|
94
|
+
The entity to handle undefined and null values for.
|
|
95
|
+
|
|
96
|
+
##### removeProperties?
|
|
97
|
+
|
|
98
|
+
`string`[]
|
|
99
|
+
|
|
100
|
+
Optional list of properties to remove from the entity.
|
|
101
|
+
|
|
102
|
+
#### Returns
|
|
103
|
+
|
|
104
|
+
`T`
|
|
105
|
+
|
|
106
|
+
The entity with undefined and null values handled.
|
|
107
|
+
|
|
108
|
+
***
|
|
109
|
+
|
|
110
|
+
### validateSortProperties() {#validatesortproperties}
|
|
111
|
+
|
|
112
|
+
> `static` **validateSortProperties**\<`T`\>(`schema`, `sortProperties?`): `void`
|
|
113
|
+
|
|
114
|
+
Validate that every sort property in the list is indexed in the schema (isPrimary, isSecondary,
|
|
115
|
+
or has a default sortDirection), throwing sortNotIndexed for the first violation found.
|
|
116
|
+
|
|
117
|
+
#### Type Parameters
|
|
118
|
+
|
|
119
|
+
##### T
|
|
120
|
+
|
|
121
|
+
`T`
|
|
122
|
+
|
|
123
|
+
#### Parameters
|
|
124
|
+
|
|
125
|
+
##### schema
|
|
126
|
+
|
|
127
|
+
`IEntitySchema`\<`T`\>
|
|
128
|
+
|
|
129
|
+
The entity schema to validate against.
|
|
130
|
+
|
|
131
|
+
##### sortProperties?
|
|
132
|
+
|
|
133
|
+
`object`[]
|
|
134
|
+
|
|
135
|
+
The sort properties to check.
|
|
136
|
+
|
|
137
|
+
#### Returns
|
|
138
|
+
|
|
139
|
+
`void`
|
|
140
|
+
|
|
141
|
+
#### Throws
|
|
142
|
+
|
|
143
|
+
GeneralError If a sort property is not indexed in the schema.
|
|
144
|
+
|
|
145
|
+
***
|
|
146
|
+
|
|
147
|
+
### validateProperties() {#validateproperties}
|
|
148
|
+
|
|
149
|
+
> `static` **validateProperties**\<`T`\>(`schema`, `properties?`): `void`
|
|
150
|
+
|
|
151
|
+
Validate that every property in the list exists in the schema, throwing propertyNotInSchema
|
|
152
|
+
for the first property that is not found.
|
|
153
|
+
|
|
154
|
+
#### Type Parameters
|
|
155
|
+
|
|
156
|
+
##### T
|
|
157
|
+
|
|
158
|
+
`T`
|
|
159
|
+
|
|
160
|
+
#### Parameters
|
|
161
|
+
|
|
162
|
+
##### schema
|
|
163
|
+
|
|
164
|
+
`IEntitySchema`\<`T`\>
|
|
165
|
+
|
|
166
|
+
The entity schema to validate against.
|
|
167
|
+
|
|
168
|
+
##### properties?
|
|
169
|
+
|
|
170
|
+
keyof `T`[]
|
|
171
|
+
|
|
172
|
+
The properties to check.
|
|
173
|
+
|
|
174
|
+
#### Returns
|
|
175
|
+
|
|
176
|
+
`void`
|
|
177
|
+
|
|
178
|
+
#### Throws
|
|
179
|
+
|
|
180
|
+
GeneralError If a property does not exist in the schema.
|
|
181
|
+
|
|
182
|
+
***
|
|
183
|
+
|
|
184
|
+
### normalizeConditionValues() {#normalizeconditionvalues}
|
|
185
|
+
|
|
186
|
+
> `static` **normalizeConditionValues**\<`T`\>(`condition`): `EntityCondition`\<`T`\>
|
|
187
|
+
|
|
188
|
+
Deep-clone condition tree and normalise null/undefined to undefined on Equals/NotEquals leaves
|
|
189
|
+
so in-memory evaluation matches stored-absent semantics (optional absent props are omitted/undefined).
|
|
190
|
+
|
|
191
|
+
#### Type Parameters
|
|
192
|
+
|
|
193
|
+
##### T
|
|
194
|
+
|
|
195
|
+
`T`
|
|
196
|
+
|
|
197
|
+
#### Parameters
|
|
198
|
+
|
|
199
|
+
##### condition
|
|
200
|
+
|
|
201
|
+
`EntityCondition`\<`T`\>
|
|
202
|
+
|
|
203
|
+
The user-supplied condition (not mutated).
|
|
204
|
+
|
|
205
|
+
#### Returns
|
|
206
|
+
|
|
207
|
+
`EntityCondition`\<`T`\>
|
|
208
|
+
|
|
209
|
+
A clone safe to pass to check.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Class: MigrationHelper
|
|
2
|
+
|
|
3
|
+
Helper class for performing entity schema migrations between two connectors.
|
|
4
|
+
The chain-based API (migrateWithChain / applyEntityChain) is the single migration
|
|
5
|
+
path: a chain of one step covers the same case as a traditional single-step migration.
|
|
6
|
+
|
|
7
|
+
## Constructors
|
|
8
|
+
|
|
9
|
+
### Constructor
|
|
10
|
+
|
|
11
|
+
> **new MigrationHelper**(): `MigrationHelper`
|
|
12
|
+
|
|
13
|
+
#### Returns
|
|
14
|
+
|
|
15
|
+
`MigrationHelper`
|
|
16
|
+
|
|
17
|
+
## Properties
|
|
18
|
+
|
|
19
|
+
### CLASS\_NAME {#class_name}
|
|
20
|
+
|
|
21
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
22
|
+
|
|
23
|
+
Runtime name for the class.
|
|
24
|
+
|
|
25
|
+
## Methods
|
|
26
|
+
|
|
27
|
+
### migrateWithChain() {#migratewithchain}
|
|
28
|
+
|
|
29
|
+
> `static` **migrateWithChain**(`sourceConnector`, `targetSchemaName`, `steps`, `options?`, `loggingComponentType?`): `Promise`\<\{ `finalConnector`: [`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md); `migrated`: `number`; \}\>
|
|
30
|
+
|
|
31
|
+
Performs a chain migration in a single connector swap, regardless of how many version
|
|
32
|
+
steps the chain spans. Creates one target connector, reads all source entities, applies
|
|
33
|
+
applyEntityChain to each, writes them to the target, then finalizes the migration.
|
|
34
|
+
A chain of one step is equivalent to a traditional single-step migration.
|
|
35
|
+
|
|
36
|
+
#### Parameters
|
|
37
|
+
|
|
38
|
+
##### sourceConnector
|
|
39
|
+
|
|
40
|
+
[`IEntityStorageMigrationConnector`](../interfaces/IEntityStorageMigrationConnector.md)
|
|
41
|
+
|
|
42
|
+
The connector holding data at the stored schema version.
|
|
43
|
+
|
|
44
|
+
##### targetSchemaName
|
|
45
|
+
|
|
46
|
+
`string`
|
|
47
|
+
|
|
48
|
+
The schema name for the current version (used to create the target connector).
|
|
49
|
+
|
|
50
|
+
##### steps
|
|
51
|
+
|
|
52
|
+
[`IResolvedMigrationStep`](../interfaces/IResolvedMigrationStep.md)\<`unknown`, `unknown`\>[]
|
|
53
|
+
|
|
54
|
+
Ordered, fully-resolved migration steps from stored to current version.
|
|
55
|
+
|
|
56
|
+
##### options?
|
|
57
|
+
|
|
58
|
+
[`IMigrationOptions`](../interfaces/IMigrationOptions.md)
|
|
59
|
+
|
|
60
|
+
Optional migration options.
|
|
61
|
+
|
|
62
|
+
##### loggingComponentType?
|
|
63
|
+
|
|
64
|
+
`string`
|
|
65
|
+
|
|
66
|
+
The optional component type to use for logging the migration progress.
|
|
67
|
+
|
|
68
|
+
#### Returns
|
|
69
|
+
|
|
70
|
+
`Promise`\<\{ `finalConnector`: [`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md); `migrated`: `number`; \}\>
|
|
71
|
+
|
|
72
|
+
The finalized connector and the count of migrated entities.
|
|
73
|
+
|
|
74
|
+
***
|
|
75
|
+
|
|
76
|
+
### migratePartitionWithChain() {#migratepartitionwithchain}
|
|
77
|
+
|
|
78
|
+
> `static` **migratePartitionWithChain**(`source`, `target`, `steps`, `options?`): `Promise`\<`number`\>
|
|
79
|
+
|
|
80
|
+
Reads all entities from one partition of the source connector, applies the migration
|
|
81
|
+
chain to each entity, and writes the results to the target connector.
|
|
82
|
+
|
|
83
|
+
#### Parameters
|
|
84
|
+
|
|
85
|
+
##### source
|
|
86
|
+
|
|
87
|
+
[`IEntityStorageMigrationConnector`](../interfaces/IEntityStorageMigrationConnector.md)
|
|
88
|
+
|
|
89
|
+
The connector to read from (already bootstrapped).
|
|
90
|
+
|
|
91
|
+
##### target
|
|
92
|
+
|
|
93
|
+
[`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md)
|
|
94
|
+
|
|
95
|
+
The connector to write to (already bootstrapped).
|
|
96
|
+
|
|
97
|
+
##### steps
|
|
98
|
+
|
|
99
|
+
[`IResolvedMigrationStep`](../interfaces/IResolvedMigrationStep.md)\<`unknown`, `unknown`\>[]
|
|
100
|
+
|
|
101
|
+
Ordered, fully-resolved migration steps.
|
|
102
|
+
|
|
103
|
+
##### options?
|
|
104
|
+
|
|
105
|
+
[`IMigrationOptions`](../interfaces/IMigrationOptions.md)
|
|
106
|
+
|
|
107
|
+
Optional migration options (batchSize, progress callbacks, transformEntityProperty).
|
|
108
|
+
|
|
109
|
+
#### Returns
|
|
110
|
+
|
|
111
|
+
`Promise`\<`number`\>
|
|
112
|
+
|
|
113
|
+
The number of entities migrated.
|
|
114
|
+
|
|
115
|
+
***
|
|
116
|
+
|
|
117
|
+
### applyEntityChain() {#applyentitychain}
|
|
118
|
+
|
|
119
|
+
> `static` **applyEntityChain**(`entity`, `steps`): `unknown`
|
|
120
|
+
|
|
121
|
+
Transforms a single entity through an ordered chain of fully-resolved migration steps.
|
|
122
|
+
For each step the method diffs fromProperties against toProperties, then applies
|
|
123
|
+
applyEntityTransform. Each step's output feeds the next step's input so that
|
|
124
|
+
per-step transformEntityProperty hooks are honoured throughout the chain.
|
|
125
|
+
|
|
126
|
+
#### Parameters
|
|
127
|
+
|
|
128
|
+
##### entity
|
|
129
|
+
|
|
130
|
+
`unknown`
|
|
131
|
+
|
|
132
|
+
The entity to transform (at the shape described by steps[0].fromProperties).
|
|
133
|
+
|
|
134
|
+
##### steps
|
|
135
|
+
|
|
136
|
+
[`IResolvedMigrationStep`](../interfaces/IResolvedMigrationStep.md)\<`unknown`, `unknown`\>[]
|
|
137
|
+
|
|
138
|
+
Ordered, fully-resolved migration steps from stored version to current version.
|
|
139
|
+
Each step's fromProperties and toProperties are resolved by the caller before invocation.
|
|
140
|
+
|
|
141
|
+
#### Returns
|
|
142
|
+
|
|
143
|
+
`unknown`
|
|
144
|
+
|
|
145
|
+
The entity transformed to the shape described by steps[last].toProperties.
|
|
146
|
+
|
|
147
|
+
***
|
|
148
|
+
|
|
149
|
+
### applyEntityTransform() {#applyentitytransform}
|
|
150
|
+
|
|
151
|
+
> `static` **applyEntityTransform**\<`T`, `U`\>(`entity`, `schemaDiff`, `transformEntityProperty?`): `U`
|
|
152
|
+
|
|
153
|
+
Applies the entity transformation for a single diff, handling added, removed, and
|
|
154
|
+
modified properties according to the provided schema diff and optional transform hook.
|
|
155
|
+
|
|
156
|
+
#### Type Parameters
|
|
157
|
+
|
|
158
|
+
##### T
|
|
159
|
+
|
|
160
|
+
`T` = `unknown`
|
|
161
|
+
|
|
162
|
+
##### U
|
|
163
|
+
|
|
164
|
+
`U` = `unknown`
|
|
165
|
+
|
|
166
|
+
#### Parameters
|
|
167
|
+
|
|
168
|
+
##### entity
|
|
169
|
+
|
|
170
|
+
`Partial`\<`T`\>
|
|
171
|
+
|
|
172
|
+
The entity to transform.
|
|
173
|
+
|
|
174
|
+
##### schemaDiff
|
|
175
|
+
|
|
176
|
+
`IEntitySchemaDiff`\<`T`, `U`\>
|
|
177
|
+
|
|
178
|
+
The schema diff between the old and new schemas.
|
|
179
|
+
|
|
180
|
+
##### transformEntityProperty?
|
|
181
|
+
|
|
182
|
+
[`EntityPropertyTransformer`](../type-aliases/EntityPropertyTransformer.md)\<`T`, `U`\>
|
|
183
|
+
|
|
184
|
+
Optional per-property transform hook for object/array properties.
|
|
185
|
+
|
|
186
|
+
#### Returns
|
|
187
|
+
|
|
188
|
+
`U`
|
|
189
|
+
|
|
190
|
+
The transformed entity ready to be written to the new schema.
|
|
191
|
+
|
|
192
|
+
#### Throws
|
|
193
|
+
|
|
194
|
+
GeneralError if a transformation is required for an object or array property but no transformEntityProperty function is provided.
|
|
195
|
+
|
|
196
|
+
#### Throws
|
|
197
|
+
|
|
198
|
+
GeneralError if coercion of a modified property results in undefined for a non-optional target property.
|
package/docs/reference/index.md
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
# @twin.org/entity-storage-models
|
|
2
2
|
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [EntityStorageHelper](classes/EntityStorageHelper.md)
|
|
6
|
+
- [MigrationHelper](classes/MigrationHelper.md)
|
|
7
|
+
|
|
3
8
|
## Interfaces
|
|
4
9
|
|
|
5
10
|
- [IEntityStorageComponent](interfaces/IEntityStorageComponent.md)
|
|
6
11
|
- [IEntityStorageConnector](interfaces/IEntityStorageConnector.md)
|
|
12
|
+
- [IEntityStorageMigrationConnector](interfaces/IEntityStorageMigrationConnector.md)
|
|
13
|
+
- [IMigrationOptions](interfaces/IMigrationOptions.md)
|
|
14
|
+
- [IResolvedMigrationStep](interfaces/IResolvedMigrationStep.md)
|
|
15
|
+
- [ISchemaMigration](interfaces/ISchemaMigration.md)
|
|
16
|
+
- [IEntityStorageCountRequest](interfaces/IEntityStorageCountRequest.md)
|
|
17
|
+
- [IEntityStorageCountResponse](interfaces/IEntityStorageCountResponse.md)
|
|
18
|
+
- [IEntityStorageEmptyRequest](interfaces/IEntityStorageEmptyRequest.md)
|
|
7
19
|
- [IEntityStorageGetRequest](interfaces/IEntityStorageGetRequest.md)
|
|
8
20
|
- [IEntityStorageGetResponse](interfaces/IEntityStorageGetResponse.md)
|
|
9
21
|
- [IEntityStorageListRequest](interfaces/IEntityStorageListRequest.md)
|
|
10
22
|
- [IEntityStorageListResponse](interfaces/IEntityStorageListResponse.md)
|
|
23
|
+
- [IEntityStorageRemoveBatchRequest](interfaces/IEntityStorageRemoveBatchRequest.md)
|
|
11
24
|
- [IEntityStorageRemoveRequest](interfaces/IEntityStorageRemoveRequest.md)
|
|
25
|
+
- [IEntityStorageSetBatchRequest](interfaces/IEntityStorageSetBatchRequest.md)
|
|
12
26
|
- [IEntityStorageSetRequest](interfaces/IEntityStorageSetRequest.md)
|
|
13
27
|
|
|
28
|
+
## Type Aliases
|
|
29
|
+
|
|
30
|
+
- [EntityPropertyTransformer](type-aliases/EntityPropertyTransformer.md)
|
|
31
|
+
|
|
14
32
|
## Variables
|
|
15
33
|
|
|
16
34
|
- [EntityStorageConnectorFactory](variables/EntityStorageConnectorFactory.md)
|
|
35
|
+
- [SchemaMigrationFactory](variables/SchemaMigrationFactory.md)
|
|
@@ -14,9 +14,9 @@ Interface describing an entity storage component.
|
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
|
-
### set()
|
|
17
|
+
### set() {#set}
|
|
18
18
|
|
|
19
|
-
> **set**(`entity`): `Promise`\<`void`\>
|
|
19
|
+
> **set**(`entity`, `conditions?`): `Promise`\<`void`\>
|
|
20
20
|
|
|
21
21
|
Set an entity.
|
|
22
22
|
|
|
@@ -28,6 +28,12 @@ Set an entity.
|
|
|
28
28
|
|
|
29
29
|
The entity to set.
|
|
30
30
|
|
|
31
|
+
##### conditions?
|
|
32
|
+
|
|
33
|
+
`object`[]
|
|
34
|
+
|
|
35
|
+
The optional conditions to match for the entities.
|
|
36
|
+
|
|
31
37
|
#### Returns
|
|
32
38
|
|
|
33
39
|
`Promise`\<`void`\>
|
|
@@ -36,9 +42,31 @@ The id of the entity.
|
|
|
36
42
|
|
|
37
43
|
***
|
|
38
44
|
|
|
39
|
-
###
|
|
45
|
+
### setBatch() {#setbatch}
|
|
46
|
+
|
|
47
|
+
> **setBatch**(`entities`): `Promise`\<`void`\>
|
|
48
|
+
|
|
49
|
+
Set multiple entities in a batch.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
##### entities
|
|
54
|
+
|
|
55
|
+
`T`[]
|
|
56
|
+
|
|
57
|
+
The entities to set.
|
|
58
|
+
|
|
59
|
+
#### Returns
|
|
60
|
+
|
|
61
|
+
`Promise`\<`void`\>
|
|
62
|
+
|
|
63
|
+
Nothing.
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### get() {#get}
|
|
40
68
|
|
|
41
|
-
> **get**(`id`, `secondaryIndex?`): `Promise`\<`T` \| `undefined`\>
|
|
69
|
+
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`T` \| `undefined`\>
|
|
42
70
|
|
|
43
71
|
Get an entity.
|
|
44
72
|
|
|
@@ -56,6 +84,12 @@ keyof `T`
|
|
|
56
84
|
|
|
57
85
|
Get the item using a secondary index.
|
|
58
86
|
|
|
87
|
+
##### conditions?
|
|
88
|
+
|
|
89
|
+
`object`[]
|
|
90
|
+
|
|
91
|
+
The optional conditions to match for the entities.
|
|
92
|
+
|
|
59
93
|
#### Returns
|
|
60
94
|
|
|
61
95
|
`Promise`\<`T` \| `undefined`\>
|
|
@@ -64,9 +98,9 @@ The object if it can be found or undefined.
|
|
|
64
98
|
|
|
65
99
|
***
|
|
66
100
|
|
|
67
|
-
### remove()
|
|
101
|
+
### remove() {#remove}
|
|
68
102
|
|
|
69
|
-
> **remove**(`id`): `Promise`\<`void`\>
|
|
103
|
+
> **remove**(`id`, `conditions?`): `Promise`\<`void`\>
|
|
70
104
|
|
|
71
105
|
Remove the entity.
|
|
72
106
|
|
|
@@ -78,6 +112,12 @@ Remove the entity.
|
|
|
78
112
|
|
|
79
113
|
The id of the entity to remove.
|
|
80
114
|
|
|
115
|
+
##### conditions?
|
|
116
|
+
|
|
117
|
+
`object`[]
|
|
118
|
+
|
|
119
|
+
The optional conditions to match for the entities.
|
|
120
|
+
|
|
81
121
|
#### Returns
|
|
82
122
|
|
|
83
123
|
`Promise`\<`void`\>
|
|
@@ -86,7 +126,29 @@ Nothing.
|
|
|
86
126
|
|
|
87
127
|
***
|
|
88
128
|
|
|
89
|
-
###
|
|
129
|
+
### removeBatch() {#removebatch}
|
|
130
|
+
|
|
131
|
+
> **removeBatch**(`ids`): `Promise`\<`void`\>
|
|
132
|
+
|
|
133
|
+
Remove multiple entities by id.
|
|
134
|
+
|
|
135
|
+
#### Parameters
|
|
136
|
+
|
|
137
|
+
##### ids
|
|
138
|
+
|
|
139
|
+
`string`[]
|
|
140
|
+
|
|
141
|
+
The ids of the entities to remove.
|
|
142
|
+
|
|
143
|
+
#### Returns
|
|
144
|
+
|
|
145
|
+
`Promise`\<`void`\>
|
|
146
|
+
|
|
147
|
+
Nothing.
|
|
148
|
+
|
|
149
|
+
***
|
|
150
|
+
|
|
151
|
+
### query() {#query}
|
|
90
152
|
|
|
91
153
|
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
92
154
|
|
|
@@ -136,3 +198,39 @@ The suggested number of entities to return in each chunk, in some scenarios can
|
|
|
136
198
|
|
|
137
199
|
All the entities for the storage matching the conditions,
|
|
138
200
|
and a cursor which can be used to request more entities.
|
|
201
|
+
|
|
202
|
+
***
|
|
203
|
+
|
|
204
|
+
### empty() {#empty}
|
|
205
|
+
|
|
206
|
+
> **empty**(): `Promise`\<`void`\>
|
|
207
|
+
|
|
208
|
+
Remove all entities from the storage.
|
|
209
|
+
|
|
210
|
+
#### Returns
|
|
211
|
+
|
|
212
|
+
`Promise`\<`void`\>
|
|
213
|
+
|
|
214
|
+
Nothing.
|
|
215
|
+
|
|
216
|
+
***
|
|
217
|
+
|
|
218
|
+
### count() {#count}
|
|
219
|
+
|
|
220
|
+
> **count**(`conditions?`): `Promise`\<`number`\>
|
|
221
|
+
|
|
222
|
+
Count all the entities which match the conditions.
|
|
223
|
+
|
|
224
|
+
#### Parameters
|
|
225
|
+
|
|
226
|
+
##### conditions?
|
|
227
|
+
|
|
228
|
+
`EntityCondition`\<`T`\>
|
|
229
|
+
|
|
230
|
+
The optional conditions to match for the entities.
|
|
231
|
+
|
|
232
|
+
#### Returns
|
|
233
|
+
|
|
234
|
+
`Promise`\<`number`\>
|
|
235
|
+
|
|
236
|
+
The total count of entities in the storage.
|