orange-orm 3.10.2 → 3.10.4
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 +40 -10
- package/docs/changelog.md +8 -4
- package/docs/diagram.svg +12 -0
- package/package.json +1 -1
- package/src/client/index.mjs +1580 -1016
- package/src/getTSDefinition.js +16 -12
- package/src/mssql/newTransaction.js +1 -0
- package/src/mySql/newTransaction.js +1 -0
- package/src/oracle/newTransaction.js +1 -0
- package/src/patchTable.js +4 -1
- package/src/pg/newTransaction.js +1 -0
- package/src/sap/newTransaction.js +1 -0
- package/src/sqlite/newTransaction.js +1 -0
- package/src/table/clearCache.js +7 -0
- package/src/table/getSessionCache.js +8 -0
- package/src/table/newRowCache.js +4 -4
- package/src/table/relation/newExpanderCache.js +2 -0
- package/src/table/relation/newManyCache.js +4 -4
- package/src/table/setSessionCache.js +8 -0
- package/src/tedious/newTransaction.js +1 -0
- package/docs/relations.png +0 -0
package/src/getTSDefinition.js
CHANGED
|
@@ -53,14 +53,17 @@ export interface ${Name}Table {
|
|
|
53
53
|
getOne(${name}: ${Name}, fetchingStrategy: ${Name}Strategy): Promise<${Name}Row>;
|
|
54
54
|
getById(${getIdArgs(table)}): Promise<${Name}Row>;
|
|
55
55
|
getById(${getIdArgs(table)}, fetchingStrategy: ${Name}Strategy): Promise<${Name}Row>;
|
|
56
|
+
|
|
56
57
|
update(${name}s: ${Name}[]): Promise<${Name}Array>;
|
|
57
|
-
updateChanges(${name}s: ${Name}[], old${name}s: ${Name}[]): Promise<${Name}Array>;
|
|
58
58
|
update(${name}s: ${Name}[], fetchingStrategy: ${Name}Strategy): Promise<${Name}Array>;
|
|
59
|
-
updateChanges(${name}s: ${Name}[],old${name}s: ${Name}[], fetchingStrategy: ${Name}Strategy): Promise<${Name}Array>;
|
|
60
59
|
update(${name}: ${Name}): Promise<${Name}Row>;
|
|
61
|
-
updateChanges(${name}: ${Name}, old${name}: ${Name}): Promise<${Name}Row>;
|
|
62
60
|
update(${name}: ${Name}, fetchingStrategy: ${Name}Strategy): Promise<${Name}Row>;
|
|
63
|
-
|
|
61
|
+
|
|
62
|
+
updateChanges(${name}s: ${Name}[], old${name}s: ${Name}[]): Promise<${Name}Array>;
|
|
63
|
+
updateChanges(${name}s: ${Name}[],old${name}s: ${Name}[], fetchingStrategy: ${Name}Strategy): Promise<${Name}Array>;
|
|
64
|
+
updateChanges(${name}: ${Name}, old${name}: ${Name}): Promise<${Name}Row>;
|
|
65
|
+
updateChanges(${name}: ${Name},old${name}: ${Name}, fetchingStrategy: ${Name}Strategy): Promise<${Name}Row>;
|
|
66
|
+
|
|
64
67
|
insert(${name}s: ${Name}[]): Promise<${Name}Array>;
|
|
65
68
|
insert(${name}s: ${Name}[], fetchingStrategy: ${Name}Strategy): Promise<${Name}Array>;
|
|
66
69
|
insert(${name}: ${Name}): Promise<${Name}Row>;
|
|
@@ -82,11 +85,6 @@ export interface ${Name}Table {
|
|
|
82
85
|
${_tableRelations}
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
export interface ${Name}TableBase {
|
|
86
|
-
${_columns}
|
|
87
|
-
${_tableRelations}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
88
|
export interface ${Name}ExpressConfig {
|
|
91
89
|
baseFilter?: RawFilter | ((context: ExpressContext) => RawFilter | Promise<RawFilter>);
|
|
92
90
|
customFilters?: Record<string, (context: ExpressContext,...args: any[]) => RawFilter | Promise<RawFilter>>;
|
|
@@ -224,6 +222,12 @@ export interface ${name} {
|
|
|
224
222
|
${regularRelations}
|
|
225
223
|
}
|
|
226
224
|
|
|
225
|
+
export interface ${name}TableBase {
|
|
226
|
+
${columns(table)}
|
|
227
|
+
${tableRelations(table)}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
227
231
|
export interface ${name}Strategy {
|
|
228
232
|
${strategyColumns(table)}
|
|
229
233
|
${strategyRelations}
|
|
@@ -350,9 +354,9 @@ function getPrefixTs(isNamespace) {
|
|
|
350
354
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
351
355
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
352
356
|
import type { AxiosInterceptorManager, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
|
353
|
-
import type { BooleanColumn, JSONColumn, UUIDColumn, DateColumn, NumberColumn, BinaryColumn, StringColumn, Concurrency, Filter, RawFilter, TransactionOptions, Pool, Express, Url, ColumnConcurrency, JsonPatch } from '
|
|
357
|
+
import type { BooleanColumn, JSONColumn, UUIDColumn, DateColumn, NumberColumn, BinaryColumn, StringColumn, Concurrency, Filter, RawFilter, TransactionOptions, Pool, Express, Url, ColumnConcurrency, JsonPatch } from 'orange-orm';
|
|
354
358
|
export { RequestHandler } from 'express';
|
|
355
|
-
export { Concurrency, Filter, RawFilter, Config, TransactionOptions, Pool } from '
|
|
359
|
+
export { Concurrency, Filter, RawFilter, Config, TransactionOptions, Pool } from 'orange-orm';
|
|
356
360
|
export = r;
|
|
357
361
|
declare function r(config: Config): r.RdbClient;
|
|
358
362
|
`;
|
|
@@ -363,7 +367,7 @@ declare function r(config: Config): r.RdbClient;
|
|
|
363
367
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
364
368
|
import schema from './schema';
|
|
365
369
|
import type { AxiosInterceptorManager, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
|
366
|
-
import type { BooleanColumn, JSONColumn, UUIDColumn, DateColumn, NumberColumn, BinaryColumn, StringColumn, Concurrency, Filter, RawFilter, TransactionOptions, Pool, Express, Url, ColumnConcurrency, JsonPatch } from '
|
|
370
|
+
import type { BooleanColumn, JSONColumn, UUIDColumn, DateColumn, NumberColumn, BinaryColumn, StringColumn, Concurrency, Filter, RawFilter, TransactionOptions, Pool, Express, Url, ColumnConcurrency, JsonPatch } from 'orange-orm';
|
|
367
371
|
export default schema as RdbClient;`;
|
|
368
372
|
}
|
|
369
373
|
|
package/src/patchTable.js
CHANGED
|
@@ -3,13 +3,16 @@ let applyPatch = require('./applyPatch');
|
|
|
3
3
|
let fromCompareObject = require('./fromCompareObject');
|
|
4
4
|
let validateDeleteConflict = require('./validateDeleteConflict');
|
|
5
5
|
let validateDeleteAllowed = require('./validateDeleteAllowed');
|
|
6
|
+
let clearCache = require('./table/clearCache');
|
|
6
7
|
|
|
7
8
|
async function patchTable() {
|
|
8
9
|
// const dryrun = true;
|
|
9
10
|
//traverse all rows you want to update before updatinng or inserting anything.
|
|
10
11
|
//this is to avoid page locks in ms sql
|
|
11
12
|
// await patchTableCore.apply(null, [...arguments, dryrun]);
|
|
12
|
-
|
|
13
|
+
const result = await patchTableCore.apply(null, arguments);
|
|
14
|
+
clearCache();
|
|
15
|
+
return result;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
async function patchTableCore(table, patches, { strategy = undefined, deduceStrategy = false, ...options } = {}, dryrun) {
|
package/src/pg/newTransaction.js
CHANGED
package/src/table/newRowCache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
let newCache = require('./newCache');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let getSessionCache = require('./getSessionCache');
|
|
3
|
+
let setSessionCache = require('./setSessionCache');
|
|
4
4
|
|
|
5
5
|
function newRowCache(table) {
|
|
6
6
|
let id = Symbol();
|
|
@@ -38,11 +38,11 @@ function newRowCache(table) {
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
function getCache(table, id) {
|
|
41
|
-
let cache =
|
|
41
|
+
let cache = getSessionCache(id);
|
|
42
42
|
if (cache)
|
|
43
43
|
return cache;
|
|
44
44
|
cache = _newRowCache(table);
|
|
45
|
-
|
|
45
|
+
setSessionCache(id, cache);
|
|
46
46
|
return cache;
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -4,8 +4,8 @@ var synchronizeRemoved = require('./manyCache/synchronizeRemoved');
|
|
|
4
4
|
var extractParentKey = require('./manyCache/extractParentKey');
|
|
5
5
|
var newCacheCore = require('./newManyCacheCore');
|
|
6
6
|
var newId = require('../../newId');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var getSessionCache = require('../getSessionCache');
|
|
8
|
+
var setSessionCache = require('../setSessionCache');
|
|
9
9
|
|
|
10
10
|
function newManyCache(joinRelation) {
|
|
11
11
|
var c = {};
|
|
@@ -25,10 +25,10 @@ function newManyCache(joinRelation) {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
c.getInnerCache = function() {
|
|
28
|
-
var cache =
|
|
28
|
+
var cache = getSessionCache(key);
|
|
29
29
|
if (!cache) {
|
|
30
30
|
cache = newCacheCore(joinRelation);
|
|
31
|
-
|
|
31
|
+
setSessionCache(key, cache);
|
|
32
32
|
fillCache();
|
|
33
33
|
synchronizeAdded(c.tryAdd, joinRelation);
|
|
34
34
|
synchronizeRemoved(c.tryRemove, joinRelation);
|
package/docs/relations.png
DELETED
|
Binary file
|