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.
@@ -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
- updateChanges(${name}: ${Name},${name}: ${Name}, fetchingStrategy: ${Name}Strategy): Promise<${Name}Row>;
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 'rdb';
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 'rdb';
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 'rdb';
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
 
@@ -54,6 +54,7 @@ function newResolveTransaction(domain, pool) {
54
54
  caller.visitSqlite();
55
55
  };
56
56
  rdb.aggregateCount = 0;
57
+ rdb.cache = {};
57
58
  domain.rdb = rdb;
58
59
  onSuccess();
59
60
  } catch (e) {
@@ -42,6 +42,7 @@ function newResolveTransaction(domain, pool) {
42
42
  caller.visitMySql();
43
43
  };
44
44
  rdb.aggregateCount = 0;
45
+ rdb.cache = {};
45
46
  domain.rdb = rdb;
46
47
  onSuccess();
47
48
  } catch (e) {
@@ -47,6 +47,7 @@ function newResolveTransaction(domain, pool) {
47
47
  caller.visitSqlite();
48
48
  };
49
49
  rdb.aggregateCount = 0;
50
+ rdb.cache = {};
50
51
  domain.rdb = rdb;
51
52
  onSuccess();
52
53
  } catch (e) {
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
- return patchTableCore.apply(null, arguments);
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) {
@@ -46,6 +46,7 @@ function newResolveTransaction(domain, pool) {
46
46
  caller.visitPg();
47
47
  };
48
48
  rdb.aggregateCount = 0;
49
+ rdb.cache = {};
49
50
  domain.rdb = rdb;
50
51
  onSuccess();
51
52
  } catch (e) {
@@ -53,6 +53,7 @@ function newResolveTransaction(domain, pool) {
53
53
  caller.visitSap();
54
54
  };
55
55
  rdb.aggregateCount = 0;
56
+ rdb.cache = {};
56
57
  domain.rdb = rdb;
57
58
  onSuccess();
58
59
  } catch (e) {
@@ -42,6 +42,7 @@ function newResolveTransaction(domain, pool) {
42
42
  caller.visitSqlite();
43
43
  };
44
44
  rdb.aggregateCount = 0;
45
+ rdb.cache = {};
45
46
  domain.rdb = rdb;
46
47
  onSuccess();
47
48
  } catch (e) {
@@ -0,0 +1,7 @@
1
+ var setSessionSingleton = require('./setSessionSingleton');
2
+
3
+ function clearCache() {
4
+ setSessionSingleton('cache', {});
5
+ }
6
+
7
+ module.exports = clearCache;
@@ -0,0 +1,8 @@
1
+ var getSessionSingleton = require('./getSessionSingleton');
2
+
3
+ function getSessionCache(id) {
4
+ const cache = getSessionSingleton('cache');
5
+ return cache[id];
6
+ }
7
+
8
+ module.exports = getSessionCache;
@@ -1,6 +1,6 @@
1
1
  let newCache = require('./newCache');
2
- let getSessionSingleton = require('./getSessionSingleton');
3
- let setSessionSingleton = require('./setSessionSingleton');
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 = getSessionSingleton(id);
41
+ let cache = getSessionCache(id);
42
42
  if (cache)
43
43
  return cache;
44
44
  cache = _newRowCache(table);
45
- setSessionSingleton(id, cache);
45
+ setSessionCache(id, cache);
46
46
  return cache;
47
47
  }
48
48
 
@@ -1,3 +1,5 @@
1
+ //todo remove ?
2
+ //unused ?
1
3
  var newRowCache = require('../newRowCache');
2
4
 
3
5
  function newExpanderCache(joinRelation) {
@@ -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 getSessionSingleton = require('../getSessionSingleton');
8
- var setSessionSingleton = require('../setSessionSingleton');
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 = getSessionSingleton(key);
28
+ var cache = getSessionCache(key);
29
29
  if (!cache) {
30
30
  cache = newCacheCore(joinRelation);
31
- setSessionSingleton(key, cache);
31
+ setSessionCache(key, cache);
32
32
  fillCache();
33
33
  synchronizeAdded(c.tryAdd, joinRelation);
34
34
  synchronizeRemoved(c.tryRemove, joinRelation);
@@ -0,0 +1,8 @@
1
+ var getSessionSingleton = require('./getSessionSingleton');
2
+
3
+ function setSessionCache(id, value) {
4
+ const cache = getSessionSingleton('cache');
5
+ cache[id] = value;
6
+ }
7
+
8
+ module.exports = setSessionCache;
@@ -57,6 +57,7 @@ function newResolveTransaction(domain, pool) {
57
57
  caller.visitSqlite();
58
58
  };
59
59
  rdb.aggregateCount = 0;
60
+ rdb.cache = {};
60
61
  domain.rdb = rdb;
61
62
  onSuccess();
62
63
  } catch (e) {
Binary file