@twin.org/entity-storage-connector-mongodb 0.0.3-next.9 → 0.9.0
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/dist/es/models/IMongoDbEntityStorageConnectorConstructorOptions.js.map +1 -1
- package/dist/es/mongoDbEntityStorageConnector.js +332 -65
- package/dist/es/mongoDbEntityStorageConnector.js.map +1 -1
- package/dist/types/models/IMongoDbEntityStorageConnectorConstructorOptions.d.ts +0 -1
- package/dist/types/mongoDbEntityStorageConnector.d.ts +69 -5
- package/docs/changelog.md +602 -55
- package/docs/reference/classes/MongoDbEntityStorageConnector.md +302 -12
- package/docs/reference/interfaces/IMongoDbEntityStorageConnectorConstructorOptions.md +0 -6
- package/locales/en.json +17 -2
- package/package.json +10 -10
|
@@ -10,7 +10,7 @@ Class for performing entity storage operations using MongoDb.
|
|
|
10
10
|
|
|
11
11
|
## Implements
|
|
12
12
|
|
|
13
|
-
- `
|
|
13
|
+
- `IEntityStorageMigrationConnector`\<`T`\>
|
|
14
14
|
|
|
15
15
|
## Constructors
|
|
16
16
|
|
|
@@ -64,7 +64,33 @@ A promise that resolves to a boolean indicating success.
|
|
|
64
64
|
|
|
65
65
|
#### Implementation of
|
|
66
66
|
|
|
67
|
-
`
|
|
67
|
+
`IEntityStorageMigrationConnector.bootstrap`
|
|
68
|
+
|
|
69
|
+
***
|
|
70
|
+
|
|
71
|
+
### stop()? {#stop}
|
|
72
|
+
|
|
73
|
+
> `optional` **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
74
|
+
|
|
75
|
+
The component needs to be stopped when the node is closed.
|
|
76
|
+
|
|
77
|
+
#### Parameters
|
|
78
|
+
|
|
79
|
+
##### nodeLoggingComponentType?
|
|
80
|
+
|
|
81
|
+
`string`
|
|
82
|
+
|
|
83
|
+
The node logging component type.
|
|
84
|
+
|
|
85
|
+
#### Returns
|
|
86
|
+
|
|
87
|
+
`Promise`\<`void`\>
|
|
88
|
+
|
|
89
|
+
Nothing.
|
|
90
|
+
|
|
91
|
+
#### Implementation of
|
|
92
|
+
|
|
93
|
+
`IEntityStorageMigrationConnector.stop`
|
|
68
94
|
|
|
69
95
|
***
|
|
70
96
|
|
|
@@ -82,7 +108,25 @@ The class name of the component.
|
|
|
82
108
|
|
|
83
109
|
#### Implementation of
|
|
84
110
|
|
|
85
|
-
`
|
|
111
|
+
`IEntityStorageMigrationConnector.className`
|
|
112
|
+
|
|
113
|
+
***
|
|
114
|
+
|
|
115
|
+
### health() {#health}
|
|
116
|
+
|
|
117
|
+
> **health**(): `Promise`\<`IHealth`[]\>
|
|
118
|
+
|
|
119
|
+
Returns the health status of the component.
|
|
120
|
+
|
|
121
|
+
#### Returns
|
|
122
|
+
|
|
123
|
+
`Promise`\<`IHealth`[]\>
|
|
124
|
+
|
|
125
|
+
The health status of the component.
|
|
126
|
+
|
|
127
|
+
#### Implementation of
|
|
128
|
+
|
|
129
|
+
`IEntityStorageMigrationConnector.health`
|
|
86
130
|
|
|
87
131
|
***
|
|
88
132
|
|
|
@@ -100,7 +144,7 @@ The schema for the entities.
|
|
|
100
144
|
|
|
101
145
|
#### Implementation of
|
|
102
146
|
|
|
103
|
-
`
|
|
147
|
+
`IEntityStorageMigrationConnector.getSchema`
|
|
104
148
|
|
|
105
149
|
***
|
|
106
150
|
|
|
@@ -138,7 +182,7 @@ The object if it can be found or undefined.
|
|
|
138
182
|
|
|
139
183
|
#### Implementation of
|
|
140
184
|
|
|
141
|
-
`
|
|
185
|
+
`IEntityStorageMigrationConnector.get`
|
|
142
186
|
|
|
143
187
|
***
|
|
144
188
|
|
|
@@ -170,7 +214,51 @@ The id of the entity.
|
|
|
170
214
|
|
|
171
215
|
#### Implementation of
|
|
172
216
|
|
|
173
|
-
`
|
|
217
|
+
`IEntityStorageMigrationConnector.set`
|
|
218
|
+
|
|
219
|
+
***
|
|
220
|
+
|
|
221
|
+
### setBatch() {#setbatch}
|
|
222
|
+
|
|
223
|
+
> **setBatch**(`entities`): `Promise`\<`void`\>
|
|
224
|
+
|
|
225
|
+
Set multiple entities in a batch.
|
|
226
|
+
|
|
227
|
+
#### Parameters
|
|
228
|
+
|
|
229
|
+
##### entities
|
|
230
|
+
|
|
231
|
+
`T`[]
|
|
232
|
+
|
|
233
|
+
The entities to set.
|
|
234
|
+
|
|
235
|
+
#### Returns
|
|
236
|
+
|
|
237
|
+
`Promise`\<`void`\>
|
|
238
|
+
|
|
239
|
+
Nothing.
|
|
240
|
+
|
|
241
|
+
#### Implementation of
|
|
242
|
+
|
|
243
|
+
`IEntityStorageMigrationConnector.setBatch`
|
|
244
|
+
|
|
245
|
+
***
|
|
246
|
+
|
|
247
|
+
### empty() {#empty}
|
|
248
|
+
|
|
249
|
+
> **empty**(): `Promise`\<`void`\>
|
|
250
|
+
|
|
251
|
+
Empty the entity storage.
|
|
252
|
+
|
|
253
|
+
#### Returns
|
|
254
|
+
|
|
255
|
+
`Promise`\<`void`\>
|
|
256
|
+
|
|
257
|
+
Nothing.
|
|
258
|
+
|
|
259
|
+
#### Implementation of
|
|
260
|
+
|
|
261
|
+
`IEntityStorageMigrationConnector.empty`
|
|
174
262
|
|
|
175
263
|
***
|
|
176
264
|
|
|
@@ -202,7 +290,59 @@ Nothing.
|
|
|
202
290
|
|
|
203
291
|
#### Implementation of
|
|
204
292
|
|
|
205
|
-
`
|
|
293
|
+
`IEntityStorageMigrationConnector.remove`
|
|
294
|
+
|
|
295
|
+
***
|
|
296
|
+
|
|
297
|
+
### removeBatch() {#removebatch}
|
|
298
|
+
|
|
299
|
+
> **removeBatch**(`ids`): `Promise`\<`void`\>
|
|
300
|
+
|
|
301
|
+
Remove multiple entities by id.
|
|
302
|
+
|
|
303
|
+
#### Parameters
|
|
304
|
+
|
|
305
|
+
##### ids
|
|
306
|
+
|
|
307
|
+
`string`[]
|
|
308
|
+
|
|
309
|
+
The ids of the entities to remove.
|
|
310
|
+
|
|
311
|
+
#### Returns
|
|
312
|
+
|
|
313
|
+
`Promise`\<`void`\>
|
|
314
|
+
|
|
315
|
+
Nothing.
|
|
316
|
+
|
|
317
|
+
#### Implementation of
|
|
318
|
+
|
|
319
|
+
`IEntityStorageMigrationConnector.removeBatch`
|
|
320
|
+
|
|
321
|
+
***
|
|
322
|
+
|
|
323
|
+
### teardown() {#teardown}
|
|
324
|
+
|
|
325
|
+
> **teardown**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
326
|
+
|
|
327
|
+
Teardown the entity storage by dropping the collection.
|
|
328
|
+
|
|
329
|
+
#### Parameters
|
|
330
|
+
|
|
331
|
+
##### nodeLoggingComponentType?
|
|
332
|
+
|
|
333
|
+
`string`
|
|
334
|
+
|
|
335
|
+
The node logging component type.
|
|
336
|
+
|
|
337
|
+
#### Returns
|
|
338
|
+
|
|
339
|
+
`Promise`\<`boolean`\>
|
|
340
|
+
|
|
341
|
+
True if the teardown process was successful.
|
|
342
|
+
|
|
343
|
+
#### Implementation of
|
|
344
|
+
|
|
345
|
+
`IEntityStorageMigrationConnector.teardown`
|
|
206
346
|
|
|
207
347
|
***
|
|
208
348
|
|
|
@@ -253,18 +393,168 @@ and a cursor which can be used to request more entities.
|
|
|
253
393
|
|
|
254
394
|
#### Implementation of
|
|
255
395
|
|
|
256
|
-
`
|
|
396
|
+
`IEntityStorageMigrationConnector.query`
|
|
397
|
+
|
|
398
|
+
***
|
|
399
|
+
|
|
400
|
+
### count() {#count}
|
|
401
|
+
|
|
402
|
+
> **count**(`conditions?`): `Promise`\<`number`\>
|
|
403
|
+
|
|
404
|
+
Count all the entities which match the conditions.
|
|
405
|
+
|
|
406
|
+
#### Parameters
|
|
407
|
+
|
|
408
|
+
##### conditions?
|
|
409
|
+
|
|
410
|
+
`EntityCondition`\<`T`\>
|
|
411
|
+
|
|
412
|
+
The optional conditions to match for the entities.
|
|
413
|
+
|
|
414
|
+
#### Returns
|
|
415
|
+
|
|
416
|
+
`Promise`\<`number`\>
|
|
417
|
+
|
|
418
|
+
The total count of entities in the storage.
|
|
419
|
+
|
|
420
|
+
#### Implementation of
|
|
421
|
+
|
|
422
|
+
`IEntityStorageMigrationConnector.count`
|
|
423
|
+
|
|
424
|
+
***
|
|
425
|
+
|
|
426
|
+
### getPartitionContextIds() {#getpartitioncontextids}
|
|
427
|
+
|
|
428
|
+
> **getPartitionContextIds**(): `Promise`\<`IContextIds`[]\>
|
|
429
|
+
|
|
430
|
+
Get all unique partition context ids present in the collection.
|
|
431
|
+
|
|
432
|
+
#### Returns
|
|
433
|
+
|
|
434
|
+
`Promise`\<`IContextIds`[]\>
|
|
435
|
+
|
|
436
|
+
An array of context id objects, one per unique partition.
|
|
437
|
+
|
|
438
|
+
#### Implementation of
|
|
439
|
+
|
|
440
|
+
`IEntityStorageMigrationConnector.getPartitionContextIds`
|
|
441
|
+
|
|
442
|
+
***
|
|
443
|
+
|
|
444
|
+
### createTargetConnector() {#createtargetconnector}
|
|
445
|
+
|
|
446
|
+
> **createTargetConnector**\<`U`\>(`newEntitySchema`): `Promise`\<`IEntityStorageConnector`\<`U`\>\>
|
|
447
|
+
|
|
448
|
+
Create the target connector for performing the migration using a temporary collection.
|
|
449
|
+
|
|
450
|
+
#### Type Parameters
|
|
451
|
+
|
|
452
|
+
##### U
|
|
453
|
+
|
|
454
|
+
`U`
|
|
455
|
+
|
|
456
|
+
#### Parameters
|
|
457
|
+
|
|
458
|
+
##### newEntitySchema
|
|
459
|
+
|
|
460
|
+
`string`
|
|
461
|
+
|
|
462
|
+
The name of the new entity schema to create the connector for.
|
|
463
|
+
|
|
464
|
+
#### Returns
|
|
465
|
+
|
|
466
|
+
`Promise`\<`IEntityStorageConnector`\<`U`\>\>
|
|
467
|
+
|
|
468
|
+
Connector for performing the migration.
|
|
469
|
+
|
|
470
|
+
#### Implementation of
|
|
471
|
+
|
|
472
|
+
`IEntityStorageMigrationConnector.createTargetConnector`
|
|
257
473
|
|
|
258
474
|
***
|
|
259
475
|
|
|
260
|
-
###
|
|
476
|
+
### finalizeMigration() {#finalizemigration}
|
|
477
|
+
|
|
478
|
+
> **finalizeMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`MongoDbEntityStorageConnector`\<`U`\>\>
|
|
479
|
+
|
|
480
|
+
Finalize the migration by dropping the source collection and renaming the migration collection to the original name.
|
|
481
|
+
|
|
482
|
+
#### Type Parameters
|
|
483
|
+
|
|
484
|
+
##### U
|
|
485
|
+
|
|
486
|
+
`U`
|
|
487
|
+
|
|
488
|
+
#### Parameters
|
|
489
|
+
|
|
490
|
+
##### targetConnector
|
|
261
491
|
|
|
262
|
-
|
|
492
|
+
`MongoDbEntityStorageConnector`\<`U`\>
|
|
263
493
|
|
|
264
|
-
|
|
494
|
+
The connector holding the migrated data in a temporary collection.
|
|
495
|
+
|
|
496
|
+
##### options?
|
|
497
|
+
|
|
498
|
+
`IMigrationOptions`
|
|
499
|
+
|
|
500
|
+
The options to control how the migration is finalized.
|
|
501
|
+
|
|
502
|
+
##### loggingComponentType?
|
|
503
|
+
|
|
504
|
+
`string`
|
|
505
|
+
|
|
506
|
+
The logging component type to use during finalization.
|
|
507
|
+
|
|
508
|
+
#### Returns
|
|
509
|
+
|
|
510
|
+
`Promise`\<`MongoDbEntityStorageConnector`\<`U`\>\>
|
|
511
|
+
|
|
512
|
+
The final connector using the original collection name with the new schema.
|
|
513
|
+
|
|
514
|
+
#### Implementation of
|
|
515
|
+
|
|
516
|
+
`IEntityStorageMigrationConnector.finalizeMigration`
|
|
517
|
+
|
|
518
|
+
***
|
|
519
|
+
|
|
520
|
+
### cleanupMigration() {#cleanupmigration}
|
|
521
|
+
|
|
522
|
+
> **cleanupMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
523
|
+
|
|
524
|
+
Cleanup a failed or aborted migration by dropping the temporary migration collection.
|
|
525
|
+
|
|
526
|
+
#### Type Parameters
|
|
527
|
+
|
|
528
|
+
##### U
|
|
529
|
+
|
|
530
|
+
`U`
|
|
531
|
+
|
|
532
|
+
#### Parameters
|
|
533
|
+
|
|
534
|
+
##### targetConnector
|
|
535
|
+
|
|
536
|
+
`IEntityStorageConnector`\<`U`\> \| `undefined`
|
|
537
|
+
|
|
538
|
+
The target connector to cleanup.
|
|
539
|
+
|
|
540
|
+
##### options?
|
|
541
|
+
|
|
542
|
+
`IMigrationOptions`
|
|
543
|
+
|
|
544
|
+
The options to control how the migration is cleaned up.
|
|
545
|
+
|
|
546
|
+
##### loggingComponentType?
|
|
547
|
+
|
|
548
|
+
`string`
|
|
549
|
+
|
|
550
|
+
The optional component type to use for logging.
|
|
265
551
|
|
|
266
552
|
#### Returns
|
|
267
553
|
|
|
268
554
|
`Promise`\<`void`\>
|
|
269
555
|
|
|
270
|
-
|
|
556
|
+
A promise that resolves when the cleanup is complete.
|
|
557
|
+
|
|
558
|
+
#### Implementation of
|
|
559
|
+
|
|
560
|
+
`IEntityStorageMigrationConnector.cleanupMigration`
|
package/locales/en.json
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
"mongoDbEntityStorageConnector": {
|
|
4
4
|
"databaseCreating": "Database \"{databaseName}\" creating",
|
|
5
5
|
"databaseExists": "Database \"{databaseName}\" created or it already exists",
|
|
6
|
-
"collectionExists": "Database \"{collectionName}\" created or it already exists"
|
|
6
|
+
"collectionExists": "Database \"{collectionName}\" created or it already exists",
|
|
7
|
+
"collectionDropping": "Dropping collection \"{collection}\"",
|
|
8
|
+
"collectionDropped": "Collection \"{collection}\" dropped"
|
|
7
9
|
}
|
|
8
10
|
},
|
|
9
11
|
"error": {
|
|
@@ -12,7 +14,20 @@
|
|
|
12
14
|
"getFailed": "Unable to get entity \"{id}\"",
|
|
13
15
|
"removeFailed": "Unable to remove entity \"{id}\"",
|
|
14
16
|
"databaseCreateFailed": "The database creation failed for \"{databaseName}\"",
|
|
15
|
-
"unsupportedComparisonOperator": "Comparison operator \"{comparison}\" is not supported"
|
|
17
|
+
"unsupportedComparisonOperator": "Comparison operator \"{comparison}\" is not supported",
|
|
18
|
+
"setBatchFailed": "Unable to set batch of entities",
|
|
19
|
+
"removeBatchFailed": "Unable to remove batch of entities",
|
|
20
|
+
"emptyFailed": "Unable to empty entity storage",
|
|
21
|
+
"countFailed": "Unable to count entities",
|
|
22
|
+
"teardownFailed": "Unable to teardown entity storage",
|
|
23
|
+
"getPartitionContextIdsFailed": "Unable to get partition context ids",
|
|
24
|
+
"finalizeMigrationFailedBootstrap": "Finalizing migration failed during bootstrap phase"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"health": {
|
|
28
|
+
"mongoDbEntityStorageConnector": {
|
|
29
|
+
"healthDescription": "Checks if the MongoDB collection \"{collection}\" in database \"{database}\" is available",
|
|
30
|
+
"connectionFailed": "Failed to connect to MongoDB collection \"{collection}\" in database \"{database}\""
|
|
16
31
|
}
|
|
17
32
|
}
|
|
18
33
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity-storage-connector-mongodb",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "MongoDB connector for flexible document-oriented persistence.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-entity-storage.git",
|
|
8
8
|
"directory": "packages/entity-storage-connector-mongodb"
|
|
9
9
|
},
|
|
10
10
|
"author": "adrian.sanchez.sequeira@iota.org",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/context": "
|
|
18
|
-
"@twin.org/core": "
|
|
19
|
-
"@twin.org/entity": "
|
|
20
|
-
"@twin.org/entity-storage-models": "0.0
|
|
21
|
-
"@twin.org/logging-models": "
|
|
22
|
-
"@twin.org/nameof": "
|
|
23
|
-
"mongodb": "7.
|
|
17
|
+
"@twin.org/context": "^0.9.0",
|
|
18
|
+
"@twin.org/core": "^0.9.0",
|
|
19
|
+
"@twin.org/entity": "^0.9.0",
|
|
20
|
+
"@twin.org/entity-storage-models": "^0.9.0",
|
|
21
|
+
"@twin.org/logging-models": "^0.9.0",
|
|
22
|
+
"@twin.org/nameof": "^0.9.0",
|
|
23
|
+
"mongodb": "7.3.0"
|
|
24
24
|
},
|
|
25
25
|
"main": "./dist/es/index.js",
|
|
26
26
|
"types": "./dist/types/index.d.ts",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"integration"
|
|
55
55
|
],
|
|
56
56
|
"bugs": {
|
|
57
|
-
"url": "git+https://github.com/
|
|
57
|
+
"url": "git+https://github.com/iotaledger/twin-entity-storage/issues"
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://twindev.org"
|
|
60
60
|
}
|