sonamu 0.4.6 → 0.4.7
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/dist/{base-model-CWRKUX49.d.ts → base-model-C24du9JT.d.ts} +1 -1
- package/dist/{base-model-BzMJ2E_I.d.mts → base-model-IZdmwmB5.d.mts} +1 -1
- package/dist/bin/cli.js +51 -51
- package/dist/bin/cli.mjs +2 -2
- package/dist/{chunk-WJGRXAXE.js → chunk-54T42DSA.js} +35 -28
- package/dist/chunk-54T42DSA.js.map +1 -0
- package/dist/{chunk-HVVCQLAU.mjs → chunk-5CB4CKVQ.mjs} +2 -2
- package/dist/{chunk-EUP6N7EK.js → chunk-6HM2HY4W.js} +100 -100
- package/dist/{chunk-N6N3LENC.js → chunk-COZNUCYR.js} +4 -4
- package/dist/{chunk-6SP5N5ND.mjs → chunk-HRZ23FCT.mjs} +2 -2
- package/dist/{chunk-UAG3SKFM.js → chunk-JNQQ3K3E.js} +7 -7
- package/dist/{chunk-4K2F3SOM.mjs → chunk-VOEEO52Y.mjs} +2 -2
- package/dist/{chunk-ZFLQLW37.mjs → chunk-YOH4CHWQ.mjs} +13 -6
- package/dist/chunk-YOH4CHWQ.mjs.map +1 -0
- package/dist/database/drivers/knex/base-model.d.mts +2 -2
- package/dist/database/drivers/knex/base-model.d.ts +2 -2
- package/dist/database/drivers/knex/base-model.js +8 -8
- package/dist/database/drivers/knex/base-model.mjs +3 -3
- package/dist/database/drivers/kysely/base-model.d.mts +2 -2
- package/dist/database/drivers/kysely/base-model.d.ts +2 -2
- package/dist/database/drivers/kysely/base-model.js +9 -9
- package/dist/database/drivers/kysely/base-model.mjs +3 -3
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{model-CAH_4oQh.d.ts → model-Dbbfpk2X.d.mts} +1 -1
- package/dist/{model-CAH_4oQh.d.mts → model-Dbbfpk2X.d.ts} +1 -1
- package/package.json +1 -1
- package/src/database/drivers/knex/db.ts +10 -5
- package/src/database/drivers/kysely/db.ts +1 -1
- package/src/database/types.ts +2 -1
- package/src/index.ts +2 -0
- package/dist/chunk-WJGRXAXE.js.map +0 -1
- package/dist/chunk-ZFLQLW37.mjs.map +0 -1
- /package/dist/{chunk-HVVCQLAU.mjs.map → chunk-5CB4CKVQ.mjs.map} +0 -0
- /package/dist/{chunk-EUP6N7EK.js.map → chunk-6HM2HY4W.js.map} +0 -0
- /package/dist/{chunk-N6N3LENC.js.map → chunk-COZNUCYR.js.map} +0 -0
- /package/dist/{chunk-6SP5N5ND.mjs.map → chunk-HRZ23FCT.mjs.map} +0 -0
- /package/dist/{chunk-UAG3SKFM.js.map → chunk-JNQQ3K3E.js.map} +0 -0
- /package/dist/{chunk-4K2F3SOM.mjs.map → chunk-VOEEO52Y.mjs.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
DB,
|
|
3
3
|
EntityManager,
|
|
4
4
|
nonNullable
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YOH4CHWQ.mjs";
|
|
6
6
|
|
|
7
7
|
// src/database/upsert-builder.ts
|
|
8
8
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -277,4 +277,4 @@ export {
|
|
|
277
277
|
isRefField,
|
|
278
278
|
UpsertBuilder
|
|
279
279
|
};
|
|
280
|
-
//# sourceMappingURL=chunk-
|
|
280
|
+
//# sourceMappingURL=chunk-5CB4CKVQ.mjs.map
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk54T42DSAjs = require('./chunk-54T42DSA.js');
|
|
20
20
|
|
|
21
21
|
// src/entity/migrator.ts
|
|
22
22
|
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
@@ -34,10 +34,10 @@ var Migrator = class {
|
|
|
34
34
|
constructor(options) {
|
|
35
35
|
this.mode = options.mode;
|
|
36
36
|
if (this.mode === "dev") {
|
|
37
|
-
const devDB =
|
|
38
|
-
const testDB =
|
|
39
|
-
const fixtureLocalDB =
|
|
40
|
-
const uniqConfigs =
|
|
37
|
+
const devDB = _chunk54T42DSAjs.DB.getClient("development_master");
|
|
38
|
+
const testDB = _chunk54T42DSAjs.DB.getClient("test");
|
|
39
|
+
const fixtureLocalDB = _chunk54T42DSAjs.DB.getClient("fixture_local");
|
|
40
|
+
const uniqConfigs = _chunk54T42DSAjs.DB.getUniqueConfigs([
|
|
41
41
|
"development_master",
|
|
42
42
|
"test",
|
|
43
43
|
"fixture_local",
|
|
@@ -45,7 +45,7 @@ var Migrator = class {
|
|
|
45
45
|
]);
|
|
46
46
|
const applyDBs = [devDB, testDB, fixtureLocalDB];
|
|
47
47
|
if (uniqConfigs.length === 4) {
|
|
48
|
-
const fixtureRemoteDB =
|
|
48
|
+
const fixtureRemoteDB = _chunk54T42DSAjs.DB.getClient("fixture_remote");
|
|
49
49
|
applyDBs.push(fixtureRemoteDB);
|
|
50
50
|
}
|
|
51
51
|
this.targets = {
|
|
@@ -55,8 +55,8 @@ var Migrator = class {
|
|
|
55
55
|
apply: applyDBs
|
|
56
56
|
};
|
|
57
57
|
} else if (this.mode === "deploy") {
|
|
58
|
-
const productionDB =
|
|
59
|
-
const testDB =
|
|
58
|
+
const productionDB = _chunk54T42DSAjs.DB.getClient("production_master");
|
|
59
|
+
const testDB = _chunk54T42DSAjs.DB.getClient("test");
|
|
60
60
|
this.targets = {
|
|
61
61
|
pending: productionDB,
|
|
62
62
|
shadow: testDB,
|
|
@@ -67,8 +67,8 @@ var Migrator = class {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
async getMigrationCodes() {
|
|
70
|
-
const srcMigrationsDir = `${
|
|
71
|
-
const distMigrationsDir = `${
|
|
70
|
+
const srcMigrationsDir = `${_chunk54T42DSAjs.Sonamu.apiRootPath}/src/migrations`;
|
|
71
|
+
const distMigrationsDir = `${_chunk54T42DSAjs.Sonamu.apiRootPath}/dist/migrations`;
|
|
72
72
|
if (_fsextra2.default.existsSync(srcMigrationsDir) === false) {
|
|
73
73
|
_fsextra2.default.mkdirSync(srcMigrationsDir, {
|
|
74
74
|
recursive: true
|
|
@@ -113,7 +113,7 @@ var Migrator = class {
|
|
|
113
113
|
const { normal, onlyTs, onlyJs } = await this.getMigrationCodes();
|
|
114
114
|
if (onlyTs.length > 0) {
|
|
115
115
|
console.debug({ onlyTs });
|
|
116
|
-
throw new (0,
|
|
116
|
+
throw new (0, _chunk54T42DSAjs.ServiceUnavailableException)(
|
|
117
117
|
`There are un-compiled TS migration files.
|
|
118
118
|
Please compile them first.
|
|
119
119
|
|
|
@@ -130,12 +130,12 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
130
130
|
})
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
|
-
const connKeys = Object.keys(
|
|
133
|
+
const connKeys = Object.keys(_chunk54T42DSAjs.DB.fullConfig).filter(
|
|
134
134
|
(key) => key.endsWith("_slave") === false
|
|
135
135
|
);
|
|
136
136
|
const statuses = await Promise.all(
|
|
137
137
|
connKeys.map(async (connKey) => {
|
|
138
|
-
const tConn =
|
|
138
|
+
const tConn = _chunk54T42DSAjs.DB.getClient(connKey);
|
|
139
139
|
const status = await (async () => {
|
|
140
140
|
try {
|
|
141
141
|
return await tConn.status();
|
|
@@ -172,7 +172,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
172
172
|
if (status0conn === void 0) {
|
|
173
173
|
return [];
|
|
174
174
|
}
|
|
175
|
-
const compareDBconn =
|
|
175
|
+
const compareDBconn = _chunk54T42DSAjs.DB.getClient(status0conn.connKey);
|
|
176
176
|
const genCodes = await this.compareMigrations(compareDBconn);
|
|
177
177
|
await compareDBconn.destroy();
|
|
178
178
|
return genCodes;
|
|
@@ -184,11 +184,11 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
async runAction(action, targets) {
|
|
187
|
-
const configs =
|
|
187
|
+
const configs = _chunk54T42DSAjs.DB.getUniqueConfigs(targets);
|
|
188
188
|
const conns = await Promise.all(
|
|
189
189
|
configs.map(async (config) => ({
|
|
190
190
|
connKey: config.connKey,
|
|
191
|
-
db:
|
|
191
|
+
db: _chunk54T42DSAjs.DB.getClient(config.connKey)
|
|
192
192
|
}))
|
|
193
193
|
);
|
|
194
194
|
const result = await (async () => {
|
|
@@ -236,8 +236,8 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
238
|
const delFiles = codeNames.map((codeName) => [
|
|
239
|
-
`${
|
|
240
|
-
`${
|
|
239
|
+
`${_chunk54T42DSAjs.Sonamu.apiRootPath}/src/migrations/${codeName}.ts`,
|
|
240
|
+
`${_chunk54T42DSAjs.Sonamu.apiRootPath}/dist/migrations/${codeName}.js`
|
|
241
241
|
]).flat();
|
|
242
242
|
const res = await Promise.all(
|
|
243
243
|
delFiles.map((delFile) => {
|
|
@@ -257,7 +257,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
257
257
|
console.log(_chalk2.default.green("\n\uD604\uC7AC \uBAA8\uB450 \uC2F1\uD06C\uB41C \uC0C1\uD0DC\uC785\uB2C8\uB2E4."));
|
|
258
258
|
return 0;
|
|
259
259
|
}
|
|
260
|
-
const migrationsDir = `${
|
|
260
|
+
const migrationsDir = `${_chunk54T42DSAjs.Sonamu.apiRootPath}/src/migrations`;
|
|
261
261
|
preparedCodes.filter((pcode) => pcode.formatted).map((pcode, index) => {
|
|
262
262
|
const dateTag = _luxon.DateTime.local().plus({ seconds: index }).toFormat("yyyyMMddHHmmss");
|
|
263
263
|
const filePath = `${migrationsDir}/${dateTag}_${pcode.title}.ts`;
|
|
@@ -268,7 +268,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
268
268
|
}
|
|
269
269
|
async clearPendingList() {
|
|
270
270
|
const pendingList = await this.targets.pending.getMigrations();
|
|
271
|
-
const migrationsDir = `${
|
|
271
|
+
const migrationsDir = `${_chunk54T42DSAjs.Sonamu.apiRootPath}/src/migrations`;
|
|
272
272
|
const delList = pendingList.map((df) => {
|
|
273
273
|
return _path2.default.join(migrationsDir, `${df}.ts`);
|
|
274
274
|
});
|
|
@@ -332,7 +332,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
332
332
|
if (answer.value === false) {
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
|
-
const migrationsDir = `${
|
|
335
|
+
const migrationsDir = `${_chunk54T42DSAjs.Sonamu.apiRootPath}/src/migrations`;
|
|
336
336
|
codes.filter((code) => code.formatted).map((code, index) => {
|
|
337
337
|
const dateTag = _luxon.DateTime.local().plus({ seconds: index }).toFormat("yyyyMMddHHmmss");
|
|
338
338
|
const filePath = `${migrationsDir}/${dateTag}_${code.title}.ts`;
|
|
@@ -354,7 +354,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
354
354
|
const files = ["src", "dist"].reduce(
|
|
355
355
|
(r, which) => {
|
|
356
356
|
const migrationPath = _path2.default.join(
|
|
357
|
-
|
|
357
|
+
_chunk54T42DSAjs.Sonamu.apiRootPath,
|
|
358
358
|
which,
|
|
359
359
|
"migrations"
|
|
360
360
|
);
|
|
@@ -402,7 +402,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
const filesToRm = diffOnDist.map((filename) => {
|
|
405
|
-
return _path2.default.join(
|
|
405
|
+
return _path2.default.join(_chunk54T42DSAjs.Sonamu.apiRootPath, "dist", "migrations", filename);
|
|
406
406
|
});
|
|
407
407
|
filesToRm.map((filePath) => {
|
|
408
408
|
_fsextra2.default.unlinkSync(filePath);
|
|
@@ -411,7 +411,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
async runShadowTest() {
|
|
414
|
-
const tdb =
|
|
414
|
+
const tdb = _chunk54T42DSAjs.DB.getClient("test");
|
|
415
415
|
const tdbConn = tdb.connectionInfo;
|
|
416
416
|
const shadowDatabase = tdbConn.database + "__migration_shadow";
|
|
417
417
|
const tmpSqlPath = `/tmp/${shadowDatabase}.sql`;
|
|
@@ -449,7 +449,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
449
449
|
];
|
|
450
450
|
} catch (e) {
|
|
451
451
|
console.error(e);
|
|
452
|
-
throw new (0,
|
|
452
|
+
throw new (0, _chunk54T42DSAjs.ServiceUnavailableException)("Shadow DB \uD14C\uC2A4\uD2B8 \uC9C4\uD589 \uC911 \uC5D0\uB7EC");
|
|
453
453
|
} finally {
|
|
454
454
|
await tdb.destroy();
|
|
455
455
|
}
|
|
@@ -472,19 +472,19 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
472
472
|
);
|
|
473
473
|
console.log({ rollbackAllResult });
|
|
474
474
|
console.timeEnd(_chalk2.default.red("rollback-all:"));
|
|
475
|
-
const migrationsDir = `${
|
|
475
|
+
const migrationsDir = `${_chunk54T42DSAjs.Sonamu.apiRootPath}/src/migrations`;
|
|
476
476
|
console.time(_chalk2.default.red("delete migration files"));
|
|
477
477
|
_child_process.execSync.call(void 0, `rm -f ${migrationsDir}/*`);
|
|
478
478
|
_child_process.execSync.call(void 0, `rm -f ${migrationsDir.replace("/src/", "/dist/")}/*`);
|
|
479
479
|
console.timeEnd(_chalk2.default.red("delete migration files"));
|
|
480
480
|
}
|
|
481
481
|
async compareMigrations(compareDB) {
|
|
482
|
-
const entityIds =
|
|
482
|
+
const entityIds = _chunk54T42DSAjs.EntityManager.getAllIds();
|
|
483
483
|
const entitySetsWithJoinTable = entityIds.filter((entityId) => {
|
|
484
|
-
const entity =
|
|
484
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(entityId);
|
|
485
485
|
return entity.props.length > 0;
|
|
486
486
|
}).map((entityId) => {
|
|
487
|
-
const entity =
|
|
487
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(entityId);
|
|
488
488
|
return this.getMigrationSetFromEntity(entity);
|
|
489
489
|
});
|
|
490
490
|
const joinTablesWithDup = entitySetsWithJoinTable.map((entitySet) => entitySet.joinTables).flat();
|
|
@@ -514,12 +514,12 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
514
514
|
);
|
|
515
515
|
if (dbSet === null) {
|
|
516
516
|
return [
|
|
517
|
-
await
|
|
517
|
+
await _chunk54T42DSAjs.DB.generator.generateCreateCode_ColumnAndIndexes(
|
|
518
518
|
entitySet.table,
|
|
519
519
|
entitySet.columns,
|
|
520
520
|
entitySet.indexes
|
|
521
521
|
),
|
|
522
|
-
...await
|
|
522
|
+
...await _chunk54T42DSAjs.DB.generator.generateCreateCode_Foreign(
|
|
523
523
|
entitySet.table,
|
|
524
524
|
entitySet.foreigns
|
|
525
525
|
)
|
|
@@ -565,7 +565,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
565
565
|
if (isEqualColumns && isEqualIndexes) {
|
|
566
566
|
return null;
|
|
567
567
|
} else {
|
|
568
|
-
return
|
|
568
|
+
return _chunk54T42DSAjs.DB.generator.generateAlterCode_ColumnAndIndexes(
|
|
569
569
|
entitySet.table,
|
|
570
570
|
entityColumns,
|
|
571
571
|
entityIndexes,
|
|
@@ -591,7 +591,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
591
591
|
(a) => [a.to, ...a.columns].join("-")
|
|
592
592
|
).map((f) => replaceNoActionOnMySQL(f));
|
|
593
593
|
if (_fastdeepequal2.default.call(void 0, entityForeigns, dbForeigns) === false) {
|
|
594
|
-
return
|
|
594
|
+
return _chunk54T42DSAjs.DB.generator.generateAlterCode_Foreigns(
|
|
595
595
|
entitySet.table,
|
|
596
596
|
entityForeigns,
|
|
597
597
|
dbForeigns
|
|
@@ -630,7 +630,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
630
630
|
table
|
|
631
631
|
);
|
|
632
632
|
} catch (e) {
|
|
633
|
-
if (
|
|
633
|
+
if (_chunk54T42DSAjs.isKnexError.call(void 0, e) && e.code === "ER_NO_SUCH_TABLE") {
|
|
634
634
|
return null;
|
|
635
635
|
}
|
|
636
636
|
console.error(e);
|
|
@@ -807,17 +807,17 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
807
807
|
getMigrationSetFromEntity(entity) {
|
|
808
808
|
const migrationSet = entity.props.reduce(
|
|
809
809
|
(r, prop) => {
|
|
810
|
-
if (
|
|
810
|
+
if (_chunk54T42DSAjs.isVirtualProp.call(void 0, prop)) {
|
|
811
811
|
return r;
|
|
812
812
|
}
|
|
813
|
-
if (
|
|
813
|
+
if (_chunk54T42DSAjs.isHasManyRelationProp.call(void 0, prop)) {
|
|
814
814
|
return r;
|
|
815
815
|
}
|
|
816
|
-
if (!
|
|
816
|
+
if (!_chunk54T42DSAjs.isRelationProp.call(void 0, prop)) {
|
|
817
817
|
let type;
|
|
818
|
-
if (
|
|
818
|
+
if (_chunk54T42DSAjs.isTextProp.call(void 0, prop)) {
|
|
819
819
|
type = prop.textType;
|
|
820
|
-
} else if (
|
|
820
|
+
} else if (_chunk54T42DSAjs.isEnumProp.call(void 0, prop)) {
|
|
821
821
|
type = "string";
|
|
822
822
|
} else {
|
|
823
823
|
type = prop.type;
|
|
@@ -825,8 +825,8 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
825
825
|
const column = {
|
|
826
826
|
name: prop.name,
|
|
827
827
|
type,
|
|
828
|
-
...
|
|
829
|
-
...(
|
|
828
|
+
..._chunk54T42DSAjs.isIntegerProp.call(void 0, prop) && { unsigned: prop.unsigned === true },
|
|
829
|
+
...(_chunk54T42DSAjs.isStringProp.call(void 0, prop) || _chunk54T42DSAjs.isEnumProp.call(void 0, prop)) && {
|
|
830
830
|
length: prop.length
|
|
831
831
|
},
|
|
832
832
|
nullable: prop.nullable === true,
|
|
@@ -840,15 +840,15 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
840
840
|
})(),
|
|
841
841
|
// FIXME: float(N, M) deprecated
|
|
842
842
|
// Decimal, Float 타입의 경우 precision, scale 추가
|
|
843
|
-
...(
|
|
843
|
+
...(_chunk54T42DSAjs.isDecimalProp.call(void 0, prop) || _chunk54T42DSAjs.isFloatProp.call(void 0, prop)) && {
|
|
844
844
|
precision: _nullishCoalesce(prop.precision, () => ( 8)),
|
|
845
845
|
scale: _nullishCoalesce(prop.scale, () => ( 2))
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
848
|
r.columns.push(column);
|
|
849
849
|
}
|
|
850
|
-
if (
|
|
851
|
-
const relMd =
|
|
850
|
+
if (_chunk54T42DSAjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
851
|
+
const relMd = _chunk54T42DSAjs.EntityManager.get(prop.with);
|
|
852
852
|
const [table1, table2] = prop.joinTable.split("__");
|
|
853
853
|
const join = {
|
|
854
854
|
from: `${entity.table}.id`,
|
|
@@ -920,7 +920,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
920
920
|
})
|
|
921
921
|
});
|
|
922
922
|
return r;
|
|
923
|
-
} else if (
|
|
923
|
+
} else if (_chunk54T42DSAjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
|
|
924
924
|
const idColumnName = prop.name + "_id";
|
|
925
925
|
r.columns.push({
|
|
926
926
|
name: idColumnName,
|
|
@@ -1056,13 +1056,13 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
1056
1056
|
const node = this.graph.get(fixture.fixtureId);
|
|
1057
1057
|
for (const [, column] of Object.entries(fixture.columns)) {
|
|
1058
1058
|
const prop = column.prop;
|
|
1059
|
-
if (
|
|
1060
|
-
if (
|
|
1059
|
+
if (_chunk54T42DSAjs.isRelationProp.call(void 0, prop)) {
|
|
1060
|
+
if (_chunk54T42DSAjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
|
|
1061
1061
|
const relatedFixtureId = `${prop.with}#${column.value}`;
|
|
1062
1062
|
if (this.graph.has(relatedFixtureId)) {
|
|
1063
1063
|
node.related.add(relatedFixtureId);
|
|
1064
1064
|
}
|
|
1065
|
-
} else if (
|
|
1065
|
+
} else if (_chunk54T42DSAjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
1066
1066
|
const relatedIds = column.value;
|
|
1067
1067
|
for (const relatedId of relatedIds) {
|
|
1068
1068
|
const relatedFixtureId = `${prop.with}#${relatedId}`;
|
|
@@ -1088,11 +1088,11 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
1088
1088
|
}
|
|
1089
1089
|
tempVisited.add(fixtureId);
|
|
1090
1090
|
const node = this.graph.get(fixtureId);
|
|
1091
|
-
const entity =
|
|
1091
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(node.entityId);
|
|
1092
1092
|
for (const depId of node.related) {
|
|
1093
1093
|
const depNode = this.graph.get(depId);
|
|
1094
1094
|
const relationProp = entity.props.find(
|
|
1095
|
-
(prop) =>
|
|
1095
|
+
(prop) => _chunk54T42DSAjs.isRelationProp.call(void 0, prop) && (_chunk54T42DSAjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) && prop.with === depNode.entityId
|
|
1096
1096
|
);
|
|
1097
1097
|
if (relationProp && !relationProp.nullable) {
|
|
1098
1098
|
visit(depId);
|
|
@@ -1118,39 +1118,39 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
1118
1118
|
var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__init2.call(this); }
|
|
1119
1119
|
__init2() {this.relationGraph = new RelationGraph()}
|
|
1120
1120
|
init() {
|
|
1121
|
-
|
|
1121
|
+
_chunk54T42DSAjs.DB.testInit();
|
|
1122
1122
|
}
|
|
1123
1123
|
async cleanAndSeed(usingTables) {
|
|
1124
1124
|
const tableNames = await (async () => {
|
|
1125
1125
|
if (usingTables) {
|
|
1126
1126
|
return usingTables;
|
|
1127
1127
|
}
|
|
1128
|
-
const tables = await
|
|
1128
|
+
const tables = await _chunk54T42DSAjs.DB.tdb.raw(
|
|
1129
1129
|
`SHOW TABLE STATUS WHERE Engine IS NOT NULL`
|
|
1130
1130
|
);
|
|
1131
1131
|
return tables.map((tableInfo) => tableInfo["Name"]);
|
|
1132
1132
|
})();
|
|
1133
|
-
await
|
|
1133
|
+
await _chunk54T42DSAjs.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 0`);
|
|
1134
1134
|
for await (let tableName of tableNames) {
|
|
1135
1135
|
if (tableName == "migrations") {
|
|
1136
1136
|
continue;
|
|
1137
1137
|
}
|
|
1138
|
-
const [fdbChecksumRow] = await
|
|
1138
|
+
const [fdbChecksumRow] = await _chunk54T42DSAjs.DB.fdb.raw(
|
|
1139
1139
|
`CHECKSUM TABLE ${tableName}`
|
|
1140
1140
|
);
|
|
1141
1141
|
const fdbChecksum = fdbChecksumRow["Checksum"];
|
|
1142
|
-
const [tdbChecksumRow] = await
|
|
1142
|
+
const [tdbChecksumRow] = await _chunk54T42DSAjs.DB.tdb.raw(
|
|
1143
1143
|
`CHECKSUM TABLE ${tableName}`
|
|
1144
1144
|
);
|
|
1145
1145
|
const tdbChecksum = tdbChecksumRow["Checksum"];
|
|
1146
1146
|
if (fdbChecksum !== tdbChecksum) {
|
|
1147
|
-
await
|
|
1148
|
-
const rawQuery = `INSERT INTO ${
|
|
1149
|
-
SELECT * FROM ${
|
|
1150
|
-
await
|
|
1147
|
+
await _chunk54T42DSAjs.DB.tdb.truncate(tableName);
|
|
1148
|
+
const rawQuery = `INSERT INTO ${_chunk54T42DSAjs.DB.connectionInfo.test.database}.${tableName}
|
|
1149
|
+
SELECT * FROM ${_chunk54T42DSAjs.DB.connectionInfo.fixture_local.database}.${tableName}`;
|
|
1150
|
+
await _chunk54T42DSAjs.DB.tdb.raw(rawQuery);
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
|
-
await
|
|
1153
|
+
await _chunk54T42DSAjs.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 1`);
|
|
1154
1154
|
}
|
|
1155
1155
|
async getChecksum(db, tableName) {
|
|
1156
1156
|
const [checksumRow] = await db.raw(
|
|
@@ -1159,8 +1159,8 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1159
1159
|
return checksumRow.Checksum;
|
|
1160
1160
|
}
|
|
1161
1161
|
async sync() {
|
|
1162
|
-
const frdb =
|
|
1163
|
-
const tables = await
|
|
1162
|
+
const frdb = _chunk54T42DSAjs.DB.getClient("fixture_remote");
|
|
1163
|
+
const tables = await _chunk54T42DSAjs.DB.fdb.raw(
|
|
1164
1164
|
"SHOW TABLE STATUS WHERE Engine IS NOT NULL"
|
|
1165
1165
|
);
|
|
1166
1166
|
const tableNames = tables.map(
|
|
@@ -1169,13 +1169,13 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1169
1169
|
console.log(_chalk2.default.magenta("SYNC..."));
|
|
1170
1170
|
await Promise.all(
|
|
1171
1171
|
tableNames.map(async (tableName) => {
|
|
1172
|
-
if (tableName.startsWith(
|
|
1172
|
+
if (tableName.startsWith(_chunk54T42DSAjs.DB.migrationTable)) {
|
|
1173
1173
|
return;
|
|
1174
1174
|
}
|
|
1175
1175
|
const remoteChecksum = await this.getChecksum(frdb, tableName);
|
|
1176
|
-
const localChecksum = await this.getChecksum(
|
|
1176
|
+
const localChecksum = await this.getChecksum(_chunk54T42DSAjs.DB.fdb, tableName);
|
|
1177
1177
|
if (remoteChecksum !== localChecksum) {
|
|
1178
|
-
await
|
|
1178
|
+
await _chunk54T42DSAjs.DB.fdb.trx(async (transaction) => {
|
|
1179
1179
|
await transaction.raw(`SET FOREIGN_KEY_CHECKS = 0`);
|
|
1180
1180
|
await transaction.truncate(tableName);
|
|
1181
1181
|
const rows = await frdb.raw(`SELECT * FROM ${tableName}`);
|
|
@@ -1218,7 +1218,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1218
1218
|
})
|
|
1219
1219
|
)).flat()
|
|
1220
1220
|
);
|
|
1221
|
-
const wdb =
|
|
1221
|
+
const wdb = _chunk54T42DSAjs.DB.toClient(_chunk54T42DSAjs.DB.getDB("w"));
|
|
1222
1222
|
for (let query of queries) {
|
|
1223
1223
|
const [rsh] = await wdb.raw(query);
|
|
1224
1224
|
console.log({
|
|
@@ -1229,23 +1229,23 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1229
1229
|
}
|
|
1230
1230
|
async getImportQueries(entityId, field, id) {
|
|
1231
1231
|
console.log({ entityId, field, id });
|
|
1232
|
-
const entity =
|
|
1233
|
-
const wdb =
|
|
1232
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(entityId);
|
|
1233
|
+
const wdb = _chunk54T42DSAjs.DB.toClient(_chunk54T42DSAjs.DB.getDB("w"));
|
|
1234
1234
|
const [row] = await wdb.raw(
|
|
1235
1235
|
`SELECT * FROM ${entity.table} WHERE ${field} = ${id} LIMIT 1`
|
|
1236
1236
|
);
|
|
1237
1237
|
if (row === void 0) {
|
|
1238
1238
|
throw new Error(`${entityId}#${id} row\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.`);
|
|
1239
1239
|
}
|
|
1240
|
-
const fixtureDatabase =
|
|
1241
|
-
const realDatabase =
|
|
1240
|
+
const fixtureDatabase = _chunk54T42DSAjs.DB.connectionInfo.fixture_remote.database;
|
|
1241
|
+
const realDatabase = _chunk54T42DSAjs.DB.connectionInfo.production_master.database;
|
|
1242
1242
|
const selfQuery = `INSERT IGNORE INTO \`${fixtureDatabase}\`.\`${entity.table}\` (SELECT * FROM \`${realDatabase}\`.\`${entity.table}\` WHERE \`id\` = ${id})`;
|
|
1243
1243
|
const args = Object.entries(entity.relations).filter(
|
|
1244
|
-
([, relation]) =>
|
|
1244
|
+
([, relation]) => _chunk54T42DSAjs.isBelongsToOneRelationProp.call(void 0, relation) || _chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, relation) && relation.customJoinClause === void 0
|
|
1245
1245
|
).map(([, relation]) => {
|
|
1246
1246
|
let field2;
|
|
1247
1247
|
let id2;
|
|
1248
|
-
if (
|
|
1248
|
+
if (_chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, relation) && !relation.hasJoinColumn) {
|
|
1249
1249
|
field2 = `${relation.name}_id`;
|
|
1250
1250
|
id2 = row["id"];
|
|
1251
1251
|
} else {
|
|
@@ -1266,14 +1266,14 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1266
1266
|
return [..._lodash2.default.uniq(relQueries.reverse().flat()), selfQuery];
|
|
1267
1267
|
}
|
|
1268
1268
|
async destory() {
|
|
1269
|
-
await
|
|
1270
|
-
await
|
|
1269
|
+
await _chunk54T42DSAjs.DB.testDestroy();
|
|
1270
|
+
await _chunk54T42DSAjs.DB.destroy();
|
|
1271
1271
|
}
|
|
1272
1272
|
async getFixtures(sourceDBName, targetDBName, searchOptions) {
|
|
1273
|
-
const sourceDB =
|
|
1274
|
-
const targetDB =
|
|
1273
|
+
const sourceDB = _chunk54T42DSAjs.DB.getClient(sourceDBName);
|
|
1274
|
+
const targetDB = _chunk54T42DSAjs.DB.getClient(targetDBName);
|
|
1275
1275
|
const { entityId, field, value, searchType } = searchOptions;
|
|
1276
|
-
const entity =
|
|
1276
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(entityId);
|
|
1277
1277
|
const column = _optionalChain([entity, 'access', _10 => _10.props, 'access', _11 => _11.find, 'call', _12 => _12((prop) => prop.name === field), 'optionalAccess', _13 => _13.type]) === "relation" ? `${field}_id` : field;
|
|
1278
1278
|
let query = sourceDB.from(entity.table).selectAll();
|
|
1279
1279
|
if (searchType === "equals") {
|
|
@@ -1298,7 +1298,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
1300
|
for await (const fixture of fixtures) {
|
|
1301
|
-
const entity2 =
|
|
1301
|
+
const entity2 = _chunk54T42DSAjs.EntityManager.get(fixture.entityId);
|
|
1302
1302
|
const [row] = await targetDB.from(entity2.table).selectAll().where(["id", "=", fixture.id]).first().execute();
|
|
1303
1303
|
if (row) {
|
|
1304
1304
|
const [record] = await this.createFixtureRecord(entity2, row, {
|
|
@@ -1341,43 +1341,43 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1341
1341
|
belongsRecords: []
|
|
1342
1342
|
};
|
|
1343
1343
|
for (const prop of entity2.props) {
|
|
1344
|
-
if (
|
|
1344
|
+
if (_chunk54T42DSAjs.isVirtualProp.call(void 0, prop)) {
|
|
1345
1345
|
continue;
|
|
1346
1346
|
}
|
|
1347
1347
|
record.columns[prop.name] = {
|
|
1348
1348
|
prop,
|
|
1349
1349
|
value: row2[prop.name]
|
|
1350
1350
|
};
|
|
1351
|
-
const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14._db]), () => (
|
|
1352
|
-
if (
|
|
1353
|
-
const relatedEntity =
|
|
1351
|
+
const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14._db]), () => ( _chunk54T42DSAjs.DB.toClient(_chunk54T42DSAjs.DB.getDB("w"))));
|
|
1352
|
+
if (_chunk54T42DSAjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
1353
|
+
const relatedEntity = _chunk54T42DSAjs.EntityManager.get(prop.with);
|
|
1354
1354
|
const throughTable = prop.joinTable;
|
|
1355
1355
|
const fromColumn = `${_inflection2.default.singularize(entity2.table)}_id`;
|
|
1356
1356
|
const toColumn = `${_inflection2.default.singularize(relatedEntity.table)}_id`;
|
|
1357
1357
|
const _relatedIds = await db.from(throughTable).select(toColumn).where([fromColumn, "=", row2.id]).execute();
|
|
1358
1358
|
const relatedIds = _relatedIds.map((r) => parseInt(r[toColumn]));
|
|
1359
1359
|
record.columns[prop.name].value = relatedIds;
|
|
1360
|
-
} else if (
|
|
1361
|
-
const relatedEntity =
|
|
1360
|
+
} else if (_chunk54T42DSAjs.isHasManyRelationProp.call(void 0, prop)) {
|
|
1361
|
+
const relatedEntity = _chunk54T42DSAjs.EntityManager.get(prop.with);
|
|
1362
1362
|
const relatedIds = await db.from(relatedEntity.table).select("id").where([prop.joinColumn, "=", row2.id]).pluck("id");
|
|
1363
1363
|
record.columns[prop.name].value = relatedIds;
|
|
1364
|
-
} else if (
|
|
1365
|
-
const relatedEntity =
|
|
1364
|
+
} else if (_chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, prop) && !prop.hasJoinColumn) {
|
|
1365
|
+
const relatedEntity = _chunk54T42DSAjs.EntityManager.get(prop.with);
|
|
1366
1366
|
const relatedProp = relatedEntity.props.find(
|
|
1367
|
-
(p) =>
|
|
1367
|
+
(p) => _chunk54T42DSAjs.isRelationProp.call(void 0, p) && p.with === entity2.id
|
|
1368
1368
|
);
|
|
1369
1369
|
if (relatedProp) {
|
|
1370
1370
|
const [relatedRow] = await db.from(relatedEntity.table).select("id").where([relatedProp.name, "=", row2.id]).first().execute();
|
|
1371
1371
|
record.columns[prop.name].value = _optionalChain([relatedRow, 'optionalAccess', _15 => _15.id]);
|
|
1372
1372
|
}
|
|
1373
|
-
} else if (
|
|
1373
|
+
} else if (_chunk54T42DSAjs.isRelationProp.call(void 0, prop)) {
|
|
1374
1374
|
const relatedId = row2[`${prop.name}_id`];
|
|
1375
1375
|
record.columns[prop.name].value = relatedId;
|
|
1376
1376
|
if (relatedId) {
|
|
1377
1377
|
record.belongsRecords.push(`${prop.with}#${relatedId}`);
|
|
1378
1378
|
}
|
|
1379
1379
|
if (!_optionalChain([options, 'optionalAccess', _16 => _16.singleRecord]) && relatedId) {
|
|
1380
|
-
const relatedEntity =
|
|
1380
|
+
const relatedEntity = _chunk54T42DSAjs.EntityManager.get(prop.with);
|
|
1381
1381
|
const [relatedRow] = await db.from(relatedEntity.table).selectAll().where(["id", "=", relatedId]).first().execute();
|
|
1382
1382
|
if (relatedRow) {
|
|
1383
1383
|
await create(relatedEntity, relatedRow);
|
|
@@ -1394,7 +1394,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1394
1394
|
const fixtures = _lodash2.default.uniqBy(_fixtures, (f) => f.fixtureId);
|
|
1395
1395
|
this.relationGraph.buildGraph(fixtures);
|
|
1396
1396
|
const insertionOrder = this.relationGraph.getInsertionOrder();
|
|
1397
|
-
const db =
|
|
1397
|
+
const db = _chunk54T42DSAjs.DB.getClient(dbName);
|
|
1398
1398
|
await db.trx(async (trx) => {
|
|
1399
1399
|
await trx.raw(`SET FOREIGN_KEY_CHECKS = 0`);
|
|
1400
1400
|
for (const fixtureId of insertionOrder) {
|
|
@@ -1424,7 +1424,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1424
1424
|
});
|
|
1425
1425
|
const records = [];
|
|
1426
1426
|
for await (const r of fixtures) {
|
|
1427
|
-
const entity =
|
|
1427
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(r.entityId);
|
|
1428
1428
|
const [record] = await db.from(entity.table).selectAll().where(["id", "=", r.id]).first().execute();
|
|
1429
1429
|
records.push({
|
|
1430
1430
|
entityId: r.entityId,
|
|
@@ -1436,17 +1436,17 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1436
1436
|
prepareInsertData(fixture) {
|
|
1437
1437
|
const insertData = {};
|
|
1438
1438
|
for (const [propName, column] of Object.entries(fixture.columns)) {
|
|
1439
|
-
if (
|
|
1439
|
+
if (_chunk54T42DSAjs.isVirtualProp.call(void 0, column.prop)) {
|
|
1440
1440
|
continue;
|
|
1441
1441
|
}
|
|
1442
1442
|
const prop = column.prop;
|
|
1443
|
-
if (!
|
|
1443
|
+
if (!_chunk54T42DSAjs.isRelationProp.call(void 0, prop)) {
|
|
1444
1444
|
if (prop.type === "json") {
|
|
1445
1445
|
insertData[propName] = JSON.stringify(column.value);
|
|
1446
1446
|
} else {
|
|
1447
1447
|
insertData[propName] = column.value;
|
|
1448
1448
|
}
|
|
1449
|
-
} else if (
|
|
1449
|
+
} else if (_chunk54T42DSAjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk54T42DSAjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
|
|
1450
1450
|
insertData[`${propName}_id`] = column.value;
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
@@ -1454,7 +1454,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1454
1454
|
}
|
|
1455
1455
|
async insertFixture(db, fixture) {
|
|
1456
1456
|
const insertData = this.prepareInsertData(fixture);
|
|
1457
|
-
const entity =
|
|
1457
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(fixture.entityId);
|
|
1458
1458
|
try {
|
|
1459
1459
|
const uniqueFound = await this.checkUniqueViolation(db, entity, fixture);
|
|
1460
1460
|
if (uniqueFound) {
|
|
@@ -1483,15 +1483,15 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1483
1483
|
async handleManyToManyRelations(db, fixture, fixtures) {
|
|
1484
1484
|
for (const [, column] of Object.entries(fixture.columns)) {
|
|
1485
1485
|
const prop = column.prop;
|
|
1486
|
-
if (
|
|
1486
|
+
if (_chunk54T42DSAjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
1487
1487
|
const joinTable = prop.joinTable;
|
|
1488
1488
|
const relatedIds = column.value;
|
|
1489
1489
|
for (const relatedId of relatedIds) {
|
|
1490
1490
|
if (!fixtures.find((f) => f.fixtureId === `${prop.with}#${relatedId}`)) {
|
|
1491
1491
|
continue;
|
|
1492
1492
|
}
|
|
1493
|
-
const entity =
|
|
1494
|
-
const relatedEntity =
|
|
1493
|
+
const entity = _chunk54T42DSAjs.EntityManager.get(fixture.entityId);
|
|
1494
|
+
const relatedEntity = _chunk54T42DSAjs.EntityManager.get(prop.with);
|
|
1495
1495
|
if (!entity || !relatedEntity) {
|
|
1496
1496
|
throw new Error(
|
|
1497
1497
|
`Entity not found: ${fixture.entityId}, ${prop.with}`
|
|
@@ -1524,7 +1524,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1524
1524
|
}
|
|
1525
1525
|
}
|
|
1526
1526
|
async addFixtureLoader(code) {
|
|
1527
|
-
const path2 =
|
|
1527
|
+
const path2 = _chunk54T42DSAjs.Sonamu.apiRootPath + "/src/testing/fixture.ts";
|
|
1528
1528
|
let content = _fs.readFileSync.call(void 0, path2).toString();
|
|
1529
1529
|
const fixtureLoaderStart = content.indexOf("const fixtureLoader = {");
|
|
1530
1530
|
const fixtureLoaderEnd = content.indexOf("};", fixtureLoaderStart);
|
|
@@ -1576,4 +1576,4 @@ var FixtureManager = new FixtureManagerClass();
|
|
|
1576
1576
|
|
|
1577
1577
|
|
|
1578
1578
|
exports.Migrator = Migrator; exports.FixtureManagerClass = FixtureManagerClass; exports.FixtureManager = FixtureManager;
|
|
1579
|
-
//# sourceMappingURL=chunk-
|
|
1579
|
+
//# sourceMappingURL=chunk-6HM2HY4W.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk54T42DSAjs = require('./chunk-54T42DSA.js');
|
|
4
4
|
|
|
5
5
|
// src/database/base-model.ts
|
|
6
6
|
var _luxon = require('luxon');
|
|
@@ -53,8 +53,8 @@ var BaseModelClassAbstract = (_class = class {constructor() { _class.prototype._
|
|
|
53
53
|
db: _db,
|
|
54
54
|
optimizeCountQuery
|
|
55
55
|
}) {
|
|
56
|
-
const db = _nullishCoalesce(_db, () => (
|
|
57
|
-
const dbClient =
|
|
56
|
+
const db = _nullishCoalesce(_db, () => ( _chunk54T42DSAjs.DB.getDB(subset.startsWith("A") ? "w" : "r")));
|
|
57
|
+
const dbClient = _chunk54T42DSAjs.DB.toClient(db);
|
|
58
58
|
baseTable = _nullishCoalesce(baseTable, () => ( _inflection2.default.pluralize(_inflection2.default.underscore(this.modelName))));
|
|
59
59
|
const queryMode = _nullishCoalesce(params.queryMode, () => ( (params.id !== void 0 ? "list" : "both")));
|
|
60
60
|
const { select, virtual, joins, loaders } = subsetQuery;
|
|
@@ -228,4 +228,4 @@ var BaseModelClassAbstract = (_class = class {constructor() { _class.prototype._
|
|
|
228
228
|
|
|
229
229
|
|
|
230
230
|
exports.BaseModelClassAbstract = BaseModelClassAbstract;
|
|
231
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-COZNUCYR.js.map
|