mythix-orm 1.13.3 → 1.14.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.
|
@@ -74,8 +74,6 @@ declare class ConnectionBase extends EventEmitter {
|
|
|
74
74
|
public constructor(options?: ConnectionBaseOptions);
|
|
75
75
|
public getLockMode(options: string | LockModeOptions): LockMode;
|
|
76
76
|
public getDefaultOrder(Model: ModelClass, options?: GenericObject): Array<string>;
|
|
77
|
-
public isLimitSupportedInContext(options?: GenericObject): boolean;
|
|
78
|
-
public isOrderSupportedInContext(options?: GenericObject): boolean | string;
|
|
79
77
|
public _getFromModelCache(Model: ModelClass, key: string, defaultValue?: any): any;
|
|
80
78
|
public _setToModelCache<T>(Model: ModelClass, key: string, value: T): T;
|
|
81
79
|
public getOptions(): ConnectionBaseOptions;
|
|
@@ -402,46 +402,6 @@ class ConnectionBase extends EventEmitter {
|
|
|
402
402
|
getDefaultOrder(Model, options) {
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
/// This method is called (and often provided)
|
|
406
|
-
/// by the underlying database driver to see
|
|
407
|
-
/// if a `LIMIT` clause is allowed to appear in
|
|
408
|
-
/// a given context/operation.
|
|
409
|
-
///
|
|
410
|
-
/// Arguments:
|
|
411
|
-
/// options: object
|
|
412
|
-
/// Driver specific options for the context.
|
|
413
|
-
///
|
|
414
|
-
/// Return: boolean
|
|
415
|
-
isLimitSupportedInContext(options) {
|
|
416
|
-
return true;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/// This method is called (and often provided)
|
|
420
|
-
/// by the underlying database driver to see
|
|
421
|
-
/// if an `ORDER BY` clause is allowed to appear in
|
|
422
|
-
/// a given context/operation.
|
|
423
|
-
///
|
|
424
|
-
/// Arguments:
|
|
425
|
-
/// options: object
|
|
426
|
-
/// Driver specific options for the context.
|
|
427
|
-
///
|
|
428
|
-
/// Return: boolean
|
|
429
|
-
isOrderSupportedInContext(_options) {
|
|
430
|
-
let options = _options || {};
|
|
431
|
-
if (options.isSubQuery) {
|
|
432
|
-
let subQueryOperator = options.subQueryOperator;
|
|
433
|
-
if (subQueryOperator === 'EXISTS' || subQueryOperator === 'NOT EXISTS')
|
|
434
|
-
return false;
|
|
435
|
-
|
|
436
|
-
if (subQueryOperator === 'ANY' || subQueryOperator === 'ALL')
|
|
437
|
-
return true;
|
|
438
|
-
|
|
439
|
-
return 'PROJECTION_ONLY';
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
405
|
/// A convenience method to get from "model cache".
|
|
446
406
|
///
|
|
447
407
|
/// Model Cache is a simple system to cache
|
|
@@ -2640,12 +2600,7 @@ class ConnectionBase extends EventEmitter {
|
|
|
2640
2600
|
/// This allows the caller of an operation such as `insert`, or `update` to
|
|
2641
2601
|
/// request that specific hooks not be called.
|
|
2642
2602
|
async runSaveHooks(Model, models, operationHookName, saveHookName, _options) {
|
|
2643
|
-
const throwError = (error) => {
|
|
2644
|
-
throw error;
|
|
2645
|
-
};
|
|
2646
|
-
|
|
2647
2603
|
let options = _options || {};
|
|
2648
|
-
let promises = [];
|
|
2649
2604
|
let context = { connection: this, Model, options, self: null };
|
|
2650
2605
|
let skipHooks = options.skipHooks;
|
|
2651
2606
|
|
|
@@ -2665,21 +2620,13 @@ class ConnectionBase extends EventEmitter {
|
|
|
2665
2620
|
for (let i = 0, il = models.length; i < il; i++) {
|
|
2666
2621
|
let model = models[i];
|
|
2667
2622
|
let modelContext = { ...context, self: model };
|
|
2623
|
+
let result = (shouldSkipHook(operationHookName)) ? undefined : model[operationHookName](modelContext);
|
|
2668
2624
|
|
|
2669
|
-
|
|
2670
|
-
if (!Nife.instanceOf(promise, 'promise'))
|
|
2671
|
-
promise = Promise.resolve(promise);
|
|
2625
|
+
await result;
|
|
2672
2626
|
|
|
2673
|
-
if (!shouldSkipHook(saveHookName))
|
|
2674
|
-
|
|
2675
|
-
if (!Nife.instanceOf(promise, 'promise'))
|
|
2676
|
-
promise = Promise.resolve(promise);
|
|
2677
|
-
}
|
|
2678
|
-
|
|
2679
|
-
promises.push(promise);
|
|
2627
|
+
if (!shouldSkipHook(saveHookName))
|
|
2628
|
+
await model[saveHookName](modelContext);
|
|
2680
2629
|
}
|
|
2681
|
-
|
|
2682
|
-
await Promise.all(promises);
|
|
2683
2630
|
}
|
|
2684
2631
|
|
|
2685
2632
|
/// Drop a table/bucket from the database.
|
package/lib/model.js
CHANGED
|
@@ -7,6 +7,7 @@ const DefaultHelpers = require('./types/helpers/default-helpers');
|
|
|
7
7
|
const Field = require('./field');
|
|
8
8
|
const AsyncStore = require('./utils/async-store');
|
|
9
9
|
const ModelUtils = require('./utils/model-utils');
|
|
10
|
+
const { LiteralBase } = require('./connection/literals');
|
|
10
11
|
|
|
11
12
|
/// Used as a unique key for cache.
|
|
12
13
|
/// Caches will generally be stored in
|
|
@@ -2188,6 +2189,9 @@ class Model {
|
|
|
2188
2189
|
if (!type)
|
|
2189
2190
|
return value;
|
|
2190
2191
|
|
|
2192
|
+
if (LiteralBase.isLiteral(value))
|
|
2193
|
+
return value;
|
|
2194
|
+
|
|
2191
2195
|
return type.castToType({
|
|
2192
2196
|
connection: this.getConnection(),
|
|
2193
2197
|
Model: this.getModel(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mythix-orm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "ORM for Mythix framework",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"homepage": "https://github.com/th317erd/mythix-orm#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@spothero/eslint-plugin-spothero": "github:spothero/eslint-plugin-spothero",
|
|
37
|
-
"@types/node": "^18.11.
|
|
38
|
-
"better-sqlite3": "^8.0.
|
|
37
|
+
"@types/node": "^18.11.18",
|
|
38
|
+
"better-sqlite3": "^8.0.1",
|
|
39
39
|
"colors": "^1.4.0",
|
|
40
40
|
"diff": "^5.1.0",
|
|
41
|
-
"eslint": "^8.
|
|
41
|
+
"eslint": "^8.31.0",
|
|
42
42
|
"jasmine": "^4.5.0",
|
|
43
43
|
"nyc": "^15.1.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"events": "^3.3.0",
|
|
47
|
-
"inflection": "^2.0.
|
|
48
|
-
"luxon": "^3.1
|
|
47
|
+
"inflection": "^2.0.1",
|
|
48
|
+
"luxon": "^3.2.1",
|
|
49
49
|
"nife": "^1.12.1",
|
|
50
50
|
"uuid": "^9.0.0",
|
|
51
51
|
"xid-js": "^1.0.1"
|