@h3ravel/arquebus 0.6.6 → 0.6.8
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/README.md +5 -4
- package/bin/index.cjs +270 -425
- package/bin/{index.js → index.mjs} +230 -409
- package/bin/seeders-C0schOjT.mjs +3 -0
- package/bin/seeders-D-v59HCz.cjs +3 -0
- package/dist/browser/index.cjs +4 -12
- package/dist/browser/index.d.cts +203 -203
- package/dist/browser/{index.d.ts → index.d.mts} +203 -203
- package/dist/browser/{index.js → index.mjs} +4 -11
- package/dist/index.cjs +21 -59
- package/dist/index.d.cts +133 -133
- package/dist/{index.d.ts → index.d.mts} +133 -133
- package/dist/{index.js → index.mjs} +21 -54
- package/dist/inspector/index.cjs +15 -46
- package/dist/inspector/{index.js → index.mjs} +15 -43
- package/dist/migrations/{chunk-PECeCxCb.js → chunk-BD38OWEx.mjs} +1 -1
- package/dist/migrations/index.cjs +20 -57
- package/dist/migrations/index.d.cts +186 -186
- package/dist/migrations/{index.d.ts → index.d.mts} +186 -186
- package/dist/migrations/{index.js → index.mjs} +22 -54
- package/dist/seeders/index.cjs +1 -5
- package/dist/seeders/index.d.cts +184 -184
- package/dist/seeders/{index.d.ts → index.d.mts} +184 -184
- package/dist/seeders/{index.js → index.mjs} +2 -3
- package/dist/stubs/seeder-js.stub +4 -4
- package/dist/stubs/seeder-ts.stub +5 -0
- package/package.json +5 -4
- package/bin/seeders-8GJzfIIN.js +0 -3
- package/bin/seeders-ByeSoCAQ.cjs +0 -131
- package/bin/seeders-CltigymO.js +0 -79
- package/bin/seeders-_xJ6VGVS.cjs +0 -3
- /package/bin/{index.d.ts → index.d.mts} +0 -0
- /package/dist/inspector/{index.d.ts → index.d.mts} +0 -0
|
@@ -490,9 +490,7 @@ const HasAttributes = (Model$1) => {
|
|
|
490
490
|
}
|
|
491
491
|
originalIsEquivalent(key) {
|
|
492
492
|
if (this.original[key] === void 0) return false;
|
|
493
|
-
|
|
494
|
-
const original = this.original[key];
|
|
495
|
-
if (attribute === original) return true;
|
|
493
|
+
if (this.attributes[key] === this.original[key]) return true;
|
|
496
494
|
else return false;
|
|
497
495
|
}
|
|
498
496
|
setAttributes(attributes) {
|
|
@@ -674,8 +672,7 @@ const HasAttributes = (Model$1) => {
|
|
|
674
672
|
return new Date(value);
|
|
675
673
|
}
|
|
676
674
|
asDate(value) {
|
|
677
|
-
|
|
678
|
-
return dayjs(date).startOf("day").toDate();
|
|
675
|
+
return dayjs(this.asDateTime(value)).startOf("day").toDate();
|
|
679
676
|
}
|
|
680
677
|
};
|
|
681
678
|
};
|
|
@@ -1189,10 +1186,7 @@ const HasRelations = (Model$1) => {
|
|
|
1189
1186
|
return this.relations[relation] !== void 0;
|
|
1190
1187
|
}
|
|
1191
1188
|
related(relation) {
|
|
1192
|
-
if (typeof this[getRelationMethod(relation)] !== "function") {
|
|
1193
|
-
const message = `Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
1194
|
-
throw new RelationNotFoundError(message);
|
|
1195
|
-
}
|
|
1189
|
+
if (typeof this[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
1196
1190
|
return this[getRelationMethod(relation)]();
|
|
1197
1191
|
}
|
|
1198
1192
|
async getRelated(relation) {
|
|
@@ -2693,8 +2687,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
2693
2687
|
return columns.concat(this.aliasedPivotColumns());
|
|
2694
2688
|
}
|
|
2695
2689
|
aliasedPivotColumns() {
|
|
2696
|
-
|
|
2697
|
-
return collect(defaults.concat(this.pivotColumns)).map((column) => {
|
|
2690
|
+
return collect([this.foreignPivotKey, this.relatedPivotKey].concat(this.pivotColumns)).map((column) => {
|
|
2698
2691
|
return this.qualifyPivotColumn(column) + " as pivot_" + column;
|
|
2699
2692
|
}).unique().all();
|
|
2700
2693
|
}
|
|
@@ -2987,8 +2980,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
2987
2980
|
}
|
|
2988
2981
|
addUpdatedAtColumn(values) {
|
|
2989
2982
|
if (!this.model.usesTimestamps() || this.model.getUpdatedAtColumn() === null) return values;
|
|
2990
|
-
|
|
2991
|
-
values = assign({ [column]: this.model.freshTimestampString() }, values);
|
|
2983
|
+
values = assign({ [this.model.getUpdatedAtColumn()]: this.model.freshTimestampString() }, values);
|
|
2992
2984
|
return values;
|
|
2993
2985
|
}
|
|
2994
2986
|
delete() {
|
|
@@ -3303,10 +3295,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
3303
3295
|
}];
|
|
3304
3296
|
}
|
|
3305
3297
|
related(relation) {
|
|
3306
|
-
if (typeof this.model[getRelationMethod(relation)] !== "function") {
|
|
3307
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
3308
|
-
throw new RelationNotFoundError(message);
|
|
3309
|
-
}
|
|
3298
|
+
if (typeof this.model[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
3310
3299
|
return this.model[getRelationMethod(relation)]();
|
|
3311
3300
|
}
|
|
3312
3301
|
take(...args) {
|
|
@@ -3379,8 +3368,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
3379
3368
|
return await this.whereIn(this.model.getKeyName(), ids).get(columns);
|
|
3380
3369
|
}
|
|
3381
3370
|
async pluck(column) {
|
|
3382
|
-
|
|
3383
|
-
return new collection_default(data);
|
|
3371
|
+
return new collection_default(await this.query.pluck(column));
|
|
3384
3372
|
}
|
|
3385
3373
|
async destroy(ids) {
|
|
3386
3374
|
if (ids instanceof collection_default) ids = ids.modelKeys();
|
|
@@ -3425,10 +3413,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
3425
3413
|
return this.hydrate(await this.query.get()).all();
|
|
3426
3414
|
}
|
|
3427
3415
|
getRelation(name) {
|
|
3428
|
-
if (typeof this.model[getRelationMethod(name)] !== "function") {
|
|
3429
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`;
|
|
3430
|
-
throw new RelationNotFoundError(message);
|
|
3431
|
-
}
|
|
3416
|
+
if (typeof this.model[getRelationMethod(name)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`);
|
|
3432
3417
|
const relation = relation_default.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
|
|
3433
3418
|
const nested = this.relationsNestedUnder(name);
|
|
3434
3419
|
if (Object.keys(nested).length > 0) relation.query.with(nested);
|
|
@@ -4026,10 +4011,7 @@ var MSSQL = class {
|
|
|
4026
4011
|
AND ISNULL([i].[index_column_count], 1) = 1
|
|
4027
4012
|
AND ISNULL([i].[index_priority], 1) = 1`).where({ "s.name": this.schema });
|
|
4028
4013
|
if (table) query.andWhere({ "o.name": table });
|
|
4029
|
-
if (column) {
|
|
4030
|
-
const rawColumn = await query.andWhere({ "c.name": column }).first();
|
|
4031
|
-
return rawColumnToColumn$2(rawColumn);
|
|
4032
|
-
}
|
|
4014
|
+
if (column) return rawColumnToColumn$2(await query.andWhere({ "c.name": column }).first());
|
|
4033
4015
|
return (await query).map(rawColumnToColumn$2);
|
|
4034
4016
|
}
|
|
4035
4017
|
/**
|
|
@@ -4180,10 +4162,7 @@ var MySQL = class {
|
|
|
4180
4162
|
this.on("rc.TABLE_NAME", "=", "fk.TABLE_NAME").andOn("rc.CONSTRAINT_NAME", "=", "fk.CONSTRAINT_NAME").andOn("rc.CONSTRAINT_SCHEMA", "=", "fk.CONSTRAINT_SCHEMA");
|
|
4181
4163
|
}).where({ "c.TABLE_SCHEMA": this.knex.client.database() });
|
|
4182
4164
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
4183
|
-
if (column) {
|
|
4184
|
-
const rawColumn = await query.andWhere({ "c.column_name": column }).first();
|
|
4185
|
-
return rawColumnToColumn$1(rawColumn);
|
|
4186
|
-
}
|
|
4165
|
+
if (column) return rawColumnToColumn$1(await query.andWhere({ "c.column_name": column }).first());
|
|
4187
4166
|
return (await query).map(rawColumnToColumn$1).sort((column$1) => +!column$1.foreign_key_column).filter((column$1, index, records) => {
|
|
4188
4167
|
return records.findIndex((_column) => {
|
|
4189
4168
|
return column$1.name === _column.name && column$1.table === _column.table;
|
|
@@ -4369,10 +4348,7 @@ var oracleDB = class {
|
|
|
4369
4348
|
ON "ct"."R_CONSTRAINT_NAME" = "fk"."CONSTRAINT_NAME"
|
|
4370
4349
|
`)).where({ "c.HIDDEN_COLUMN": "NO" });
|
|
4371
4350
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
4372
|
-
if (column) {
|
|
4373
|
-
const rawColumn = await query.andWhere({ "c.COLUMN_NAME": column }).first();
|
|
4374
|
-
return rawColumnToColumn(rawColumn);
|
|
4375
|
-
}
|
|
4351
|
+
if (column) return rawColumnToColumn(await query.andWhere({ "c.COLUMN_NAME": column }).first());
|
|
4376
4352
|
return (await query).map(rawColumnToColumn);
|
|
4377
4353
|
}
|
|
4378
4354
|
/**
|
|
@@ -4850,8 +4826,7 @@ var SQLite = class {
|
|
|
4850
4826
|
column: column.name
|
|
4851
4827
|
}));
|
|
4852
4828
|
const tables = await this.tables();
|
|
4853
|
-
|
|
4854
|
-
return flatten(columnsPerTable);
|
|
4829
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.columns(table$1))));
|
|
4855
4830
|
}
|
|
4856
4831
|
async columnInfo(table, column) {
|
|
4857
4832
|
const getColumnsForTable = async (table$1) => {
|
|
@@ -4886,8 +4861,7 @@ var SQLite = class {
|
|
|
4886
4861
|
};
|
|
4887
4862
|
if (!table) {
|
|
4888
4863
|
const tables = await this.tables();
|
|
4889
|
-
|
|
4890
|
-
return flatten(columnsPerTable);
|
|
4864
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await getColumnsForTable(table$1))));
|
|
4891
4865
|
}
|
|
4892
4866
|
if (table && !column) return await getColumnsForTable(table);
|
|
4893
4867
|
return (await getColumnsForTable(table)).find((columnInfo) => columnInfo.name === column);
|
|
@@ -4918,8 +4892,7 @@ var SQLite = class {
|
|
|
4918
4892
|
constraint_name: null
|
|
4919
4893
|
}));
|
|
4920
4894
|
const tables = await this.tables();
|
|
4921
|
-
|
|
4922
|
-
return flatten(keysPerTable);
|
|
4895
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.foreignKeys(table$1))));
|
|
4923
4896
|
}
|
|
4924
4897
|
async uniqueConstraints(table) {
|
|
4925
4898
|
if (table) {
|
|
@@ -4935,8 +4908,7 @@ var SQLite = class {
|
|
|
4935
4908
|
});
|
|
4936
4909
|
}
|
|
4937
4910
|
const tables = await this.tables();
|
|
4938
|
-
|
|
4939
|
-
return flatten(constraintsPerTable);
|
|
4911
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.uniqueConstraints(table$1))));
|
|
4940
4912
|
}
|
|
4941
4913
|
};
|
|
4942
4914
|
|
|
@@ -5303,21 +5275,19 @@ var Migrate = class {
|
|
|
5303
5275
|
const getAllMigrationFiles = async () => {
|
|
5304
5276
|
return await migrator.getMigrationFiles(await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path));
|
|
5305
5277
|
};
|
|
5306
|
-
async function getStatusFor(ran
|
|
5278
|
+
async function getStatusFor(ran, batches) {
|
|
5307
5279
|
const files = await getAllMigrationFiles();
|
|
5308
5280
|
return Object.values(files).map((migration) => {
|
|
5309
5281
|
const migrationName = migrator.getMigrationName(migration);
|
|
5310
5282
|
return {
|
|
5311
5283
|
name: migrationName,
|
|
5312
|
-
ran: ran
|
|
5313
|
-
batch: ran
|
|
5284
|
+
ran: ran.includes(migrationName),
|
|
5285
|
+
batch: ran.includes(migrationName) ? batches[migrationName] : null
|
|
5314
5286
|
};
|
|
5315
5287
|
});
|
|
5316
5288
|
}
|
|
5317
5289
|
if (!await migrator.repositoryExists()) this.callback("ERROR: Migration table does not exist.", "error");
|
|
5318
|
-
const
|
|
5319
|
-
const batches = await migrator.getRepository().getMigrationBatches();
|
|
5320
|
-
const migrations = await getStatusFor(ran, batches);
|
|
5290
|
+
const migrations = await getStatusFor(await migrator.repository.getRan(), await migrator.getRepository().getMigrationBatches());
|
|
5321
5291
|
if (destroyAll) await arquebus$1.destroyAll();
|
|
5322
5292
|
return migrations;
|
|
5323
5293
|
}
|
|
@@ -5336,11 +5306,9 @@ var Migrate = class {
|
|
|
5336
5306
|
arquebus_default.addConnection(connection, name);
|
|
5337
5307
|
});
|
|
5338
5308
|
}
|
|
5339
|
-
const repository = new MigrationRepository(arquebus_default, table);
|
|
5340
|
-
const migrator = new migrator_default(repository, arquebus_default);
|
|
5341
5309
|
return {
|
|
5342
5310
|
arquebus: arquebus_default,
|
|
5343
|
-
migrator
|
|
5311
|
+
migrator: new migrator_default(new MigrationRepository(arquebus_default, table), arquebus_default)
|
|
5344
5312
|
};
|
|
5345
5313
|
}
|
|
5346
5314
|
};
|
|
@@ -5443,8 +5411,7 @@ var SeederCreator = class {
|
|
|
5443
5411
|
}
|
|
5444
5412
|
async create(dir, name, type = "js") {
|
|
5445
5413
|
await mkdir(dir, { recursive: true });
|
|
5446
|
-
|
|
5447
|
-
let stub = await readFile(stubPath, "utf-8");
|
|
5414
|
+
let stub = await readFile(this.getStubPath(type), "utf-8");
|
|
5448
5415
|
stub = stub.replace(/{{ name }}/g, name);
|
|
5449
5416
|
const filePath = path.join(dir, `${name}.${type}`);
|
|
5450
5417
|
await writeFile(filePath, stub);
|
package/dist/inspector/index.cjs
CHANGED
|
@@ -30,7 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
let radashi = require("radashi");
|
|
33
|
-
radashi = __toESM(radashi);
|
|
34
33
|
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
35
34
|
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
|
|
36
35
|
let dayjs = require("dayjs");
|
|
@@ -42,9 +41,7 @@ knex = __toESM(knex);
|
|
|
42
41
|
let path = require("path");
|
|
43
42
|
path = __toESM(path);
|
|
44
43
|
let fs = require("fs");
|
|
45
|
-
fs = __toESM(fs);
|
|
46
44
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
47
|
-
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
48
45
|
let pluralize = require("pluralize");
|
|
49
46
|
pluralize = __toESM(pluralize);
|
|
50
47
|
require("node:fs/promises");
|
|
@@ -521,10 +518,7 @@ var MSSQL = class {
|
|
|
521
518
|
AND ISNULL([i].[index_column_count], 1) = 1
|
|
522
519
|
AND ISNULL([i].[index_priority], 1) = 1`).where({ "s.name": this.schema });
|
|
523
520
|
if (table) query.andWhere({ "o.name": table });
|
|
524
|
-
if (column) {
|
|
525
|
-
const rawColumn = await query.andWhere({ "c.name": column }).first();
|
|
526
|
-
return rawColumnToColumn$2(rawColumn);
|
|
527
|
-
}
|
|
521
|
+
if (column) return rawColumnToColumn$2(await query.andWhere({ "c.name": column }).first());
|
|
528
522
|
return (await query).map(rawColumnToColumn$2);
|
|
529
523
|
}
|
|
530
524
|
/**
|
|
@@ -675,10 +669,7 @@ var MySQL = class {
|
|
|
675
669
|
this.on("rc.TABLE_NAME", "=", "fk.TABLE_NAME").andOn("rc.CONSTRAINT_NAME", "=", "fk.CONSTRAINT_NAME").andOn("rc.CONSTRAINT_SCHEMA", "=", "fk.CONSTRAINT_SCHEMA");
|
|
676
670
|
}).where({ "c.TABLE_SCHEMA": this.knex.client.database() });
|
|
677
671
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
678
|
-
if (column) {
|
|
679
|
-
const rawColumn = await query.andWhere({ "c.column_name": column }).first();
|
|
680
|
-
return rawColumnToColumn$1(rawColumn);
|
|
681
|
-
}
|
|
672
|
+
if (column) return rawColumnToColumn$1(await query.andWhere({ "c.column_name": column }).first());
|
|
682
673
|
return (await query).map(rawColumnToColumn$1).sort((column$1) => +!column$1.foreign_key_column).filter((column$1, index, records) => {
|
|
683
674
|
return records.findIndex((_column) => {
|
|
684
675
|
return column$1.name === _column.name && column$1.table === _column.table;
|
|
@@ -864,10 +855,7 @@ var oracleDB = class {
|
|
|
864
855
|
ON "ct"."R_CONSTRAINT_NAME" = "fk"."CONSTRAINT_NAME"
|
|
865
856
|
`)).where({ "c.HIDDEN_COLUMN": "NO" });
|
|
866
857
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
867
|
-
if (column) {
|
|
868
|
-
const rawColumn = await query.andWhere({ "c.COLUMN_NAME": column }).first();
|
|
869
|
-
return rawColumnToColumn(rawColumn);
|
|
870
|
-
}
|
|
858
|
+
if (column) return rawColumnToColumn(await query.andWhere({ "c.COLUMN_NAME": column }).first());
|
|
871
859
|
return (await query).map(rawColumnToColumn);
|
|
872
860
|
}
|
|
873
861
|
/**
|
|
@@ -1754,9 +1742,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1754
1742
|
}
|
|
1755
1743
|
originalIsEquivalent(key) {
|
|
1756
1744
|
if (this.original[key] === void 0) return false;
|
|
1757
|
-
|
|
1758
|
-
const original = this.original[key];
|
|
1759
|
-
if (attribute === original) return true;
|
|
1745
|
+
if (this.attributes[key] === this.original[key]) return true;
|
|
1760
1746
|
else return false;
|
|
1761
1747
|
}
|
|
1762
1748
|
setAttributes(attributes) {
|
|
@@ -1938,8 +1924,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1938
1924
|
return new Date(value);
|
|
1939
1925
|
}
|
|
1940
1926
|
asDate(value) {
|
|
1941
|
-
|
|
1942
|
-
return (0, dayjs.default)(date).startOf("day").toDate();
|
|
1927
|
+
return (0, dayjs.default)(this.asDateTime(value)).startOf("day").toDate();
|
|
1943
1928
|
}
|
|
1944
1929
|
};
|
|
1945
1930
|
};
|
|
@@ -2453,10 +2438,7 @@ const HasRelations = (Model$1) => {
|
|
|
2453
2438
|
return this.relations[relation] !== void 0;
|
|
2454
2439
|
}
|
|
2455
2440
|
related(relation) {
|
|
2456
|
-
if (typeof this[getRelationMethod(relation)] !== "function") {
|
|
2457
|
-
const message = `Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
2458
|
-
throw new RelationNotFoundError(message);
|
|
2459
|
-
}
|
|
2441
|
+
if (typeof this[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
2460
2442
|
return this[getRelationMethod(relation)]();
|
|
2461
2443
|
}
|
|
2462
2444
|
async getRelated(relation) {
|
|
@@ -3957,8 +3939,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
3957
3939
|
return columns.concat(this.aliasedPivotColumns());
|
|
3958
3940
|
}
|
|
3959
3941
|
aliasedPivotColumns() {
|
|
3960
|
-
|
|
3961
|
-
return (0, collect_js.collect)(defaults.concat(this.pivotColumns)).map((column) => {
|
|
3942
|
+
return (0, collect_js.collect)([this.foreignPivotKey, this.relatedPivotKey].concat(this.pivotColumns)).map((column) => {
|
|
3962
3943
|
return this.qualifyPivotColumn(column) + " as pivot_" + column;
|
|
3963
3944
|
}).unique().all();
|
|
3964
3945
|
}
|
|
@@ -4251,8 +4232,7 @@ var Builder = class Builder extends Inference {
|
|
|
4251
4232
|
}
|
|
4252
4233
|
addUpdatedAtColumn(values) {
|
|
4253
4234
|
if (!this.model.usesTimestamps() || this.model.getUpdatedAtColumn() === null) return values;
|
|
4254
|
-
|
|
4255
|
-
values = (0, radashi.assign)({ [column]: this.model.freshTimestampString() }, values);
|
|
4235
|
+
values = (0, radashi.assign)({ [this.model.getUpdatedAtColumn()]: this.model.freshTimestampString() }, values);
|
|
4256
4236
|
return values;
|
|
4257
4237
|
}
|
|
4258
4238
|
delete() {
|
|
@@ -4567,10 +4547,7 @@ var Builder = class Builder extends Inference {
|
|
|
4567
4547
|
}];
|
|
4568
4548
|
}
|
|
4569
4549
|
related(relation) {
|
|
4570
|
-
if (typeof this.model[getRelationMethod(relation)] !== "function") {
|
|
4571
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
4572
|
-
throw new RelationNotFoundError(message);
|
|
4573
|
-
}
|
|
4550
|
+
if (typeof this.model[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
4574
4551
|
return this.model[getRelationMethod(relation)]();
|
|
4575
4552
|
}
|
|
4576
4553
|
take(...args) {
|
|
@@ -4643,8 +4620,7 @@ var Builder = class Builder extends Inference {
|
|
|
4643
4620
|
return await this.whereIn(this.model.getKeyName(), ids).get(columns);
|
|
4644
4621
|
}
|
|
4645
4622
|
async pluck(column) {
|
|
4646
|
-
|
|
4647
|
-
return new collection_default(data);
|
|
4623
|
+
return new collection_default(await this.query.pluck(column));
|
|
4648
4624
|
}
|
|
4649
4625
|
async destroy(ids) {
|
|
4650
4626
|
if (ids instanceof collection_default) ids = ids.modelKeys();
|
|
@@ -4689,10 +4665,7 @@ var Builder = class Builder extends Inference {
|
|
|
4689
4665
|
return this.hydrate(await this.query.get()).all();
|
|
4690
4666
|
}
|
|
4691
4667
|
getRelation(name) {
|
|
4692
|
-
if (typeof this.model[getRelationMethod(name)] !== "function") {
|
|
4693
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`;
|
|
4694
|
-
throw new RelationNotFoundError(message);
|
|
4695
|
-
}
|
|
4668
|
+
if (typeof this.model[getRelationMethod(name)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`);
|
|
4696
4669
|
const relation = relation_default.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
|
|
4697
4670
|
const nested = this.relationsNestedUnder(name);
|
|
4698
4671
|
if (Object.keys(nested).length > 0) relation.query.with(nested);
|
|
@@ -4781,8 +4754,7 @@ var SQLite = class {
|
|
|
4781
4754
|
column: column.name
|
|
4782
4755
|
}));
|
|
4783
4756
|
const tables = await this.tables();
|
|
4784
|
-
|
|
4785
|
-
return flatten(columnsPerTable);
|
|
4757
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.columns(table$1))));
|
|
4786
4758
|
}
|
|
4787
4759
|
async columnInfo(table, column) {
|
|
4788
4760
|
const getColumnsForTable = async (table$1) => {
|
|
@@ -4817,8 +4789,7 @@ var SQLite = class {
|
|
|
4817
4789
|
};
|
|
4818
4790
|
if (!table) {
|
|
4819
4791
|
const tables = await this.tables();
|
|
4820
|
-
|
|
4821
|
-
return flatten(columnsPerTable);
|
|
4792
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await getColumnsForTable(table$1))));
|
|
4822
4793
|
}
|
|
4823
4794
|
if (table && !column) return await getColumnsForTable(table);
|
|
4824
4795
|
return (await getColumnsForTable(table)).find((columnInfo) => columnInfo.name === column);
|
|
@@ -4849,8 +4820,7 @@ var SQLite = class {
|
|
|
4849
4820
|
constraint_name: null
|
|
4850
4821
|
}));
|
|
4851
4822
|
const tables = await this.tables();
|
|
4852
|
-
|
|
4853
|
-
return flatten(keysPerTable);
|
|
4823
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.foreignKeys(table$1))));
|
|
4854
4824
|
}
|
|
4855
4825
|
async uniqueConstraints(table) {
|
|
4856
4826
|
if (table) {
|
|
@@ -4866,8 +4836,7 @@ var SQLite = class {
|
|
|
4866
4836
|
});
|
|
4867
4837
|
}
|
|
4868
4838
|
const tables = await this.tables();
|
|
4869
|
-
|
|
4870
|
-
return flatten(constraintsPerTable);
|
|
4839
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.uniqueConstraints(table$1))));
|
|
4871
4840
|
}
|
|
4872
4841
|
};
|
|
4873
4842
|
|
|
@@ -494,10 +494,7 @@ var MSSQL = class {
|
|
|
494
494
|
AND ISNULL([i].[index_column_count], 1) = 1
|
|
495
495
|
AND ISNULL([i].[index_priority], 1) = 1`).where({ "s.name": this.schema });
|
|
496
496
|
if (table) query.andWhere({ "o.name": table });
|
|
497
|
-
if (column) {
|
|
498
|
-
const rawColumn = await query.andWhere({ "c.name": column }).first();
|
|
499
|
-
return rawColumnToColumn$2(rawColumn);
|
|
500
|
-
}
|
|
497
|
+
if (column) return rawColumnToColumn$2(await query.andWhere({ "c.name": column }).first());
|
|
501
498
|
return (await query).map(rawColumnToColumn$2);
|
|
502
499
|
}
|
|
503
500
|
/**
|
|
@@ -648,10 +645,7 @@ var MySQL = class {
|
|
|
648
645
|
this.on("rc.TABLE_NAME", "=", "fk.TABLE_NAME").andOn("rc.CONSTRAINT_NAME", "=", "fk.CONSTRAINT_NAME").andOn("rc.CONSTRAINT_SCHEMA", "=", "fk.CONSTRAINT_SCHEMA");
|
|
649
646
|
}).where({ "c.TABLE_SCHEMA": this.knex.client.database() });
|
|
650
647
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
651
|
-
if (column) {
|
|
652
|
-
const rawColumn = await query.andWhere({ "c.column_name": column }).first();
|
|
653
|
-
return rawColumnToColumn$1(rawColumn);
|
|
654
|
-
}
|
|
648
|
+
if (column) return rawColumnToColumn$1(await query.andWhere({ "c.column_name": column }).first());
|
|
655
649
|
return (await query).map(rawColumnToColumn$1).sort((column$1) => +!column$1.foreign_key_column).filter((column$1, index, records) => {
|
|
656
650
|
return records.findIndex((_column) => {
|
|
657
651
|
return column$1.name === _column.name && column$1.table === _column.table;
|
|
@@ -837,10 +831,7 @@ var oracleDB = class {
|
|
|
837
831
|
ON "ct"."R_CONSTRAINT_NAME" = "fk"."CONSTRAINT_NAME"
|
|
838
832
|
`)).where({ "c.HIDDEN_COLUMN": "NO" });
|
|
839
833
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
840
|
-
if (column) {
|
|
841
|
-
const rawColumn = await query.andWhere({ "c.COLUMN_NAME": column }).first();
|
|
842
|
-
return rawColumnToColumn(rawColumn);
|
|
843
|
-
}
|
|
834
|
+
if (column) return rawColumnToColumn(await query.andWhere({ "c.COLUMN_NAME": column }).first());
|
|
844
835
|
return (await query).map(rawColumnToColumn);
|
|
845
836
|
}
|
|
846
837
|
/**
|
|
@@ -1727,9 +1718,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1727
1718
|
}
|
|
1728
1719
|
originalIsEquivalent(key) {
|
|
1729
1720
|
if (this.original[key] === void 0) return false;
|
|
1730
|
-
|
|
1731
|
-
const original = this.original[key];
|
|
1732
|
-
if (attribute === original) return true;
|
|
1721
|
+
if (this.attributes[key] === this.original[key]) return true;
|
|
1733
1722
|
else return false;
|
|
1734
1723
|
}
|
|
1735
1724
|
setAttributes(attributes) {
|
|
@@ -1911,8 +1900,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1911
1900
|
return new Date(value);
|
|
1912
1901
|
}
|
|
1913
1902
|
asDate(value) {
|
|
1914
|
-
|
|
1915
|
-
return dayjs(date).startOf("day").toDate();
|
|
1903
|
+
return dayjs(this.asDateTime(value)).startOf("day").toDate();
|
|
1916
1904
|
}
|
|
1917
1905
|
};
|
|
1918
1906
|
};
|
|
@@ -2426,10 +2414,7 @@ const HasRelations = (Model$1) => {
|
|
|
2426
2414
|
return this.relations[relation] !== void 0;
|
|
2427
2415
|
}
|
|
2428
2416
|
related(relation) {
|
|
2429
|
-
if (typeof this[getRelationMethod(relation)] !== "function") {
|
|
2430
|
-
const message = `Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
2431
|
-
throw new RelationNotFoundError(message);
|
|
2432
|
-
}
|
|
2417
|
+
if (typeof this[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
2433
2418
|
return this[getRelationMethod(relation)]();
|
|
2434
2419
|
}
|
|
2435
2420
|
async getRelated(relation) {
|
|
@@ -3930,8 +3915,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
3930
3915
|
return columns.concat(this.aliasedPivotColumns());
|
|
3931
3916
|
}
|
|
3932
3917
|
aliasedPivotColumns() {
|
|
3933
|
-
|
|
3934
|
-
return collect(defaults.concat(this.pivotColumns)).map((column) => {
|
|
3918
|
+
return collect([this.foreignPivotKey, this.relatedPivotKey].concat(this.pivotColumns)).map((column) => {
|
|
3935
3919
|
return this.qualifyPivotColumn(column) + " as pivot_" + column;
|
|
3936
3920
|
}).unique().all();
|
|
3937
3921
|
}
|
|
@@ -4224,8 +4208,7 @@ var Builder = class Builder extends Inference {
|
|
|
4224
4208
|
}
|
|
4225
4209
|
addUpdatedAtColumn(values) {
|
|
4226
4210
|
if (!this.model.usesTimestamps() || this.model.getUpdatedAtColumn() === null) return values;
|
|
4227
|
-
|
|
4228
|
-
values = assign({ [column]: this.model.freshTimestampString() }, values);
|
|
4211
|
+
values = assign({ [this.model.getUpdatedAtColumn()]: this.model.freshTimestampString() }, values);
|
|
4229
4212
|
return values;
|
|
4230
4213
|
}
|
|
4231
4214
|
delete() {
|
|
@@ -4540,10 +4523,7 @@ var Builder = class Builder extends Inference {
|
|
|
4540
4523
|
}];
|
|
4541
4524
|
}
|
|
4542
4525
|
related(relation) {
|
|
4543
|
-
if (typeof this.model[getRelationMethod(relation)] !== "function") {
|
|
4544
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
4545
|
-
throw new RelationNotFoundError(message);
|
|
4546
|
-
}
|
|
4526
|
+
if (typeof this.model[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
4547
4527
|
return this.model[getRelationMethod(relation)]();
|
|
4548
4528
|
}
|
|
4549
4529
|
take(...args) {
|
|
@@ -4616,8 +4596,7 @@ var Builder = class Builder extends Inference {
|
|
|
4616
4596
|
return await this.whereIn(this.model.getKeyName(), ids).get(columns);
|
|
4617
4597
|
}
|
|
4618
4598
|
async pluck(column) {
|
|
4619
|
-
|
|
4620
|
-
return new collection_default(data);
|
|
4599
|
+
return new collection_default(await this.query.pluck(column));
|
|
4621
4600
|
}
|
|
4622
4601
|
async destroy(ids) {
|
|
4623
4602
|
if (ids instanceof collection_default) ids = ids.modelKeys();
|
|
@@ -4662,10 +4641,7 @@ var Builder = class Builder extends Inference {
|
|
|
4662
4641
|
return this.hydrate(await this.query.get()).all();
|
|
4663
4642
|
}
|
|
4664
4643
|
getRelation(name) {
|
|
4665
|
-
if (typeof this.model[getRelationMethod(name)] !== "function") {
|
|
4666
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`;
|
|
4667
|
-
throw new RelationNotFoundError(message);
|
|
4668
|
-
}
|
|
4644
|
+
if (typeof this.model[getRelationMethod(name)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`);
|
|
4669
4645
|
const relation = relation_default.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
|
|
4670
4646
|
const nested = this.relationsNestedUnder(name);
|
|
4671
4647
|
if (Object.keys(nested).length > 0) relation.query.with(nested);
|
|
@@ -4754,8 +4730,7 @@ var SQLite = class {
|
|
|
4754
4730
|
column: column.name
|
|
4755
4731
|
}));
|
|
4756
4732
|
const tables = await this.tables();
|
|
4757
|
-
|
|
4758
|
-
return flatten(columnsPerTable);
|
|
4733
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.columns(table$1))));
|
|
4759
4734
|
}
|
|
4760
4735
|
async columnInfo(table, column) {
|
|
4761
4736
|
const getColumnsForTable = async (table$1) => {
|
|
@@ -4790,8 +4765,7 @@ var SQLite = class {
|
|
|
4790
4765
|
};
|
|
4791
4766
|
if (!table) {
|
|
4792
4767
|
const tables = await this.tables();
|
|
4793
|
-
|
|
4794
|
-
return flatten(columnsPerTable);
|
|
4768
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await getColumnsForTable(table$1))));
|
|
4795
4769
|
}
|
|
4796
4770
|
if (table && !column) return await getColumnsForTable(table);
|
|
4797
4771
|
return (await getColumnsForTable(table)).find((columnInfo) => columnInfo.name === column);
|
|
@@ -4822,8 +4796,7 @@ var SQLite = class {
|
|
|
4822
4796
|
constraint_name: null
|
|
4823
4797
|
}));
|
|
4824
4798
|
const tables = await this.tables();
|
|
4825
|
-
|
|
4826
|
-
return flatten(keysPerTable);
|
|
4799
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.foreignKeys(table$1))));
|
|
4827
4800
|
}
|
|
4828
4801
|
async uniqueConstraints(table) {
|
|
4829
4802
|
if (table) {
|
|
@@ -4839,8 +4812,7 @@ var SQLite = class {
|
|
|
4839
4812
|
});
|
|
4840
4813
|
}
|
|
4841
4814
|
const tables = await this.tables();
|
|
4842
|
-
|
|
4843
|
-
return flatten(constraintsPerTable);
|
|
4815
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.uniqueConstraints(table$1))));
|
|
4844
4816
|
}
|
|
4845
4817
|
};
|
|
4846
4818
|
|