couchdb-web-node-plugin 2.0.831 → 2.0.833
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 +16 -9
- package/readme.md +30 -0
- package/type.d.ts +18 -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.833",
|
|
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",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"@types/pouchdb-adapter-memory": "^6.1.6",
|
|
81
81
|
"@types/pouchdb-node": "^6.1.7",
|
|
82
82
|
"@types/webpack-env": "^1.18.8",
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
84
|
-
"@typescript-eslint/parser": "^8.
|
|
85
|
-
"clientnode": "^4.0.
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
|
84
|
+
"@typescript-eslint/parser": "^8.58.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",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
"node-fetch": "^3.3.2",
|
|
96
96
|
"pouchdb-adapter-memory": "^9.0.0",
|
|
97
97
|
"rimraf": "^6.1.3",
|
|
98
|
-
"typescript-eslint": "^8.
|
|
98
|
+
"typescript-eslint": "^8.58.0",
|
|
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,8 +258,16 @@
|
|
|
258
258
|
"since": "now",
|
|
259
259
|
"timeout": false
|
|
260
260
|
},
|
|
261
|
+
"updateForeignKeysChangesStream": {
|
|
262
|
+
"include_docs": false,
|
|
263
|
+
"live": true,
|
|
264
|
+
"return_docs": false,
|
|
265
|
+
"since": "now",
|
|
266
|
+
"style": "all_docs",
|
|
267
|
+
"timeout": false
|
|
268
|
+
},
|
|
261
269
|
"removeDanglingForeignKeysChangesStream": {
|
|
262
|
-
"include_docs":
|
|
270
|
+
"include_docs": false,
|
|
263
271
|
"live": true,
|
|
264
272
|
"return_docs": false,
|
|
265
273
|
"since": "now",
|
|
@@ -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
|
@@ -295,6 +295,7 @@ export interface CoreConfiguration<Type extends object = Mapping<unknown>, Attac
|
|
|
295
295
|
};
|
|
296
296
|
numberOfParallelChangesRunner: number;
|
|
297
297
|
removeDanglingForeignKeysChangesStream: ChangesStreamOptions;
|
|
298
|
+
updateForeignKeysChangesStream: ChangesStreamOptions;
|
|
298
299
|
updateMaterializedViewsChangesStream: ChangesStreamOptions;
|
|
299
300
|
connector: ConnectorConfiguration;
|
|
300
301
|
security: {
|
|
@@ -302,7 +303,6 @@ export interface CoreConfiguration<Type extends object = Mapping<unknown>, Attac
|
|
|
302
303
|
_users: SecuritySettings;
|
|
303
304
|
[key: string]: SecuritySettings;
|
|
304
305
|
};
|
|
305
|
-
removeDanglingForeignKeys: boolean;
|
|
306
306
|
createGenericFlatIndex: boolean;
|
|
307
307
|
databaseName: string;
|
|
308
308
|
debug: boolean;
|
|
@@ -336,14 +336,31 @@ export interface CoreConfiguration<Type extends object = Mapping<unknown>, Attac
|
|
|
336
336
|
export type Configuration<ConfigurationType = Mapping<unknown>> = BaseConfiguration<{
|
|
337
337
|
couchdb: CoreConfiguration;
|
|
338
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>;
|
|
339
349
|
export interface CouchDB<Type extends object = Mapping<unknown>> {
|
|
340
350
|
changesStream: ChangesStream;
|
|
341
351
|
lastChangesSequenceIdentifier?: number | string;
|
|
342
352
|
reinitializeMaterializedViews?: () => Promise<void>;
|
|
353
|
+
foreignKeys: {
|
|
354
|
+
static: Mapping<StaticForeignKeys>;
|
|
355
|
+
runtime: Mapping<RuntimeForeignKeys>;
|
|
356
|
+
};
|
|
357
|
+
removeDanglingForeignKeys?: () => Promise<void>;
|
|
343
358
|
updateMaterializedViewsChangesStream?: ChangesStream;
|
|
344
359
|
lastUpdateMaterializedViewsChangesSequenceIdentifier?: number | string;
|
|
345
360
|
removeDanglingForeignKeysChangesStream?: ChangesStream;
|
|
346
361
|
lastRemoveDanglingForeignKeysChangesSequenceIdentifier?: number | string;
|
|
362
|
+
updateForeignKeysChangesStream?: ChangesStream;
|
|
363
|
+
lastUpdateForeignKeysChangesSequenceIdentifier?: number | string;
|
|
347
364
|
backendConnector: Connector;
|
|
348
365
|
connection: Connection<Type>;
|
|
349
366
|
connector: Connector;
|