mythix-orm-sql-base 1.6.2 → 1.7.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.
|
@@ -315,7 +315,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
315
315
|
Object.assign({}, _options || {}, { skipPersisted: true, isInsertOperation: true }),
|
|
316
316
|
// Before model operation handler
|
|
317
317
|
async (Model, models, options) => {
|
|
318
|
-
await this.runSaveHooks(Model, models, 'onBeforeCreate', 'onBeforeSave',
|
|
318
|
+
await this.runSaveHooks(Model, models, 'onBeforeCreate', 'onBeforeSave', options);
|
|
319
319
|
},
|
|
320
320
|
// Operation handler
|
|
321
321
|
async (Model, preparedModels, options, queryGenerator) => {
|
|
@@ -326,7 +326,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
326
326
|
},
|
|
327
327
|
// After model operation handler
|
|
328
328
|
async (Model, models, options) => {
|
|
329
|
-
await this.runSaveHooks(Model, models, 'onAfterCreate', 'onAfterSave',
|
|
329
|
+
await this.runSaveHooks(Model, models, 'onAfterCreate', 'onAfterSave', options);
|
|
330
330
|
},
|
|
331
331
|
// After all operations handler
|
|
332
332
|
async (PrimaryModel, dirtyModels, options, queryGenerator) => {
|
|
@@ -359,14 +359,14 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
359
359
|
Object.assign({}, options || {}, { isUpdateOperation: true }),
|
|
360
360
|
// Before model operation handler
|
|
361
361
|
async (Model, models, options) => {
|
|
362
|
-
await this.runSaveHooks(Model, models, 'onBeforeUpdate', 'onBeforeSave',
|
|
362
|
+
await this.runSaveHooks(Model, models, 'onBeforeUpdate', 'onBeforeSave', options);
|
|
363
363
|
},
|
|
364
364
|
// Operation handler
|
|
365
365
|
async (Model, preparedModels, options, queryGenerator) => {
|
|
366
366
|
let models = preparedModels.models;
|
|
367
367
|
for (let i = 0, il = models.length; i < il; i++) {
|
|
368
368
|
let model = models[i];
|
|
369
|
-
let query = Model.where;
|
|
369
|
+
let query = Model.where(this);
|
|
370
370
|
|
|
371
371
|
let pkFieldValue = model[primaryKeyFieldName];
|
|
372
372
|
if (!pkFieldValue)
|
|
@@ -384,7 +384,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
384
384
|
},
|
|
385
385
|
// After model operation handler
|
|
386
386
|
async (Model, models, options) => {
|
|
387
|
-
await this.runSaveHooks(Model, models, 'onAfterUpdate', 'onAfterSave',
|
|
387
|
+
await this.runSaveHooks(Model, models, 'onAfterUpdate', 'onAfterSave', options);
|
|
388
388
|
},
|
|
389
389
|
);
|
|
390
390
|
}
|
|
@@ -414,7 +414,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
414
414
|
let options = _options || {};
|
|
415
415
|
if (_models == null) {
|
|
416
416
|
let queryGenerator = this.getQueryGenerator();
|
|
417
|
-
let sqlStr = queryGenerator.generateDeleteStatement(Model, Model.where.unscoped(), options);
|
|
417
|
+
let sqlStr = queryGenerator.generateDeleteStatement(Model, Model.where(this).unscoped(), options);
|
|
418
418
|
|
|
419
419
|
return await this.query(sqlStr, options);
|
|
420
420
|
}
|
|
@@ -450,7 +450,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
450
450
|
if (Nife.isEmpty(pkIDs))
|
|
451
451
|
return;
|
|
452
452
|
|
|
453
|
-
let sqlStr = queryGenerator.generateDeleteStatement(Model, Model.where.id.EQ(pkIDs));
|
|
453
|
+
let sqlStr = queryGenerator.generateDeleteStatement(Model, Model.where(this).id.EQ(pkIDs));
|
|
454
454
|
if (!sqlStr)
|
|
455
455
|
return;
|
|
456
456
|
|
|
@@ -491,7 +491,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
491
491
|
throw new TypeError(`${this.constructor.name}::select: First argument must be a model class or a query.`);
|
|
492
492
|
|
|
493
493
|
if (!QueryEngine.isQuery(queryEngine)) {
|
|
494
|
-
if (
|
|
494
|
+
if ('where' in queryEngine)
|
|
495
495
|
queryEngine = queryEngine.where(this);
|
|
496
496
|
else
|
|
497
497
|
throw new TypeError(`${this.constructor.name}::select: First argument must be a model class or a query.`);
|
|
@@ -649,7 +649,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
649
649
|
throw new TypeError(`${this.constructor.name}::pluck: First argument must be a model class or a query.`);
|
|
650
650
|
|
|
651
651
|
if (!QueryEngine.isQuery(queryEngine)) {
|
|
652
|
-
if (
|
|
652
|
+
if ('where' in queryEngine)
|
|
653
653
|
queryEngine = queryEngine.where(this);
|
|
654
654
|
else
|
|
655
655
|
throw new TypeError(`${this.constructor.name}::pluck: First argument must be a model class or a query.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mythix-orm-sql-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "SQL base support for Mythix ORM",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/th317erd/mythix-orm-sql-base#readme",
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"mythix-orm": "^1.
|
|
36
|
+
"mythix-orm": "^1.8.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"luxon": "^3.0.4",
|