couchdb-web-node-plugin 2.0.830 → 2.0.832
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/databaseHelper.js +1 -1
- package/helper.js +1 -1
- package/index.js +1 -1
- package/package.json +13 -6
- package/readme.md +30 -0
- package/type.d.ts +21 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "couchdb-web-node-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.832",
|
|
4
4
|
"description": "A couchdb server, model instance conflict handler, rest api, authentication, session management, schema validator and model relation guarantee for webNode.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"@types/webpack-env": "^1.18.8",
|
|
83
83
|
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
84
84
|
"@typescript-eslint/parser": "^8.57.2",
|
|
85
|
-
"clientnode": "^4.0.
|
|
85
|
+
"clientnode": "^4.0.1369",
|
|
86
86
|
"documentation-website": "^1.0.401",
|
|
87
87
|
"eslint": "^10.1.0",
|
|
88
88
|
"eslint-config-google": "^0.14.0",
|
|
89
|
-
"eslint-plugin-jsdoc": "^62.8.
|
|
89
|
+
"eslint-plugin-jsdoc": "^62.8.1",
|
|
90
90
|
"express": "^5.2.1",
|
|
91
91
|
"express-pouchdb": "^4.2.0",
|
|
92
92
|
"jest": "^30.3.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"rimraf": "^6.1.3",
|
|
98
98
|
"typescript-eslint": "^8.57.2",
|
|
99
99
|
"web-node": "^1.0.577",
|
|
100
|
-
"weboptimizer": "^3.0.
|
|
100
|
+
"weboptimizer": "^3.0.16"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"@babel/runtime": "*",
|
|
@@ -258,7 +258,7 @@
|
|
|
258
258
|
"since": "now",
|
|
259
259
|
"timeout": false
|
|
260
260
|
},
|
|
261
|
-
"
|
|
261
|
+
"updateForeignKeysChangesStream": {
|
|
262
262
|
"include_docs": true,
|
|
263
263
|
"live": true,
|
|
264
264
|
"return_docs": false,
|
|
@@ -266,6 +266,14 @@
|
|
|
266
266
|
"style": "all_docs",
|
|
267
267
|
"timeout": false
|
|
268
268
|
},
|
|
269
|
+
"removeDanglingForeignKeysChangesStream": {
|
|
270
|
+
"include_docs": false,
|
|
271
|
+
"live": true,
|
|
272
|
+
"return_docs": false,
|
|
273
|
+
"since": "now",
|
|
274
|
+
"style": "all_docs",
|
|
275
|
+
"timeout": false
|
|
276
|
+
},
|
|
269
277
|
"updateMaterializedViewsChangesStream": {
|
|
270
278
|
"include_docs": true,
|
|
271
279
|
"live": true,
|
|
@@ -298,7 +306,6 @@
|
|
|
298
306
|
"createGenericFlatIndex": true,
|
|
299
307
|
"databaseName": "main",
|
|
300
308
|
"debug": false,
|
|
301
|
-
"removeDanglingForeignKeys": false,
|
|
302
309
|
"ensureAdminPresence": true,
|
|
303
310
|
"ensureSecuritySettingsPresence": true,
|
|
304
311
|
"ensureUserPresence": true,
|
package/readme.md
CHANGED
|
@@ -33,3 +33,33 @@ Use case
|
|
|
33
33
|
|
|
34
34
|
PouchDB with model specification/checking, user authentication and right
|
|
35
35
|
management as web-node plugin.
|
|
36
|
+
|
|
37
|
+
Foreign Key management
|
|
38
|
+
----------------------
|
|
39
|
+
|
|
40
|
+
The plugin provides a foreign key management for PouchDB. It allows to define
|
|
41
|
+
foreign keys in the model specification and automatically checks the existence
|
|
42
|
+
of the referenced documents when creating or updating documents. It also
|
|
43
|
+
provides a way to automatically delete or update the referenced documents when
|
|
44
|
+
the referencing document is deleted or updated.
|
|
45
|
+
|
|
46
|
+
### Mechanism
|
|
47
|
+
|
|
48
|
+
#### Initialization
|
|
49
|
+
|
|
50
|
+
During application start the plugin analyzes the model specification and
|
|
51
|
+
creates a map of model types to properties that are defined as foreign keys and
|
|
52
|
+
which model type they reference.
|
|
53
|
+
|
|
54
|
+
It than goes through all documents having referencing properties and checks if
|
|
55
|
+
the referenced documents exist. If not, it deletes the reference and if yes, it
|
|
56
|
+
stores the reference in an internal map of referenced documents to referencing
|
|
57
|
+
documents.
|
|
58
|
+
|
|
59
|
+
#### Document creation and update
|
|
60
|
+
|
|
61
|
+
When creating or updating a document, the plugin checks if the document has
|
|
62
|
+
referencing properties. If yes, it checks if the referenced documents exist. If
|
|
63
|
+
not, it deletes the reference and if yes, it stores the reference in the
|
|
64
|
+
internal map of referenced documents to referencing documents. It also removes
|
|
65
|
+
references from the internal map if they are no longer present.
|
package/type.d.ts
CHANGED
|
@@ -38,6 +38,9 @@ export type DatabaseFetch = PouchDB.Core.Options['fetch'];
|
|
|
38
38
|
export type DatabaseResponse = PouchDB.Core.Response;
|
|
39
39
|
export type Document<Type extends object = PlainObject> = PouchDB.Core.Document<Type>;
|
|
40
40
|
export type ExistingDocument<Type extends object = PlainObject> = PouchDB.Core.ExistingDocument<Type>;
|
|
41
|
+
export type DocumentDeleteMeta = PouchDB.Core.IdMeta & {
|
|
42
|
+
_deleted: boolean;
|
|
43
|
+
};
|
|
41
44
|
export type DocumentGetMeta = PouchDB.Core.GetMeta;
|
|
42
45
|
export type DocumentIDMeta = PouchDB.Core.IdMeta;
|
|
43
46
|
export type DocumentRevisionIDMeta = PouchDB.Core.RevisionIdMeta;
|
|
@@ -292,6 +295,7 @@ export interface CoreConfiguration<Type extends object = Mapping<unknown>, Attac
|
|
|
292
295
|
};
|
|
293
296
|
numberOfParallelChangesRunner: number;
|
|
294
297
|
removeDanglingForeignKeysChangesStream: ChangesStreamOptions;
|
|
298
|
+
updateForeignKeysChangesStream: ChangesStreamOptions;
|
|
295
299
|
updateMaterializedViewsChangesStream: ChangesStreamOptions;
|
|
296
300
|
connector: ConnectorConfiguration;
|
|
297
301
|
security: {
|
|
@@ -299,7 +303,6 @@ export interface CoreConfiguration<Type extends object = Mapping<unknown>, Attac
|
|
|
299
303
|
_users: SecuritySettings;
|
|
300
304
|
[key: string]: SecuritySettings;
|
|
301
305
|
};
|
|
302
|
-
removeDanglingForeignKeys: boolean;
|
|
303
306
|
createGenericFlatIndex: boolean;
|
|
304
307
|
databaseName: string;
|
|
305
308
|
debug: boolean;
|
|
@@ -333,14 +336,31 @@ export interface CoreConfiguration<Type extends object = Mapping<unknown>, Attac
|
|
|
333
336
|
export type Configuration<ConfigurationType = Mapping<unknown>> = BaseConfiguration<{
|
|
334
337
|
couchdb: CoreConfiguration;
|
|
335
338
|
}> & ConfigurationType;
|
|
339
|
+
export interface StaticForeignKey {
|
|
340
|
+
propertySelector: Array<string>;
|
|
341
|
+
targetModelName: string;
|
|
342
|
+
}
|
|
343
|
+
export type StaticForeignKeys = Array<StaticForeignKey>;
|
|
344
|
+
export interface RuntimeForeignKey {
|
|
345
|
+
propertySelector: Array<string>;
|
|
346
|
+
id: string;
|
|
347
|
+
}
|
|
348
|
+
export type RuntimeForeignKeys = Array<RuntimeForeignKey>;
|
|
336
349
|
export interface CouchDB<Type extends object = Mapping<unknown>> {
|
|
337
350
|
changesStream: ChangesStream;
|
|
338
351
|
lastChangesSequenceIdentifier?: number | string;
|
|
339
352
|
reinitializeMaterializedViews?: () => Promise<void>;
|
|
353
|
+
foreignKeys: {
|
|
354
|
+
static: Mapping<StaticForeignKeys>;
|
|
355
|
+
runtime: Mapping<RuntimeForeignKeys>;
|
|
356
|
+
};
|
|
357
|
+
removeDanglingForeignKeys?: () => Promise<void>;
|
|
340
358
|
updateMaterializedViewsChangesStream?: ChangesStream;
|
|
341
359
|
lastUpdateMaterializedViewsChangesSequenceIdentifier?: number | string;
|
|
342
360
|
removeDanglingForeignKeysChangesStream?: ChangesStream;
|
|
343
361
|
lastRemoveDanglingForeignKeysChangesSequenceIdentifier?: number | string;
|
|
362
|
+
updateForeignKeysChangesStream?: ChangesStream;
|
|
363
|
+
lastUpdateForeignKeysChangesSequenceIdentifier?: number | string;
|
|
344
364
|
backendConnector: Connector;
|
|
345
365
|
connection: Connection<Type>;
|
|
346
366
|
connector: Connector;
|