@alpha.consultings/eloquent-orm.js 1.0.9 → 1.0.11
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/CHANGELOG.md +17 -0
- package/PACKAGE-UPDATE-SUMMARY.md +18 -11
- package/README.md +5 -5
- package/dist/Model.d.ts +1 -1
- package/dist/Model.js +3 -3
- package/dist/cli/commands/cacheClear.js +12 -12
- package/dist/cli/commands/cacheStats.js +12 -12
- package/dist/cli/commands/dbSeed.d.ts +1 -1
- package/dist/cli/commands/dbSeed.js +23 -23
- package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/commands/dbSeedBootstrapPrecheck.js +2 -2
- package/dist/cli/commands/dbSeedFresh.d.ts +1 -1
- package/dist/cli/commands/dbSeedFresh.js +10 -10
- package/dist/cli/commands/demoScenario.js +11 -11
- package/dist/cli/commands/factoryStatus.js +13 -13
- package/dist/cli/commands/makeController.js +11 -11
- package/dist/cli/commands/makeFactory.js +21 -21
- package/dist/cli/commands/makeMigration.d.ts +1 -1
- package/dist/cli/commands/makeMigration.js +31 -17
- package/dist/cli/commands/makeModel.js +30 -30
- package/dist/cli/commands/makeRegistry.d.ts +5 -8
- package/dist/cli/commands/makeRegistry.js +18 -68
- package/dist/cli/commands/makeScenario.js +49 -43
- package/dist/cli/commands/makeSeed.js +12 -9
- package/dist/cli/commands/makeService.js +10 -10
- package/dist/cli/commands/migrateFresh.d.ts +1 -1
- package/dist/cli/commands/migrateFresh.js +14 -14
- package/dist/cli/commands/migrateReset.d.ts +1 -1
- package/dist/cli/commands/migrateReset.js +4 -4
- package/dist/cli/commands/migrateRollback.d.ts +1 -1
- package/dist/cli/commands/migrateRollback.js +36 -36
- package/dist/cli/commands/migrateRun.d.ts +2 -2
- package/dist/cli/commands/migrateRun.js +34 -34
- package/dist/cli/commands/migrateStatus.d.ts +1 -1
- package/dist/cli/commands/migrateStatus.js +16 -16
- package/dist/cli/eloquent.d.ts +1 -1
- package/dist/cli/eloquent.js +30 -30
- package/dist/cli/utils/ArtifactRoutingReport.d.ts +1 -1
- package/dist/cli/utils/ArtifactRoutingReport.js +3 -3
- package/dist/cli/utils/ArtifactStorage.d.ts +2 -2
- package/dist/cli/utils/ArtifactStorage.js +17 -17
- package/dist/cli/utils/AuditTrail.js +2 -2
- package/dist/cli/utils/CliBootstrapSupport.d.ts +1 -1
- package/dist/cli/utils/CliCommandTargets.d.ts +2 -2
- package/dist/cli/utils/CliCommandTargets.js +2 -2
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.js +15 -15
- package/dist/cli/utils/CliMigrationCommandRegistration.js +29 -29
- package/dist/cli/utils/CliProductionGuards.d.ts +1 -1
- package/dist/cli/utils/CliProductionGuards.js +6 -6
- package/dist/cli/utils/CliScaffoldCommandRegistration.js +13 -13
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.js +23 -23
- package/dist/cli/utils/CliSupportCommandRegistration.js +8 -8
- package/dist/cli/utils/ImportResolver.d.ts +12 -3
- package/dist/cli/utils/ImportResolver.js +76 -17
- package/dist/cli/utils/ModelIntrospector.d.ts +1 -1
- package/dist/cli/utils/ModelIntrospector.js +4 -4
- package/dist/cli/utils/ScaffoldGeneratorSupport.js +2 -2
- package/dist/cli/utils/ScenarioMorphAliasRouting.js +8 -8
- package/dist/cli/utils/SeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/utils/SeedBootstrapPrecheck.js +10 -10
- package/dist/cli/utils/TemplateEngine.js +2 -2
- package/dist/cli/utils/factories/Factory.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryDisplay.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryGraph.js +5 -5
- package/dist/cli/utils/factories/FactoryLoader.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryLoader.js +4 -4
- package/dist/cli/utils/factories/FactoryRegistry.d.ts +3 -3
- package/dist/cli/utils/factories/FactoryRegistry.js +10 -10
- package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts +1 -1
- package/dist/cli/utils/migrations/MigrationLockStrategy.js +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.d.ts +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.js +6 -6
- package/dist/cli/utils/migrations/MongoMigrationTracker.js +3 -3
- package/dist/cli/utils/resolveConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/resolveConnectionFlags.js +3 -3
- package/dist/cli/utils/resolveSqlConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.js +3 -3
- package/dist/cli/utils/typescript/tsRuntime.js +62 -9
- package/dist/config/database.js +9 -9
- package/dist/core/cache/CacheFallbackManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.js +2 -2
- package/dist/core/cache/CacheRegistry.js +4 -4
- package/dist/core/cache/drivers/FileCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/FileCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemcachedCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemoryCacheDriver.js +2 -2
- package/dist/core/cache/setupCache.js +12 -12
- package/dist/core/connection/ConnectionFactory.d.ts +2 -2
- package/dist/core/connection/ConnectionFactory.js +9 -9
- package/dist/core/connection/DatabaseConnection.d.ts +2 -2
- package/dist/core/connection/DatabaseConnection.js +4 -4
- package/dist/core/connection/DriverAdapter.d.ts +1 -1
- package/dist/core/connection/DriverAdapter.js +2 -2
- package/dist/core/connection/resolveConnectionName.d.ts +1 -1
- package/dist/core/connection/resolveConnectionName.js +7 -7
- package/dist/core/model/BaseModel.d.ts +29 -29
- package/dist/core/model/BaseModel.js +38 -38
- package/dist/core/model/BaseModelSafeFinderStatics.d.ts +1 -1
- package/dist/core/model/BaseModelSafeFinderStatics.js +19 -19
- package/dist/core/model/CoreModel.d.ts +4 -4
- package/dist/core/model/CoreModel.js +28 -28
- package/dist/core/model/CoreModelPersistenceState.d.ts +1 -1
- package/dist/core/model/CoreModelSafeFinderSupport.d.ts +2 -2
- package/dist/core/model/CoreModelSafeFinderSupport.js +2 -2
- package/dist/core/model/CoreModelValidationEvents.d.ts +2 -2
- package/dist/core/model/CoreModelValidationEvents.js +2 -2
- package/dist/core/model/SafeFinder.d.ts +1 -1
- package/dist/core/model/SafeFinder.js +2 -2
- package/dist/core/orm/mixins/CastsMixin.js +2 -2
- package/dist/core/orm/mixins/HooksMixin.js +8 -8
- package/dist/core/orm/mixins/MorphableMixin.js +4 -4
- package/dist/core/orm/mixins/PivotHelperMixin.js +3 -3
- package/dist/core/orm/mixins/QueryCacheMixin.js +20 -20
- package/dist/core/orm/mixins/ScopeMixin.js +2 -2
- package/dist/core/orm/mixins/SoftDeletesMixin.js +2 -2
- package/dist/core/orm/mixins/utils/HookStore.d.ts +1 -1
- package/dist/core/orm/mixins/utils/HookStore.js +2 -2
- package/dist/core/orm/mixins/utils/modelRegistration.d.ts +1 -1
- package/dist/core/orm/mixins/utils/modelRegistration.js +6 -6
- package/dist/core/orm/relations/BelongsTo.d.ts +1 -1
- package/dist/core/orm/relations/BelongsTo.js +2 -2
- package/dist/core/orm/relations/BelongsToMany.d.ts +1 -1
- package/dist/core/orm/relations/BelongsToMany.js +2 -2
- package/dist/core/orm/relations/HasMany.d.ts +1 -1
- package/dist/core/orm/relations/HasMany.js +2 -2
- package/dist/core/orm/relations/HasOne.d.ts +1 -1
- package/dist/core/orm/relations/HasOne.js +2 -2
- package/dist/core/orm/relations/MorphMany.d.ts +1 -1
- package/dist/core/orm/relations/MorphMany.js +2 -2
- package/dist/core/orm/relations/MorphOne.d.ts +1 -1
- package/dist/core/orm/relations/MorphOne.js +2 -2
- package/dist/core/orm/relations/MorphTo.d.ts +1 -1
- package/dist/core/orm/relations/MorphTo.js +5 -5
- package/dist/core/schema/SchemaBuilder.d.ts +2 -2
- package/dist/core/schema/SchemaBuilder.js +9 -9
- package/dist/core/schema/SchemaValidator.d.ts +1 -1
- package/dist/core/security/AbstractSecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.js +2 -2
- package/dist/core/security/NoSecurity.d.ts +1 -1
- package/dist/core/security/NoSecurity.js +2 -2
- package/dist/core/security/SecurityFactory.d.ts +1 -1
- package/dist/core/security/SecurityFactory.js +4 -4
- package/dist/core/security/index.d.ts +5 -5
- package/dist/core/security/index.js +5 -5
- package/dist/index.d.ts +10 -10
- package/dist/index.js +30 -30
- package/esm/Factory.mjs +113 -136
- package/esm/Model.mjs +4 -0
- package/esm/index.mjs +23 -28
- package/package.json +14 -5
- package/src/cli/templates/factory.tpl +1 -1
- package/src/cli/templates/seed.tpl +1 -1
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoModel = exports.MorphRegistry = exports.MorphableMixin = exports.Model = exports.SqlModel = exports.BaseModel = exports.MODEL_BOUNDARY_MATRIX = exports.BASE_MODEL_COMPOSITION_ORDER = void 0;
|
|
4
4
|
// src/model/BaseModel.ts
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
5
|
+
const CoreModel_js_1 = require("./CoreModel.js");
|
|
6
|
+
const PivotHelperMixin_js_1 = require("../orm/mixins/PivotHelperMixin.js");
|
|
7
|
+
const CastsMixin_js_1 = require("../orm/mixins/CastsMixin.js");
|
|
8
|
+
const SoftDeletesMixin_js_1 = require("../orm/mixins/SoftDeletesMixin.js");
|
|
9
|
+
const ScopeMixin_js_1 = require("../orm/mixins/ScopeMixin.js");
|
|
10
|
+
const HooksMixin_js_1 = require("../orm/mixins/HooksMixin.js");
|
|
11
|
+
const QueryCacheMixin_js_1 = require("../orm/mixins/QueryCacheMixin.js");
|
|
12
|
+
const EagerLoadingMixin_js_1 = require("../orm/mixins/EagerLoadingMixin.js");
|
|
13
|
+
const SerializeMixin_js_1 = require("../orm/mixins/SerializeMixin.js");
|
|
14
|
+
const ConnectionFactory_js_1 = require("../connection/ConnectionFactory.js");
|
|
15
|
+
const database_js_1 = require("../../config/database.js");
|
|
16
|
+
const BelongsTo_js_1 = require("../orm/relations/BelongsTo.js");
|
|
17
|
+
const HasOne_js_1 = require("../orm/relations/HasOne.js");
|
|
18
|
+
const HasMany_js_1 = require("../orm/relations/HasMany.js");
|
|
19
|
+
const BelongsToMany_js_1 = require("../orm/relations/BelongsToMany.js");
|
|
20
|
+
const MorphOne_js_1 = require("../orm/relations/MorphOne.js");
|
|
21
|
+
const MorphMany_js_1 = require("../orm/relations/MorphMany.js");
|
|
22
|
+
const MorphTo_js_1 = require("../orm/relations/MorphTo.js");
|
|
23
|
+
const BaseModelSafeFinderStatics_js_1 = require("./BaseModelSafeFinderStatics.js");
|
|
24
24
|
// Morph system (re-export convenience)
|
|
25
|
-
const
|
|
26
|
-
Object.defineProperty(exports, "MorphableMixin", { enumerable: true, get: function () { return
|
|
27
|
-
const
|
|
28
|
-
Object.defineProperty(exports, "MorphRegistry", { enumerable: true, get: function () { return
|
|
25
|
+
const MorphableMixin_js_1 = require("../orm/mixins/MorphableMixin.js");
|
|
26
|
+
Object.defineProperty(exports, "MorphableMixin", { enumerable: true, get: function () { return MorphableMixin_js_1.MorphableMixin; } });
|
|
27
|
+
const MorphRegistry_js_1 = require("../orm/mixins/MorphRegistry.js");
|
|
28
|
+
Object.defineProperty(exports, "MorphRegistry", { enumerable: true, get: function () { return MorphRegistry_js_1.MorphRegistry; } });
|
|
29
29
|
exports.BASE_MODEL_COMPOSITION_ORDER = [
|
|
30
30
|
"CoreModel",
|
|
31
31
|
"MorphableMixin",
|
|
@@ -68,9 +68,9 @@ exports.MODEL_BOUNDARY_MATRIX = {
|
|
|
68
68
|
* We cast CoreModel to AbstractConstructor<ORMCoreContract> as the composition seed so
|
|
69
69
|
* TypeScript understands the initial shape we're building on top of.
|
|
70
70
|
*/
|
|
71
|
-
const MorphableSeed = (0,
|
|
72
|
-
const ComposedModel = (0,
|
|
73
|
-
const SafeFinderStaticModel = (0,
|
|
71
|
+
const MorphableSeed = (0, MorphableMixin_js_1.MorphableMixin)(CoreModel_js_1.CoreModel);
|
|
72
|
+
const ComposedModel = (0, SerializeMixin_js_1.SerializeMixin)((0, EagerLoadingMixin_js_1.EagerLoadingMixin)((0, QueryCacheMixin_js_1.QueryCacheMixin)((0, HooksMixin_js_1.HooksMixin)((0, ScopeMixin_js_1.ScopeMixin)((0, SoftDeletesMixin_js_1.SoftDeletesMixin)((0, CastsMixin_js_1.CastsMixin)((0, PivotHelperMixin_js_1.PivotHelperMixin)(MorphableSeed))))))));
|
|
73
|
+
const SafeFinderStaticModel = (0, BaseModelSafeFinderStatics_js_1.BaseModelSafeFinderStaticsMixin)(ComposedModel);
|
|
74
74
|
/**
|
|
75
75
|
* BaseModel
|
|
76
76
|
* The central abstract model class your application models should extend.
|
|
@@ -86,7 +86,7 @@ class BaseModel extends SafeFinderStaticModel {
|
|
|
86
86
|
const ctor = this.constructor;
|
|
87
87
|
if (ctor.morphAlias)
|
|
88
88
|
return ctor.morphAlias;
|
|
89
|
-
const entries = Object.entries(
|
|
89
|
+
const entries = Object.entries(MorphRegistry_js_1.MorphRegistry.list());
|
|
90
90
|
const entry = entries.find(([, name]) => name === this.constructor.name);
|
|
91
91
|
return entry ? entry[0] : this.constructor.name;
|
|
92
92
|
}
|
|
@@ -98,7 +98,7 @@ class BaseModel extends SafeFinderStaticModel {
|
|
|
98
98
|
const self = this;
|
|
99
99
|
if (self.morphAlias)
|
|
100
100
|
return self.morphAlias;
|
|
101
|
-
const entries = Object.entries(
|
|
101
|
+
const entries = Object.entries(MorphRegistry_js_1.MorphRegistry.list());
|
|
102
102
|
const entry = entries.find(([, name]) => name === this.name);
|
|
103
103
|
return entry ? entry[0] : this.name;
|
|
104
104
|
}
|
|
@@ -106,25 +106,25 @@ class BaseModel extends SafeFinderStaticModel {
|
|
|
106
106
|
// Typed relation helpers
|
|
107
107
|
// -----------------------------
|
|
108
108
|
belongsTo(RelatedModel, foreignKey, ownerKey = "id", name) {
|
|
109
|
-
return new
|
|
109
|
+
return new BelongsTo_js_1.BelongsTo(RelatedModel, foreignKey, ownerKey, name);
|
|
110
110
|
}
|
|
111
111
|
hasOne(RelatedModel, foreignKey, localKey = "id", name) {
|
|
112
|
-
return new
|
|
112
|
+
return new HasOne_js_1.HasOne(RelatedModel, foreignKey, localKey, name);
|
|
113
113
|
}
|
|
114
114
|
hasMany(RelatedModel, foreignKey, localKey = "id", name) {
|
|
115
|
-
return new
|
|
115
|
+
return new HasMany_js_1.HasMany(RelatedModel, foreignKey, localKey, name);
|
|
116
116
|
}
|
|
117
117
|
belongsToMany(RelatedModel, pivotTable, foreignPivotKey, relatedPivotKey) {
|
|
118
|
-
return new
|
|
118
|
+
return new BelongsToMany_js_1.BelongsToMany(RelatedModel, pivotTable, foreignPivotKey, relatedPivotKey);
|
|
119
119
|
}
|
|
120
120
|
morphOne(RelatedModel, morphName) {
|
|
121
|
-
return new
|
|
121
|
+
return new MorphOne_js_1.MorphOne(RelatedModel, `${morphName}_type`, `${morphName}_id`);
|
|
122
122
|
}
|
|
123
123
|
morphMany(RelatedModel, morphName) {
|
|
124
|
-
return new
|
|
124
|
+
return new MorphMany_js_1.MorphMany(RelatedModel, `${morphName}_type`, `${morphName}_id`);
|
|
125
125
|
}
|
|
126
126
|
morphTo(morphName) {
|
|
127
|
-
return new
|
|
127
|
+
return new MorphTo_js_1.MorphTo(`${morphName}_type`, `${morphName}_id`);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
exports.BaseModel = BaseModel;
|
|
@@ -140,7 +140,7 @@ class SqlModel extends BaseModel {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
async getDB() {
|
|
143
|
-
return await (0,
|
|
143
|
+
return await (0, ConnectionFactory_js_1.getAdapter)(this.connectionName);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
exports.SqlModel = SqlModel;
|
|
@@ -152,13 +152,13 @@ exports.Model = SqlModel;
|
|
|
152
152
|
class MongoModel extends BaseModel {
|
|
153
153
|
constructor(...args) {
|
|
154
154
|
super(...args);
|
|
155
|
-
const driver =
|
|
155
|
+
const driver = database_js_1.dbConfig.connections[this.connectionName]?.driver;
|
|
156
156
|
if (driver !== "mongo") {
|
|
157
157
|
throw new Error(`MongoModel requires a mongo driver connection. Received: ${this.connectionName}`);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
async getDB() {
|
|
161
|
-
return await (0,
|
|
161
|
+
return await (0, ConnectionFactory_js_1.getConnection)(this.connectionName);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
exports.MongoModel = MongoModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SafeFinderDirection, SafeFinderFilters, SafeFinderModelInstance, SafeFinderQuery } from "./SafeFinder";
|
|
1
|
+
import type { SafeFinderDirection, SafeFinderFilters, SafeFinderModelInstance, SafeFinderQuery } from "./SafeFinder.js";
|
|
2
2
|
type AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
|
|
3
3
|
export declare function BaseModelSafeFinderStaticsMixin<TBase extends AbstractConstructor<SafeFinderModelInstance>>(Base: TBase): ((abstract new (...args: any[]) => {
|
|
4
4
|
tableName: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseModelSafeFinderStaticsMixin = BaseModelSafeFinderStaticsMixin;
|
|
4
|
-
const
|
|
4
|
+
const CoreModel_js_1 = require("./CoreModel.js");
|
|
5
5
|
function BaseModelSafeFinderStaticsMixin(Base) {
|
|
6
6
|
class BaseModelSafeFinderStatics extends Base {
|
|
7
7
|
static create(data) {
|
|
@@ -9,7 +9,7 @@ function BaseModelSafeFinderStaticsMixin(Base) {
|
|
|
9
9
|
return instance.create(data);
|
|
10
10
|
}
|
|
11
11
|
static async createMany(rows) {
|
|
12
|
-
return
|
|
12
|
+
return CoreModel_js_1.CoreModel.createMany.call(this, rows);
|
|
13
13
|
}
|
|
14
14
|
static find(id, pk = "id") {
|
|
15
15
|
const instance = new this();
|
|
@@ -20,17 +20,17 @@ function BaseModelSafeFinderStaticsMixin(Base) {
|
|
|
20
20
|
return instance.update(id, data, pk);
|
|
21
21
|
}
|
|
22
22
|
static updateMany(ids, data, pk = "id") {
|
|
23
|
-
return
|
|
23
|
+
return CoreModel_js_1.CoreModel.updateMany.call(this, ids, data, pk);
|
|
24
24
|
}
|
|
25
25
|
static patchMany(rows, pk = "id") {
|
|
26
|
-
return
|
|
26
|
+
return CoreModel_js_1.CoreModel.patchMany.call(this, rows, pk);
|
|
27
27
|
}
|
|
28
28
|
static deleteById(id, pk = "id") {
|
|
29
29
|
const instance = new this();
|
|
30
30
|
return instance.delete(id, pk);
|
|
31
31
|
}
|
|
32
32
|
static deleteMany(ids, pk = "id") {
|
|
33
|
-
return
|
|
33
|
+
return CoreModel_js_1.CoreModel.deleteMany.call(this, ids, pk);
|
|
34
34
|
}
|
|
35
35
|
static restoreById(id, pk = "id") {
|
|
36
36
|
const instance = new this();
|
|
@@ -40,46 +40,46 @@ function BaseModelSafeFinderStaticsMixin(Base) {
|
|
|
40
40
|
return instance.restore(id, pk);
|
|
41
41
|
}
|
|
42
42
|
static restoreMany(ids, pk = "id") {
|
|
43
|
-
return
|
|
43
|
+
return CoreModel_js_1.CoreModel.restoreMany.call(this, ids, pk);
|
|
44
44
|
}
|
|
45
45
|
static where(field, value) {
|
|
46
|
-
return
|
|
46
|
+
return CoreModel_js_1.CoreModel.where.call(this, field, value);
|
|
47
47
|
}
|
|
48
48
|
static with(...relations) {
|
|
49
|
-
return
|
|
49
|
+
return CoreModel_js_1.CoreModel.with.call(this, ...relations);
|
|
50
50
|
}
|
|
51
51
|
static active(...args) {
|
|
52
|
-
return
|
|
52
|
+
return CoreModel_js_1.CoreModel.active.call(this, ...args);
|
|
53
53
|
}
|
|
54
54
|
static inactive(...args) {
|
|
55
|
-
return
|
|
55
|
+
return CoreModel_js_1.CoreModel.inactive.call(this, ...args);
|
|
56
56
|
}
|
|
57
57
|
static published(...args) {
|
|
58
|
-
return
|
|
58
|
+
return CoreModel_js_1.CoreModel.published.call(this, ...args);
|
|
59
59
|
}
|
|
60
60
|
static orderBy(field, direction = "asc") {
|
|
61
|
-
return
|
|
61
|
+
return CoreModel_js_1.CoreModel.orderBy.call(this, field, direction);
|
|
62
62
|
}
|
|
63
63
|
static limit(count) {
|
|
64
|
-
return
|
|
64
|
+
return CoreModel_js_1.CoreModel.limit.call(this, count);
|
|
65
65
|
}
|
|
66
66
|
static get() {
|
|
67
|
-
return
|
|
67
|
+
return CoreModel_js_1.CoreModel.get.call(this);
|
|
68
68
|
}
|
|
69
69
|
static first() {
|
|
70
|
-
return
|
|
70
|
+
return CoreModel_js_1.CoreModel.first.call(this);
|
|
71
71
|
}
|
|
72
72
|
static findBy(field, value) {
|
|
73
|
-
return
|
|
73
|
+
return CoreModel_js_1.CoreModel.findBy.call(this, field, value);
|
|
74
74
|
}
|
|
75
75
|
static findOneBy(field, value) {
|
|
76
|
-
return
|
|
76
|
+
return CoreModel_js_1.CoreModel.findOneBy.call(this, field, value);
|
|
77
77
|
}
|
|
78
78
|
static findAllBy(filters) {
|
|
79
|
-
return
|
|
79
|
+
return CoreModel_js_1.CoreModel.findAllBy.call(this, filters);
|
|
80
80
|
}
|
|
81
81
|
static existsBy(filters) {
|
|
82
|
-
return
|
|
82
|
+
return CoreModel_js_1.CoreModel.existsBy.call(this, filters);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
return BaseModelSafeFinderStatics;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ConnectionName } from "../connection/ConnectionFactory";
|
|
1
|
+
import { ConnectionName } from "../connection/ConnectionFactory.js";
|
|
2
2
|
import type { Db } from "mongodb";
|
|
3
|
-
import type { SchemaValidatorOptions } from "../schema/SchemaValidator";
|
|
4
|
-
import type { SchemaField } from "../schema/SchemaBlueprint";
|
|
5
|
-
import { SafeFinderDirection, SafeFinderFilters, SafeFinderQuery } from "./SafeFinder";
|
|
3
|
+
import type { SchemaValidatorOptions } from "../schema/SchemaValidator.js";
|
|
4
|
+
import type { SchemaField } from "../schema/SchemaBlueprint.js";
|
|
5
|
+
import { SafeFinderDirection, SafeFinderFilters, SafeFinderQuery } from "./SafeFinder.js";
|
|
6
6
|
/**
|
|
7
7
|
* Types for model contract (kept generic)
|
|
8
8
|
*/
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoModel = exports.CoreModel = void 0;
|
|
4
4
|
// src/core/connection/CoreModel.ts
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
5
|
+
const ConnectionFactory_js_1 = require("../connection/ConnectionFactory.js");
|
|
6
|
+
const database_js_1 = require("../../config/database.js");
|
|
7
|
+
const CoreModelPersistenceState_js_1 = require("./CoreModelPersistenceState.js");
|
|
8
|
+
const CoreModelValidationEvents_js_1 = require("./CoreModelValidationEvents.js");
|
|
9
|
+
const CoreModelSafeFinderSupport_js_1 = require("./CoreModelSafeFinderSupport.js");
|
|
10
10
|
/**
|
|
11
11
|
* CoreModel - driver-agnostic CRUD + schema validation + hooks + events
|
|
12
12
|
*/
|
|
@@ -44,7 +44,7 @@ class CoreModel {
|
|
|
44
44
|
}
|
|
45
45
|
static safeFinder() {
|
|
46
46
|
const instance = this.newInstance();
|
|
47
|
-
return (0,
|
|
47
|
+
return (0, CoreModelSafeFinderSupport_js_1.createSafeFinderQuery)(instance, this);
|
|
48
48
|
}
|
|
49
49
|
static where(field, value) {
|
|
50
50
|
return this.safeFinder().where(field, value);
|
|
@@ -148,47 +148,47 @@ class CoreModel {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
static findAllBy(filters) {
|
|
151
|
-
return (0,
|
|
151
|
+
return (0, CoreModelSafeFinderSupport_js_1.applySafeFinderFilters)(this.safeFinder(), filters).get();
|
|
152
152
|
}
|
|
153
153
|
static async existsBy(filters) {
|
|
154
|
-
return (await (0,
|
|
154
|
+
return (await (0, CoreModelSafeFinderSupport_js_1.applySafeFinderFilters)(this.safeFinder(), filters).first()) !== null;
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Get DB connection (lazy + cached)
|
|
158
158
|
*/
|
|
159
159
|
async getDB() {
|
|
160
160
|
if (this.connectionName === "mongo") {
|
|
161
|
-
return await (0,
|
|
161
|
+
return await (0, ConnectionFactory_js_1.getConnection)(this.connectionName);
|
|
162
162
|
}
|
|
163
|
-
return await (0,
|
|
163
|
+
return await (0, ConnectionFactory_js_1.getAdapter)(this.connectionName);
|
|
164
164
|
}
|
|
165
165
|
getDriverName() {
|
|
166
|
-
return
|
|
166
|
+
return database_js_1.dbConfig.connections[this.connectionName]?.driver ?? this.connectionName;
|
|
167
167
|
}
|
|
168
168
|
shouldSkipModelHooks() {
|
|
169
|
-
return (0,
|
|
169
|
+
return (0, CoreModelValidationEvents_js_1.shouldSkipModelHooks)(process.env.ELOQUENT_DISABLE_MODEL_HOOKS);
|
|
170
170
|
}
|
|
171
171
|
buildMongoPrimaryFilter(pk, id) {
|
|
172
|
-
return (0,
|
|
172
|
+
return (0, CoreModelPersistenceState_js_1.buildMongoPrimaryFilter)(pk, id);
|
|
173
173
|
}
|
|
174
174
|
getPersistenceSchema() {
|
|
175
|
-
return (0,
|
|
175
|
+
return (0, CoreModelPersistenceState_js_1.getPersistenceSchema)(this.constructor.name, this.constructor.schema);
|
|
176
176
|
}
|
|
177
177
|
getColumnFieldNames() {
|
|
178
|
-
return (0,
|
|
178
|
+
return (0, CoreModelPersistenceState_js_1.getColumnFieldNames)(this.getPersistenceSchema());
|
|
179
179
|
}
|
|
180
180
|
resolvePrimaryKey() {
|
|
181
|
-
return (0,
|
|
181
|
+
return (0, CoreModelPersistenceState_js_1.resolvePrimaryKey)(this.constructor.schema);
|
|
182
182
|
}
|
|
183
183
|
getPrimaryKeyValue(pk) {
|
|
184
|
-
return (0,
|
|
184
|
+
return (0, CoreModelPersistenceState_js_1.getPrimaryKeyValue)(this, pk);
|
|
185
185
|
}
|
|
186
186
|
getOriginalPrimaryKeyValue(pk) {
|
|
187
|
-
return (0,
|
|
187
|
+
return (0, CoreModelPersistenceState_js_1.getOriginalPrimaryKeyValue)(this._originalAttributes, pk);
|
|
188
188
|
}
|
|
189
189
|
createSnapshot(source) {
|
|
190
190
|
const snapshotSource = source ?? Object.assign({}, this);
|
|
191
|
-
return (0,
|
|
191
|
+
return (0, CoreModelPersistenceState_js_1.createPersistedSnapshot)({
|
|
192
192
|
source: snapshotSource,
|
|
193
193
|
schema: this.constructor.schema,
|
|
194
194
|
primaryKey: this.resolvePrimaryKey(),
|
|
@@ -199,7 +199,7 @@ class CoreModel {
|
|
|
199
199
|
this._originalAttributes = this.createSnapshot(source);
|
|
200
200
|
}
|
|
201
201
|
assertAssignableField(field, usage) {
|
|
202
|
-
(0,
|
|
202
|
+
(0, CoreModelPersistenceState_js_1.sanitizeAssignableData)({
|
|
203
203
|
data: { [field]: undefined },
|
|
204
204
|
usage,
|
|
205
205
|
schema: this.getPersistenceSchema(),
|
|
@@ -207,7 +207,7 @@ class CoreModel {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
sanitizeAssignableData(data, usage) {
|
|
210
|
-
return (0,
|
|
210
|
+
return (0, CoreModelPersistenceState_js_1.sanitizeAssignableData)({
|
|
211
211
|
data,
|
|
212
212
|
usage,
|
|
213
213
|
schema: this.getPersistenceSchema(),
|
|
@@ -215,13 +215,13 @@ class CoreModel {
|
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
extractPersistableAttributes() {
|
|
218
|
-
return (0,
|
|
218
|
+
return (0, CoreModelPersistenceState_js_1.extractPersistableAttributes)({
|
|
219
219
|
record: this,
|
|
220
220
|
columnFieldNames: this.getColumnFieldNames(),
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
assertPrimaryKeyNotMutated(primaryKey) {
|
|
224
|
-
(0,
|
|
224
|
+
(0, CoreModelPersistenceState_js_1.assertPrimaryKeyNotMutated)({
|
|
225
225
|
exists: this._exists,
|
|
226
226
|
primaryKey,
|
|
227
227
|
currentPrimaryKey: this.getPrimaryKeyValue(primaryKey),
|
|
@@ -230,7 +230,7 @@ class CoreModel {
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
getDirtyAttributes(primaryKey) {
|
|
233
|
-
return (0,
|
|
233
|
+
return (0, CoreModelPersistenceState_js_1.getDirtyAttributes)({
|
|
234
234
|
currentAttributes: this.extractPersistableAttributes(),
|
|
235
235
|
originalAttributes: this._originalAttributes,
|
|
236
236
|
primaryKey,
|
|
@@ -301,7 +301,7 @@ class CoreModel {
|
|
|
301
301
|
const schema = this.constructor.schema;
|
|
302
302
|
const hooks = this.constructor.validationHooks;
|
|
303
303
|
const customRules = this.constructor.customRules;
|
|
304
|
-
await (0,
|
|
304
|
+
await (0, CoreModelValidationEvents_js_1.validateModelData)({
|
|
305
305
|
tableName: this.tableName,
|
|
306
306
|
schema,
|
|
307
307
|
hooks,
|
|
@@ -319,7 +319,7 @@ class CoreModel {
|
|
|
319
319
|
*/
|
|
320
320
|
async fireEvent(eventName, payload) {
|
|
321
321
|
const handler = this.constructor.modelEvents?.[eventName];
|
|
322
|
-
return (0,
|
|
322
|
+
return (0, CoreModelValidationEvents_js_1.fireModelEvent)({
|
|
323
323
|
skipModelHooks: this.shouldSkipModelHooks(),
|
|
324
324
|
handler: handler,
|
|
325
325
|
payload,
|
|
@@ -528,13 +528,13 @@ exports.CoreModel = CoreModel;
|
|
|
528
528
|
class MongoModel extends CoreModel {
|
|
529
529
|
constructor(tableName, connectionName = "mongo") {
|
|
530
530
|
super(tableName, connectionName);
|
|
531
|
-
const driver =
|
|
531
|
+
const driver = database_js_1.dbConfig.connections[this.connectionName]?.driver ?? this.connectionName;
|
|
532
532
|
if (driver !== "mongo") {
|
|
533
533
|
throw new Error(`MongoModel requires a mongo driver connection. Received: ${this.connectionName}`);
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
async getDB() {
|
|
537
|
-
return (await (0,
|
|
537
|
+
return (await (0, ConnectionFactory_js_1.getConnection)(this.connectionName));
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
540
|
exports.MongoModel = MongoModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SchemaField } from "../schema/SchemaBlueprint";
|
|
1
|
+
import type { SchemaField } from "../schema/SchemaBlueprint.js";
|
|
2
2
|
export type PersistenceUsage = "fill" | "patch";
|
|
3
3
|
export declare function buildMongoPrimaryFilter(pk: string, id: number | string): Record<string, unknown>;
|
|
4
4
|
export declare function getPersistenceSchema(modelName: string, schema?: Record<string, SchemaField>): Record<string, SchemaField>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SafeFinderFilters, SafeFinderModelInstance, SafeFinderModelStatic } from "./SafeFinder";
|
|
2
|
-
import { SafeFinderQuery } from "./SafeFinder";
|
|
1
|
+
import type { SafeFinderFilters, SafeFinderModelInstance, SafeFinderModelStatic } from "./SafeFinder.js";
|
|
2
|
+
import { SafeFinderQuery } from "./SafeFinder.js";
|
|
3
3
|
export declare function createSafeFinderQuery<TModel extends SafeFinderModelInstance>(model: TModel, modelClass: SafeFinderModelStatic<TModel>): SafeFinderQuery<TModel>;
|
|
4
4
|
export declare function applySafeFinderFilters<TModel extends SafeFinderModelInstance>(finder: SafeFinderQuery<TModel>, filters: SafeFinderFilters): SafeFinderQuery<TModel>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSafeFinderQuery = createSafeFinderQuery;
|
|
4
4
|
exports.applySafeFinderFilters = applySafeFinderFilters;
|
|
5
|
-
const
|
|
5
|
+
const SafeFinder_js_1 = require("./SafeFinder.js");
|
|
6
6
|
function createSafeFinderQuery(model, modelClass) {
|
|
7
|
-
return new
|
|
7
|
+
return new SafeFinder_js_1.SafeFinderQuery(model, modelClass);
|
|
8
8
|
}
|
|
9
9
|
function applySafeFinderFilters(finder, filters) {
|
|
10
10
|
for (const [field, value] of Object.entries(filters)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SchemaValidatorOptions } from "../schema/SchemaValidator";
|
|
2
|
-
import type { SchemaField, ValidationRule } from "../schema/SchemaBlueprint";
|
|
1
|
+
import { SchemaValidatorOptions } from "../schema/SchemaValidator.js";
|
|
2
|
+
import type { SchemaField, ValidationRule } from "../schema/SchemaBlueprint.js";
|
|
3
3
|
export type CoreModelEventHandler = (payload: unknown) => Promise<unknown> | unknown;
|
|
4
4
|
export declare function shouldSkipModelHooks(envValue?: string): boolean;
|
|
5
5
|
export declare function buildValidationRules(options: {
|
|
@@ -4,7 +4,7 @@ exports.shouldSkipModelHooks = shouldSkipModelHooks;
|
|
|
4
4
|
exports.buildValidationRules = buildValidationRules;
|
|
5
5
|
exports.validateModelData = validateModelData;
|
|
6
6
|
exports.fireModelEvent = fireModelEvent;
|
|
7
|
-
const
|
|
7
|
+
const SchemaValidator_js_1 = require("../schema/SchemaValidator.js");
|
|
8
8
|
function shouldSkipModelHooks(envValue) {
|
|
9
9
|
return envValue === "1" || envValue === "true";
|
|
10
10
|
}
|
|
@@ -26,7 +26,7 @@ async function validateModelData(options) {
|
|
|
26
26
|
if (!schema)
|
|
27
27
|
return;
|
|
28
28
|
const validationRules = buildValidationRules({ schema, data, partial });
|
|
29
|
-
const errors = await
|
|
29
|
+
const errors = await SchemaValidator_js_1.SchemaValidator.validateData(data, validationRules, {
|
|
30
30
|
hooks: skipModelHooks ? undefined : hooks,
|
|
31
31
|
customRules,
|
|
32
32
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SchemaField } from "../schema/SchemaBlueprint";
|
|
1
|
+
import type { SchemaField } from "../schema/SchemaBlueprint.js";
|
|
2
2
|
export type SafeFinderDirection = "asc" | "desc";
|
|
3
3
|
export type SafeFinderFilters = Record<string, unknown>;
|
|
4
4
|
export interface SafeFinderModelInstance {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SafeFinderQuery = void 0;
|
|
4
|
-
const
|
|
4
|
+
const database_js_1 = require("../../config/database.js");
|
|
5
5
|
class SafeFinderQuery {
|
|
6
6
|
constructor(model, modelClass) {
|
|
7
7
|
this.model = model;
|
|
@@ -133,7 +133,7 @@ class SafeFinderQuery {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
getDriverName() {
|
|
136
|
-
const connections =
|
|
136
|
+
const connections = database_js_1.dbConfig.connections;
|
|
137
137
|
return connections[this.model.connectionName]?.driver ?? this.model.connectionName;
|
|
138
138
|
}
|
|
139
139
|
getSchema() {
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.CastsMixin = CastsMixin;
|
|
10
|
-
const
|
|
10
|
+
const BaseMethodResolver_js_1 = require("./utils/BaseMethodResolver.js");
|
|
11
11
|
function CastsMixin(Base) {
|
|
12
|
-
const resolveBaseMethod = (0,
|
|
12
|
+
const resolveBaseMethod = (0, BaseMethodResolver_js_1.createBaseMethodResolver)(Base);
|
|
13
13
|
class CastableModel extends Base {
|
|
14
14
|
constructor(...args) {
|
|
15
15
|
super(...args);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HooksMixin = HooksMixin;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const BaseMethodResolver_js_1 = require("./utils/BaseMethodResolver.js");
|
|
5
|
+
const HookStore_js_1 = require("./utils/HookStore.js");
|
|
6
|
+
const ModelRegistry_js_1 = require("./utils/ModelRegistry.js");
|
|
7
7
|
function HooksMixin(Base) {
|
|
8
|
-
const resolveBaseMethod = (0,
|
|
8
|
+
const resolveBaseMethod = (0, BaseMethodResolver_js_1.createBaseMethodResolver)(Base);
|
|
9
9
|
const deprecationWarnings = new WeakMap();
|
|
10
10
|
function warnDeprecatedApi(modelCtor, api) {
|
|
11
11
|
const seen = deprecationWarnings.get(modelCtor) ?? new Set();
|
|
@@ -27,7 +27,7 @@ function HooksMixin(Base) {
|
|
|
27
27
|
static on(event, callback) {
|
|
28
28
|
const modelCtor = this;
|
|
29
29
|
warnDeprecatedApi(modelCtor, "on");
|
|
30
|
-
|
|
30
|
+
HookStore_js_1.HookStore.add(modelCtor, event, callback);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Internal helper to trigger all hooks for an event.
|
|
@@ -38,8 +38,8 @@ function HooksMixin(Base) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const modelCtor = this.constructor;
|
|
41
|
-
|
|
42
|
-
const listeners =
|
|
41
|
+
ModelRegistry_js_1.ModelRegistry.ensureGranted(modelCtor, "lifecycle");
|
|
42
|
+
const listeners = HookStore_js_1.HookStore.get(modelCtor, event);
|
|
43
43
|
for (const cb of listeners) {
|
|
44
44
|
await cb(payload);
|
|
45
45
|
}
|
|
@@ -87,7 +87,7 @@ function HooksMixin(Base) {
|
|
|
87
87
|
registerHook(event, callback) {
|
|
88
88
|
const modelCtor = this.constructor;
|
|
89
89
|
warnDeprecatedApi(modelCtor, "registerHook");
|
|
90
|
-
|
|
90
|
+
HookStore_js_1.HookStore.add(modelCtor, event, callback);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return Hookable;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MorphableMixin = MorphableMixin;
|
|
4
4
|
// src/core/orm/mixins/MorphableMixin.ts
|
|
5
|
-
const
|
|
5
|
+
const MorphRegistry_js_1 = require("./MorphRegistry.js");
|
|
6
6
|
function assertSafeRelationName(relationName) {
|
|
7
7
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(relationName)) {
|
|
8
8
|
throw new Error(`Unsafe relation name: ${relationName}`);
|
|
@@ -45,8 +45,8 @@ function MorphableMixin(Base) {
|
|
|
45
45
|
// Auto-register this class in MorphRegistry once per subclass.
|
|
46
46
|
const ctor = this.constructor;
|
|
47
47
|
const alias = ctor.morphAlias || ctor.name;
|
|
48
|
-
if (!
|
|
49
|
-
|
|
48
|
+
if (!MorphRegistry_js_1.MorphRegistry.has(alias)) {
|
|
49
|
+
MorphRegistry_js_1.MorphRegistry.register(alias, ctor);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
/** morphTo('commentable') */
|
|
@@ -57,7 +57,7 @@ function MorphableMixin(Base) {
|
|
|
57
57
|
const id = record[`${relationName}_id`];
|
|
58
58
|
if (!type || id === undefined)
|
|
59
59
|
return null;
|
|
60
|
-
const ModelClass =
|
|
60
|
+
const ModelClass = MorphRegistry_js_1.MorphRegistry.resolve(type);
|
|
61
61
|
if (typeof ModelClass.prototype.find !== "function") {
|
|
62
62
|
throw new Error(`ERROR: Model '${type}' does not implement find().`);
|
|
63
63
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.PivotHelperMixin = PivotHelperMixin;
|
|
9
|
-
const
|
|
9
|
+
const database_js_1 = require("../../../config/database.js");
|
|
10
10
|
/**
|
|
11
11
|
* ✅ Updated PivotHelperMixin
|
|
12
12
|
* - Adds a type stub for getDB() so TS is satisfied
|
|
@@ -27,7 +27,7 @@ function PivotHelperMixin(Base) {
|
|
|
27
27
|
return;
|
|
28
28
|
const conn = this.connectionName;
|
|
29
29
|
const key = conn;
|
|
30
|
-
const driver =
|
|
30
|
+
const driver = database_js_1.dbConfig.connections[key]?.driver ?? conn;
|
|
31
31
|
switch (driver) {
|
|
32
32
|
case "sqlite":
|
|
33
33
|
case "mysql":
|
|
@@ -62,7 +62,7 @@ function PivotHelperMixin(Base) {
|
|
|
62
62
|
const db = await this.getDB();
|
|
63
63
|
const conn = this.connectionName;
|
|
64
64
|
const key = conn;
|
|
65
|
-
const driver =
|
|
65
|
+
const driver = database_js_1.dbConfig.connections[key]?.driver ?? conn;
|
|
66
66
|
switch (driver) {
|
|
67
67
|
case "sqlite":
|
|
68
68
|
case "mysql":
|