@twin.org/entity-storage-models 0.0.3-next.2 → 0.0.3-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/es/helpers/entityStorageHelper.js +85 -0
- package/dist/es/helpers/entityStorageHelper.js.map +1 -0
- package/dist/es/helpers/migrationHelper.js +220 -0
- package/dist/es/helpers/migrationHelper.js.map +1 -0
- package/dist/es/index.js +9 -0
- 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/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/types/helpers/entityStorageHelper.d.ts +40 -0
- package/dist/types/helpers/migrationHelper.d.ts +61 -0
- package/dist/types/index.d.ts +9 -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 +32 -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/docs/changelog.md +224 -43
- package/docs/examples.md +87 -1
- package/docs/reference/classes/EntityStorageHelper.md +135 -0
- package/docs/reference/classes/MigrationHelper.md +247 -0
- package/docs/reference/index.md +12 -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 +119 -0
- package/locales/en.json +7 -1
- package/package.json +5 -4
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Class: MigrationHelper
|
|
2
|
+
|
|
3
|
+
Helper class for performing schema migrations between two connectors.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new MigrationHelper**(): `MigrationHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`MigrationHelper`
|
|
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
|
+
### migrate() {#migrate}
|
|
26
|
+
|
|
27
|
+
> `static` **migrate**\<`T`, `U`\>(`sourceConnector`, `targetEntitySchemaName`, `renames?`, `options?`, `loggingComponentType?`): `Promise`\<\{ `finalConnector?`: [`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md)\<`U`\>; `migrated`: `number`; \}\>
|
|
28
|
+
|
|
29
|
+
Performs a migration between two connectors, using the provided options and schema diff to control the migration behaviour.
|
|
30
|
+
|
|
31
|
+
#### Type Parameters
|
|
32
|
+
|
|
33
|
+
##### T
|
|
34
|
+
|
|
35
|
+
`T`
|
|
36
|
+
|
|
37
|
+
##### U
|
|
38
|
+
|
|
39
|
+
`U`
|
|
40
|
+
|
|
41
|
+
#### Parameters
|
|
42
|
+
|
|
43
|
+
##### sourceConnector
|
|
44
|
+
|
|
45
|
+
[`IEntityStorageMigrationConnector`](../interfaces/IEntityStorageMigrationConnector.md)\<`T`\>
|
|
46
|
+
|
|
47
|
+
The connector to migrate from to allow the migration helper to create the new connector and finalize the migration.
|
|
48
|
+
|
|
49
|
+
##### targetEntitySchemaName
|
|
50
|
+
|
|
51
|
+
`string`
|
|
52
|
+
|
|
53
|
+
The name of the new entity schema.
|
|
54
|
+
|
|
55
|
+
##### renames?
|
|
56
|
+
|
|
57
|
+
`object`[]
|
|
58
|
+
|
|
59
|
+
An optional list of property renames to apply during migration.
|
|
60
|
+
|
|
61
|
+
##### options?
|
|
62
|
+
|
|
63
|
+
[`IMigrationOptions`](../interfaces/IMigrationOptions.md)\<`T`, `U`\>
|
|
64
|
+
|
|
65
|
+
Options controlling migration behaviour.
|
|
66
|
+
|
|
67
|
+
##### loggingComponentType?
|
|
68
|
+
|
|
69
|
+
`string`
|
|
70
|
+
|
|
71
|
+
An optional logging component type to use for bootstrapping and starting connectors if necessary.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`Promise`\<\{ `finalConnector?`: [`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md)\<`U`\>; `migrated`: `number`; \}\>
|
|
76
|
+
|
|
77
|
+
The connector for the new schema and the number of entities successfully migrated, the sourceConnector will no longer be usable, finalConnector will be undefined if no migration was necessary.
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
### migrateEntities() {#migrateentities}
|
|
82
|
+
|
|
83
|
+
> `static` **migrateEntities**\<`T`, `U`\>(`source`, `target`, `partitionContextIds`, `schemaDiff`, `options?`): `Promise`\<`number`\>
|
|
84
|
+
|
|
85
|
+
Generic per-partition migration loop.
|
|
86
|
+
|
|
87
|
+
#### Type Parameters
|
|
88
|
+
|
|
89
|
+
##### T
|
|
90
|
+
|
|
91
|
+
`T` = `unknown`
|
|
92
|
+
|
|
93
|
+
##### U
|
|
94
|
+
|
|
95
|
+
`U` = `T`
|
|
96
|
+
|
|
97
|
+
#### Parameters
|
|
98
|
+
|
|
99
|
+
##### source
|
|
100
|
+
|
|
101
|
+
[`IEntityStorageMigrationConnector`](../interfaces/IEntityStorageMigrationConnector.md)\<`T`\>
|
|
102
|
+
|
|
103
|
+
Connector to read from (current schema, already bootstrapped).
|
|
104
|
+
|
|
105
|
+
##### target
|
|
106
|
+
|
|
107
|
+
[`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md)\<`U`\>
|
|
108
|
+
|
|
109
|
+
Connector to write to (new schema, already bootstrapped).
|
|
110
|
+
|
|
111
|
+
##### partitionContextIds
|
|
112
|
+
|
|
113
|
+
`IContextIds`[]
|
|
114
|
+
|
|
115
|
+
The context ids to use for the migration, used for partitioning and can be used in the transform function when `options.transformEntityProperty` is provided.
|
|
116
|
+
|
|
117
|
+
##### schemaDiff
|
|
118
|
+
|
|
119
|
+
`IEntitySchemaDiff`\<`T`, `U`\>
|
|
120
|
+
|
|
121
|
+
The schema diff.
|
|
122
|
+
|
|
123
|
+
##### options?
|
|
124
|
+
|
|
125
|
+
[`IMigrationOptions`](../interfaces/IMigrationOptions.md)\<`T`, `U`\>
|
|
126
|
+
|
|
127
|
+
Optional migration controls (batchSize, transformEntity, onProgress).
|
|
128
|
+
|
|
129
|
+
#### Returns
|
|
130
|
+
|
|
131
|
+
`Promise`\<`number`\>
|
|
132
|
+
|
|
133
|
+
The number of entities successfully migrated.
|
|
134
|
+
|
|
135
|
+
***
|
|
136
|
+
|
|
137
|
+
### migratePartition() {#migratepartition}
|
|
138
|
+
|
|
139
|
+
> `static` **migratePartition**\<`T`, `U`\>(`source`, `target`, `partitionTotal`, `partitionIndex`, `schemaDiff`, `options?`): `Promise`\<`number`\>
|
|
140
|
+
|
|
141
|
+
Generic per-partition migration loop.
|
|
142
|
+
|
|
143
|
+
#### Type Parameters
|
|
144
|
+
|
|
145
|
+
##### T
|
|
146
|
+
|
|
147
|
+
`T` = `unknown`
|
|
148
|
+
|
|
149
|
+
##### U
|
|
150
|
+
|
|
151
|
+
`U` = `unknown`
|
|
152
|
+
|
|
153
|
+
#### Parameters
|
|
154
|
+
|
|
155
|
+
##### source
|
|
156
|
+
|
|
157
|
+
[`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md)\<`T`\>
|
|
158
|
+
|
|
159
|
+
Connector to read from (current schema, already bootstrapped).
|
|
160
|
+
|
|
161
|
+
##### target
|
|
162
|
+
|
|
163
|
+
[`IEntityStorageConnector`](../interfaces/IEntityStorageConnector.md)\<`U`\>
|
|
164
|
+
|
|
165
|
+
Connector to write to (new schema, already bootstrapped).
|
|
166
|
+
|
|
167
|
+
##### partitionTotal
|
|
168
|
+
|
|
169
|
+
`number`
|
|
170
|
+
|
|
171
|
+
The total number of partitions to migrate, used for progress reporting.
|
|
172
|
+
|
|
173
|
+
##### partitionIndex
|
|
174
|
+
|
|
175
|
+
`number`
|
|
176
|
+
|
|
177
|
+
The index of the current partition being migrated, used for progress reporting.
|
|
178
|
+
|
|
179
|
+
##### schemaDiff
|
|
180
|
+
|
|
181
|
+
`IEntitySchemaDiff`\<`T`, `U`\>
|
|
182
|
+
|
|
183
|
+
Schema diff used to add nullable defaults and drop removed fields when `options.transformEntity` is not provided.
|
|
184
|
+
|
|
185
|
+
##### options?
|
|
186
|
+
|
|
187
|
+
[`IMigrationOptions`](../interfaces/IMigrationOptions.md)\<`T`, `U`\>
|
|
188
|
+
|
|
189
|
+
Optional migration controls (batchSize, transformEntity, onProgress).
|
|
190
|
+
|
|
191
|
+
#### Returns
|
|
192
|
+
|
|
193
|
+
`Promise`\<`number`\>
|
|
194
|
+
|
|
195
|
+
The number of entities successfully migrated.
|
|
196
|
+
|
|
197
|
+
***
|
|
198
|
+
|
|
199
|
+
### applyEntityTransform() {#applyentitytransform}
|
|
200
|
+
|
|
201
|
+
> `static` **applyEntityTransform**\<`T`, `U`\>(`entity`, `schemaDiff`, `options?`): `U`
|
|
202
|
+
|
|
203
|
+
Applies the entity transformation for migration, using the provided options and schema diff.
|
|
204
|
+
|
|
205
|
+
#### Type Parameters
|
|
206
|
+
|
|
207
|
+
##### T
|
|
208
|
+
|
|
209
|
+
`T` = `unknown`
|
|
210
|
+
|
|
211
|
+
##### U
|
|
212
|
+
|
|
213
|
+
`U` = `unknown`
|
|
214
|
+
|
|
215
|
+
#### Parameters
|
|
216
|
+
|
|
217
|
+
##### entity
|
|
218
|
+
|
|
219
|
+
`Partial`\<`T`\>
|
|
220
|
+
|
|
221
|
+
The entity to transform.
|
|
222
|
+
|
|
223
|
+
##### schemaDiff
|
|
224
|
+
|
|
225
|
+
`IEntitySchemaDiff`\<`T`, `U`\>
|
|
226
|
+
|
|
227
|
+
The schema diff between the old and new schemas.
|
|
228
|
+
|
|
229
|
+
##### options?
|
|
230
|
+
|
|
231
|
+
[`IMigrationOptions`](../interfaces/IMigrationOptions.md)\<`T`, `U`\>
|
|
232
|
+
|
|
233
|
+
The migration options.
|
|
234
|
+
|
|
235
|
+
#### Returns
|
|
236
|
+
|
|
237
|
+
`U`
|
|
238
|
+
|
|
239
|
+
The transformed entity ready to be written to the new schema.
|
|
240
|
+
|
|
241
|
+
#### Throws
|
|
242
|
+
|
|
243
|
+
GeneralError if a transformation is required for an object or array property but no `options.transformEntityProperty` function is provided.
|
|
244
|
+
|
|
245
|
+
#### Throws
|
|
246
|
+
|
|
247
|
+
GeneralError if coercion of a modified property results in undefined for a non-optional target property.
|
package/docs/reference/index.md
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
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
|
+
- [IEntityStorageCountRequest](interfaces/IEntityStorageCountRequest.md)
|
|
15
|
+
- [IEntityStorageCountResponse](interfaces/IEntityStorageCountResponse.md)
|
|
16
|
+
- [IEntityStorageEmptyRequest](interfaces/IEntityStorageEmptyRequest.md)
|
|
7
17
|
- [IEntityStorageGetRequest](interfaces/IEntityStorageGetRequest.md)
|
|
8
18
|
- [IEntityStorageGetResponse](interfaces/IEntityStorageGetResponse.md)
|
|
9
19
|
- [IEntityStorageListRequest](interfaces/IEntityStorageListRequest.md)
|
|
10
20
|
- [IEntityStorageListResponse](interfaces/IEntityStorageListResponse.md)
|
|
21
|
+
- [IEntityStorageRemoveBatchRequest](interfaces/IEntityStorageRemoveBatchRequest.md)
|
|
11
22
|
- [IEntityStorageRemoveRequest](interfaces/IEntityStorageRemoveRequest.md)
|
|
23
|
+
- [IEntityStorageSetBatchRequest](interfaces/IEntityStorageSetBatchRequest.md)
|
|
12
24
|
- [IEntityStorageSetRequest](interfaces/IEntityStorageSetRequest.md)
|
|
13
25
|
|
|
14
26
|
## Variables
|
|
@@ -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.
|
|
@@ -6,6 +6,10 @@ Interface describing an entity storage connector.
|
|
|
6
6
|
|
|
7
7
|
- `IComponent`
|
|
8
8
|
|
|
9
|
+
## Extended by
|
|
10
|
+
|
|
11
|
+
- [`IEntityStorageMigrationConnector`](IEntityStorageMigrationConnector.md)
|
|
12
|
+
|
|
9
13
|
## Type Parameters
|
|
10
14
|
|
|
11
15
|
### T
|
|
@@ -14,7 +18,7 @@ Interface describing an entity storage connector.
|
|
|
14
18
|
|
|
15
19
|
## Methods
|
|
16
20
|
|
|
17
|
-
### getSchema()
|
|
21
|
+
### getSchema() {#getschema}
|
|
18
22
|
|
|
19
23
|
> **getSchema**(): `IEntitySchema`
|
|
20
24
|
|
|
@@ -28,7 +32,7 @@ The schema for the entities.
|
|
|
28
32
|
|
|
29
33
|
***
|
|
30
34
|
|
|
31
|
-
### set()
|
|
35
|
+
### set() {#set}
|
|
32
36
|
|
|
33
37
|
> **set**(`entity`, `conditions?`): `Promise`\<`void`\>
|
|
34
38
|
|
|
@@ -56,7 +60,29 @@ The id of the entity.
|
|
|
56
60
|
|
|
57
61
|
***
|
|
58
62
|
|
|
59
|
-
###
|
|
63
|
+
### setBatch() {#setbatch}
|
|
64
|
+
|
|
65
|
+
> **setBatch**(`entities`): `Promise`\<`void`\>
|
|
66
|
+
|
|
67
|
+
Set multiple entities in a batch.
|
|
68
|
+
|
|
69
|
+
#### Parameters
|
|
70
|
+
|
|
71
|
+
##### entities
|
|
72
|
+
|
|
73
|
+
`T`[]
|
|
74
|
+
|
|
75
|
+
The entities to set.
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
`Promise`\<`void`\>
|
|
80
|
+
|
|
81
|
+
Nothing.
|
|
82
|
+
|
|
83
|
+
***
|
|
84
|
+
|
|
85
|
+
### get() {#get}
|
|
60
86
|
|
|
61
87
|
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`T` \| `undefined`\>
|
|
62
88
|
|
|
@@ -90,7 +116,7 @@ The object if it can be found or undefined.
|
|
|
90
116
|
|
|
91
117
|
***
|
|
92
118
|
|
|
93
|
-
### remove()
|
|
119
|
+
### remove() {#remove}
|
|
94
120
|
|
|
95
121
|
> **remove**(`id`, `conditions?`): `Promise`\<`void`\>
|
|
96
122
|
|
|
@@ -118,7 +144,29 @@ Nothing.
|
|
|
118
144
|
|
|
119
145
|
***
|
|
120
146
|
|
|
121
|
-
###
|
|
147
|
+
### removeBatch() {#removebatch}
|
|
148
|
+
|
|
149
|
+
> **removeBatch**(`ids`): `Promise`\<`void`\>
|
|
150
|
+
|
|
151
|
+
Remove multiple entities by id.
|
|
152
|
+
|
|
153
|
+
#### Parameters
|
|
154
|
+
|
|
155
|
+
##### ids
|
|
156
|
+
|
|
157
|
+
`string`[]
|
|
158
|
+
|
|
159
|
+
The ids of the entities to remove.
|
|
160
|
+
|
|
161
|
+
#### Returns
|
|
162
|
+
|
|
163
|
+
`Promise`\<`void`\>
|
|
164
|
+
|
|
165
|
+
Nothing.
|
|
166
|
+
|
|
167
|
+
***
|
|
168
|
+
|
|
169
|
+
### query() {#query}
|
|
122
170
|
|
|
123
171
|
> **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
124
172
|
|
|
@@ -162,3 +210,39 @@ The suggested number of entities to return in each chunk, in some scenarios can
|
|
|
162
210
|
|
|
163
211
|
All the entities for the storage matching the conditions,
|
|
164
212
|
and a cursor which can be used to request more entities.
|
|
213
|
+
|
|
214
|
+
***
|
|
215
|
+
|
|
216
|
+
### empty() {#empty}
|
|
217
|
+
|
|
218
|
+
> **empty**(): `Promise`\<`void`\>
|
|
219
|
+
|
|
220
|
+
Remove all entities from the storage.
|
|
221
|
+
|
|
222
|
+
#### Returns
|
|
223
|
+
|
|
224
|
+
`Promise`\<`void`\>
|
|
225
|
+
|
|
226
|
+
Nothing.
|
|
227
|
+
|
|
228
|
+
***
|
|
229
|
+
|
|
230
|
+
### count() {#count}
|
|
231
|
+
|
|
232
|
+
> **count**(`conditions?`): `Promise`\<`number`\>
|
|
233
|
+
|
|
234
|
+
Count all the entities which match the conditions.
|
|
235
|
+
|
|
236
|
+
#### Parameters
|
|
237
|
+
|
|
238
|
+
##### conditions?
|
|
239
|
+
|
|
240
|
+
`EntityCondition`\<`T`\>
|
|
241
|
+
|
|
242
|
+
The optional conditions to match for the entities.
|
|
243
|
+
|
|
244
|
+
#### Returns
|
|
245
|
+
|
|
246
|
+
`Promise`\<`number`\>
|
|
247
|
+
|
|
248
|
+
The total count of entities in the storage.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: IEntityStorageCountRequest
|
|
2
|
+
|
|
3
|
+
Count the entries in entity storage.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### query? {#query}
|
|
8
|
+
|
|
9
|
+
> `optional` **query?**: `object`
|
|
10
|
+
|
|
11
|
+
The query parameters.
|
|
12
|
+
|
|
13
|
+
#### conditions?
|
|
14
|
+
|
|
15
|
+
> `optional` **conditions?**: `string`
|
|
16
|
+
|
|
17
|
+
The optional conditions to filter the count, JSON encoded EntityCondition.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: IEntityStorageCountResponse
|
|
2
|
+
|
|
3
|
+
The response for counting entries in entity storage.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### body {#body}
|
|
8
|
+
|
|
9
|
+
> **body**: `object`
|
|
10
|
+
|
|
11
|
+
The body of the response.
|
|
12
|
+
|
|
13
|
+
#### count
|
|
14
|
+
|
|
15
|
+
> **count**: `number`
|
|
16
|
+
|
|
17
|
+
The total count of entities.
|
|
@@ -4,7 +4,7 @@ Get an entry from entity storage.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### pathParams
|
|
7
|
+
### pathParams {#pathparams}
|
|
8
8
|
|
|
9
9
|
> **pathParams**: `object`
|
|
10
10
|
|
|
@@ -18,14 +18,20 @@ The id of the entity to get.
|
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
21
|
-
### query?
|
|
21
|
+
### query? {#query}
|
|
22
22
|
|
|
23
|
-
> `optional` **query
|
|
23
|
+
> `optional` **query?**: `object`
|
|
24
24
|
|
|
25
25
|
The query parameters.
|
|
26
26
|
|
|
27
27
|
#### secondaryIndex?
|
|
28
28
|
|
|
29
|
-
> `optional` **secondaryIndex
|
|
29
|
+
> `optional` **secondaryIndex?**: `string`
|
|
30
30
|
|
|
31
31
|
The secondary index to query with the id.
|
|
32
|
+
|
|
33
|
+
#### conditions?
|
|
34
|
+
|
|
35
|
+
> `optional` **conditions?**: `string`
|
|
36
|
+
|
|
37
|
+
The optional conditions to match for the entity, JSON encoded array of property/value pairs.
|
|
@@ -4,44 +4,44 @@ Query the entries from entity storage.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### query?
|
|
7
|
+
### query? {#query}
|
|
8
8
|
|
|
9
|
-
> `optional` **query
|
|
9
|
+
> `optional` **query?**: `object`
|
|
10
10
|
|
|
11
11
|
The parameters from the query.
|
|
12
12
|
|
|
13
13
|
#### conditions?
|
|
14
14
|
|
|
15
|
-
> `optional` **conditions
|
|
15
|
+
> `optional` **conditions?**: `string`
|
|
16
16
|
|
|
17
17
|
The condition for the query as JSON version of EntityCondition type.
|
|
18
18
|
|
|
19
19
|
#### orderBy?
|
|
20
20
|
|
|
21
|
-
> `optional` **orderBy
|
|
21
|
+
> `optional` **orderBy?**: `string`
|
|
22
22
|
|
|
23
23
|
The order property for the results.
|
|
24
24
|
|
|
25
25
|
#### orderByDirection?
|
|
26
26
|
|
|
27
|
-
> `optional` **orderByDirection
|
|
27
|
+
> `optional` **orderByDirection?**: `SortDirection`
|
|
28
28
|
|
|
29
29
|
The direction for the order, defaults to desc.
|
|
30
30
|
|
|
31
31
|
#### properties?
|
|
32
32
|
|
|
33
|
-
> `optional` **properties
|
|
33
|
+
> `optional` **properties?**: `string`
|
|
34
34
|
|
|
35
35
|
The properties to return in the response as a comma separated list, by default returns all properties.
|
|
36
36
|
|
|
37
37
|
#### limit?
|
|
38
38
|
|
|
39
|
-
> `optional` **limit
|
|
39
|
+
> `optional` **limit?**: `string`
|
|
40
40
|
|
|
41
41
|
Limit the number of entities to return.
|
|
42
42
|
|
|
43
43
|
#### cursor?
|
|
44
44
|
|
|
45
|
-
> `optional` **cursor
|
|
45
|
+
> `optional` **cursor?**: `string`
|
|
46
46
|
|
|
47
47
|
The cursor to get next chunk of data, returned in previous response.
|