objection 3.1.4 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/model/AjvValidator.js +60 -25
- package/lib/model/Model.js +3 -4
- package/lib/model/graph/ModelGraphNode.js +12 -0
- package/lib/model/modelToJson.js +2 -1
- package/lib/queryBuilder/QueryBuilder.js +156 -45
- package/lib/queryBuilder/QueryBuilderOperationSupport.js +1 -1
- package/lib/queryBuilder/RelationExpression.js +8 -8
- package/lib/queryBuilder/graph/GraphFetcher.js +3 -1
- package/lib/queryBuilder/graph/GraphOptions.js +21 -2
- package/lib/queryBuilder/graph/GraphUpsert.js +30 -0
- package/lib/queryBuilder/graph/delete/GraphDeleteAction.js +20 -14
- package/lib/queryBuilder/graph/insert/GraphInsert.js +6 -0
- package/lib/queryBuilder/graph/insert/GraphInsertAction.js +2 -0
- package/lib/queryBuilder/graph/patch/GraphPatchAction.js +15 -3
- package/lib/queryBuilder/join/RelationJoiner.js +17 -0
- package/lib/queryBuilder/operations/DelegateOperation.js +4 -0
- package/lib/queryBuilder/operations/NoneOperation.js +37 -0
- package/lib/queryBuilder/operations/ObjectionToKnexConvertingOperation.js +5 -0
- package/lib/queryBuilder/operations/UpdateAndFetchOperation.js +20 -0
- package/lib/queryBuilder/operations/eager/EagerOperation.js +3 -5
- package/lib/queryBuilder/operations/eager/JoinEagerOperation.js +8 -2
- package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +15 -3
- package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +8 -2
- package/lib/queryBuilder/transformations/WrapMysqlModifySubqueryTransformation.js +9 -0
- package/lib/relations/RelationProperty.js +7 -3
- package/lib/relations/belongsToOne/BelongsToOneInsertOperation.js +1 -0
- package/lib/relations/belongsToOne/BelongsToOneRelateOperation.js +5 -0
- package/lib/relations/hasMany/HasManyRelateOperation.js +1 -0
- package/lib/relations/manyToMany/relate/ManyToManyRelateOperation.js +6 -0
- package/lib/utils/identifierMapping.js +8 -2
- package/lib/utils/objectUtils.js +9 -5
- package/package.json +17 -13
- package/typings/objection/index.d.ts +77 -39
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "objection",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "An SQL-friendly ORM for Node.js",
|
|
5
5
|
"main": "lib/objection.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "npm run eslint && mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --exclude \"tests/unit/relations/files/**\" && npm run test:typings",
|
|
9
9
|
"test:fast": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail --exclude \"tests/unit/relations/files/**\"",
|
|
10
|
-
"test:typings": "tsc",
|
|
10
|
+
"test:typings": "tsc && prettier --check \"typings/**/*.ts\" \"tests/ts/**/*.ts\"",
|
|
11
11
|
"prettier": "prettier --write \"{examples,lib,tests,testUtils,typings,doc}/**/*.{js,ts}\"",
|
|
12
12
|
"eslint": "eslint --format codeframe \"examples/**/*.js\" \"lib/**/*.js\" \"tests/**/*.js\"",
|
|
13
13
|
"docs:dev": "vuepress dev doc",
|
|
@@ -30,8 +30,12 @@
|
|
|
30
30
|
],
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "git://github.com/
|
|
33
|
+
"url": "git+https://github.com/ditojs/objection.git"
|
|
34
34
|
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/ditojs/objection/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/ditojs/objection",
|
|
35
39
|
"engines": {
|
|
36
40
|
"node": ">=14.0.0"
|
|
37
41
|
},
|
|
@@ -53,28 +57,28 @@
|
|
|
53
57
|
],
|
|
54
58
|
"types": "./typings/objection/index.d.ts",
|
|
55
59
|
"dependencies": {
|
|
56
|
-
"ajv": "^8.
|
|
57
|
-
"ajv-formats": "^
|
|
60
|
+
"ajv": "^8.17.1",
|
|
61
|
+
"ajv-formats": "^3.0.1",
|
|
58
62
|
"db-errors": "^0.2.3"
|
|
59
63
|
},
|
|
60
64
|
"peerDependencies": {
|
|
61
65
|
"knex": ">=1.0.1"
|
|
62
66
|
},
|
|
63
67
|
"devDependencies": {
|
|
64
|
-
"@types/node": "^
|
|
68
|
+
"@types/node": "^22.15.3",
|
|
65
69
|
"chai": "^4.3.10",
|
|
66
70
|
"chai-subset": "^1.6.0",
|
|
67
71
|
"eslint": "^8.54.0",
|
|
68
72
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
69
|
-
"eslint-plugin-prettier": "^5.
|
|
73
|
+
"eslint-plugin-prettier": "^5.3.1",
|
|
70
74
|
"expect.js": "^0.3.1",
|
|
71
|
-
"knex": "^3.0
|
|
72
|
-
"mocha": "^
|
|
75
|
+
"knex": "^3.1.0",
|
|
76
|
+
"mocha": "^11.2.2",
|
|
73
77
|
"mysql": "^2.18.1",
|
|
74
|
-
"pg": "^8.
|
|
75
|
-
"prettier": "3.
|
|
76
|
-
"sqlite3": "^5.1.
|
|
77
|
-
"typescript": ">=5.3
|
|
78
|
+
"pg": "^8.15.6",
|
|
79
|
+
"prettier": "3.9.9",
|
|
80
|
+
"sqlite3": "^5.1.7",
|
|
81
|
+
"typescript": ">=5.8.3",
|
|
78
82
|
"vuepress": "1.9.10"
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -30,6 +30,7 @@ declare namespace Objection {
|
|
|
30
30
|
|
|
31
31
|
const snakeCaseMappers: SnakeCaseMappersFactory;
|
|
32
32
|
const knexSnakeCaseMappers: KnexSnakeCaseMappersFactory;
|
|
33
|
+
const knexIdentifierMapping: KnexIdentifierMappingFactory;
|
|
33
34
|
|
|
34
35
|
const transaction: transaction;
|
|
35
36
|
const initialize: initialize;
|
|
@@ -126,11 +127,13 @@ declare namespace Objection {
|
|
|
126
127
|
| string
|
|
127
128
|
| number
|
|
128
129
|
| boolean
|
|
130
|
+
| bigint
|
|
129
131
|
| Date
|
|
130
132
|
| Buffer
|
|
131
133
|
| string[]
|
|
132
134
|
| number[]
|
|
133
135
|
| boolean[]
|
|
136
|
+
| bigint[]
|
|
134
137
|
| Date[]
|
|
135
138
|
| Buffer[]
|
|
136
139
|
| null;
|
|
@@ -158,10 +161,7 @@ declare namespace Objection {
|
|
|
158
161
|
type AnyModelConstructor = ModelConstructor<Model>;
|
|
159
162
|
type ModifierFunction<QB extends AnyQueryBuilder> = (qb: QB, ...args: any[]) => void;
|
|
160
163
|
type Modifier<QB extends AnyQueryBuilder = AnyQueryBuilder> =
|
|
161
|
-
|
|
162
|
-
| string
|
|
163
|
-
| string[]
|
|
164
|
-
| Record<string, Expression<PrimitiveValue>>;
|
|
164
|
+
ModifierFunction<QB> | string | string[] | Record<string, Expression<PrimitiveValue>>;
|
|
165
165
|
type OrderByDirection = 'asc' | 'desc' | 'ASC' | 'DESC';
|
|
166
166
|
type OrderByNulls = 'first' | 'last';
|
|
167
167
|
|
|
@@ -201,10 +201,10 @@ declare namespace Objection {
|
|
|
201
201
|
*/
|
|
202
202
|
type PartialModelObject<T extends Model> = {
|
|
203
203
|
[K in DataPropertyNames<T>]?: Defined<T[K]> extends Model
|
|
204
|
-
? T[K]
|
|
204
|
+
? T[K] | PartialModelObject<Defined<T[K]>>
|
|
205
205
|
: Defined<T[K]> extends Array<infer I>
|
|
206
206
|
? I extends Model
|
|
207
|
-
? I[]
|
|
207
|
+
? I[] | PartialModelObject<I>[]
|
|
208
208
|
: Expression<T[K]>
|
|
209
209
|
: Expression<T[K]>;
|
|
210
210
|
};
|
|
@@ -216,6 +216,8 @@ declare namespace Objection {
|
|
|
216
216
|
'#dbRef'?: MaybeCompositeId;
|
|
217
217
|
'#ref'?: string;
|
|
218
218
|
'#id'?: string;
|
|
219
|
+
'#unrelate'?: boolean;
|
|
220
|
+
'#delete'?: boolean;
|
|
219
221
|
};
|
|
220
222
|
|
|
221
223
|
/**
|
|
@@ -597,6 +599,7 @@ declare namespace Objection {
|
|
|
597
599
|
|
|
598
600
|
interface WithMethod<QB extends AnyQueryBuilder> {
|
|
599
601
|
(alias: string, expr: CallbackVoid<QB> | AnyQueryBuilder | Raw): QB;
|
|
602
|
+
(alias: string, columns: string[], expr: CallbackVoid<QB> | AnyQueryBuilder | Raw): QB;
|
|
600
603
|
}
|
|
601
604
|
|
|
602
605
|
interface JoinRelatedOptions {
|
|
@@ -612,6 +615,7 @@ declare namespace Objection {
|
|
|
612
615
|
(table: TableRef<QB>, leftCol: ColumnRef, op: Operator, rightCol: ColumnRef): QB;
|
|
613
616
|
(table: TableRef<QB>, leftCol: ColumnRef, rightCol: ColumnRef): QB;
|
|
614
617
|
(table: TableRef<QB>, cb: CallbackVoid<Knex.JoinClause>): QB;
|
|
618
|
+
(table: TableRef<QB>, columns: { [leftCol: string]: ColumnRef }): QB;
|
|
615
619
|
(table: TableRef<QB>, raw: Raw): QB;
|
|
616
620
|
(raw: Raw): QB;
|
|
617
621
|
}
|
|
@@ -624,6 +628,7 @@ declare namespace Objection {
|
|
|
624
628
|
|
|
625
629
|
interface AggregateMethod<QB extends AnyQueryBuilder> {
|
|
626
630
|
(column: ColumnRef): QB;
|
|
631
|
+
(aliasToColumnDict: { [alias: string]: ColumnRef }): QB;
|
|
627
632
|
}
|
|
628
633
|
|
|
629
634
|
interface CountMethod<QB extends AnyQueryBuilder> {
|
|
@@ -655,7 +660,7 @@ declare namespace Objection {
|
|
|
655
660
|
interface FirstMethod {
|
|
656
661
|
<QB extends AnyQueryBuilder>(
|
|
657
662
|
this: QB,
|
|
658
|
-
): QB extends
|
|
663
|
+
): [ResultType<QB>] extends [any[]] ? MaybeSingleQueryBuilder<QB> : QB;
|
|
659
664
|
}
|
|
660
665
|
|
|
661
666
|
type ForIdValue = MaybeCompositeId | AnyQueryBuilder;
|
|
@@ -693,10 +698,11 @@ declare namespace Objection {
|
|
|
693
698
|
}
|
|
694
699
|
|
|
695
700
|
interface TableRefForMethod {
|
|
696
|
-
(
|
|
701
|
+
(modelClassOrTableName: string | AnyModelConstructor): string;
|
|
697
702
|
}
|
|
698
703
|
|
|
699
704
|
interface AliasForMethod<QB extends AnyQueryBuilder> {
|
|
705
|
+
(modelClassOrTableName: string | AnyModelConstructor): string | null;
|
|
700
706
|
(modelClassOrTableName: string | AnyModelConstructor, alias: string): QB;
|
|
701
707
|
}
|
|
702
708
|
|
|
@@ -707,7 +713,7 @@ declare namespace Objection {
|
|
|
707
713
|
interface ReturningMethod {
|
|
708
714
|
<QB extends AnyQueryBuilder>(
|
|
709
715
|
this: QB,
|
|
710
|
-
column: string | Raw | (string | Raw)[],
|
|
716
|
+
column: string | Raw | (string | Raw)[] | readonly (string | Raw)[],
|
|
711
717
|
): QB extends NumberQueryBuilder<QB> ? ArrayQueryBuilder<QB> : QB;
|
|
712
718
|
}
|
|
713
719
|
|
|
@@ -856,6 +862,8 @@ declare namespace Objection {
|
|
|
856
862
|
export class QueryBuilder<M extends Model, R = M[]> implements CatchablePromiseLike<R> {
|
|
857
863
|
static forClass: ForClassMethod;
|
|
858
864
|
|
|
865
|
+
constructor(modelClass: ModelConstructor<M>);
|
|
866
|
+
|
|
859
867
|
select: SelectMethod<this>;
|
|
860
868
|
columns: SelectMethod<this>;
|
|
861
869
|
column: SelectMethod<this>;
|
|
@@ -1031,6 +1039,7 @@ declare namespace Objection {
|
|
|
1031
1039
|
increment: IncrementDecrementMethod<this>;
|
|
1032
1040
|
decrement: IncrementDecrementMethod<this>;
|
|
1033
1041
|
first: FirstMethod;
|
|
1042
|
+
none: IdentityMethod<this>;
|
|
1034
1043
|
|
|
1035
1044
|
orderBy: OrderByMethod<this>;
|
|
1036
1045
|
orderByRaw: OrderByRawMethod<this>;
|
|
@@ -1070,7 +1079,7 @@ declare namespace Objection {
|
|
|
1070
1079
|
insert(insert: PartialModelObject<M>[]): ArrayQueryBuilder<this>;
|
|
1071
1080
|
insert(): SingleQueryBuilder<this>;
|
|
1072
1081
|
|
|
1073
|
-
onConflict(column?:
|
|
1082
|
+
onConflict(column?: ColumnRef | ColumnRef[] | true): this;
|
|
1074
1083
|
ignore(): this;
|
|
1075
1084
|
merge(merge?: PartialModelObject<M> | string[]): this;
|
|
1076
1085
|
|
|
@@ -1091,9 +1100,7 @@ declare namespace Objection {
|
|
|
1091
1100
|
truncate(): Promise<void>;
|
|
1092
1101
|
allowGraph: AllowGraphMethod<this>;
|
|
1093
1102
|
|
|
1094
|
-
throwIfNotFound: (
|
|
1095
|
-
arg?: any,
|
|
1096
|
-
) => R extends Model | undefined ? SingleQueryBuilder<QueryBuilder<M, M>> : this;
|
|
1103
|
+
throwIfNotFound: (arg?: any) => R extends Model | undefined ? SingleQueryBuilder<this> : this;
|
|
1097
1104
|
|
|
1098
1105
|
returning: ReturningMethod;
|
|
1099
1106
|
forUpdate: IdentityMethod<this>;
|
|
@@ -1110,6 +1117,8 @@ declare namespace Objection {
|
|
|
1110
1117
|
modelClass: ModelClassMethod<M>;
|
|
1111
1118
|
tableNameFor: TableRefForMethod;
|
|
1112
1119
|
tableRefFor: TableRefForMethod;
|
|
1120
|
+
tableName(): string;
|
|
1121
|
+
tableRef(): string;
|
|
1113
1122
|
reject: OneArgMethod<any, this>;
|
|
1114
1123
|
resolve: OneArgMethod<any, this>;
|
|
1115
1124
|
transacting: OneArgMethod<TransactionOrKnex, this>;
|
|
@@ -1120,12 +1129,13 @@ declare namespace Objection {
|
|
|
1120
1129
|
toKnexQuery<T extends {} = ModelObject<M>>(): Knex.QueryBuilder<T, T[]>;
|
|
1121
1130
|
knex(knex?: Knex): Knex;
|
|
1122
1131
|
clone(): this;
|
|
1132
|
+
emptyInstance(): this;
|
|
1123
1133
|
|
|
1124
1134
|
page(page: number, pageSize: number): PageQueryBuilder<this>;
|
|
1125
1135
|
range(): PageQueryBuilder<this>;
|
|
1126
1136
|
range(start: number, end: number): PageQueryBuilder<this>;
|
|
1127
|
-
offset(offset: number): this;
|
|
1128
|
-
limit(limit: number): this;
|
|
1137
|
+
offset(offset: number, options?: boolean | { skipBinding?: boolean }): this;
|
|
1138
|
+
limit(limit: number, options?: boolean | { skipBinding?: boolean }): this;
|
|
1129
1139
|
resultSize(): Promise<number>;
|
|
1130
1140
|
|
|
1131
1141
|
runBefore: RunBeforeMethod<this>;
|
|
@@ -1302,6 +1312,7 @@ declare namespace Objection {
|
|
|
1302
1312
|
|
|
1303
1313
|
export interface ToJsonOptions extends CloneOptions {
|
|
1304
1314
|
virtuals?: boolean | string[];
|
|
1315
|
+
format?: Pojo;
|
|
1305
1316
|
}
|
|
1306
1317
|
|
|
1307
1318
|
export interface ValidatorContext {
|
|
@@ -1334,6 +1345,7 @@ declare namespace Objection {
|
|
|
1334
1345
|
upperCase?: boolean;
|
|
1335
1346
|
underscoreBeforeDigits?: boolean;
|
|
1336
1347
|
underscoreBetweenUppercaseLetters?: boolean;
|
|
1348
|
+
noDoubleUnderscores?: boolean;
|
|
1337
1349
|
}
|
|
1338
1350
|
|
|
1339
1351
|
export interface ColumnNameMappers {
|
|
@@ -1354,11 +1366,12 @@ declare namespace Objection {
|
|
|
1354
1366
|
(options?: SnakeCaseMappersOptions): KnexMappers;
|
|
1355
1367
|
}
|
|
1356
1368
|
|
|
1369
|
+
export interface KnexIdentifierMappingFactory {
|
|
1370
|
+
(colToProp: Record<string, string>): KnexMappers;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1357
1373
|
export type ValidationErrorType =
|
|
1358
|
-
| '
|
|
1359
|
-
| 'RelationExpression'
|
|
1360
|
-
| 'UnallowedRelation'
|
|
1361
|
-
| 'InvalidGraph';
|
|
1374
|
+
'ModelValidation' | 'RelationExpression' | 'UnallowedRelation' | 'InvalidGraph';
|
|
1362
1375
|
|
|
1363
1376
|
export class ValidationError extends Error {
|
|
1364
1377
|
constructor(args: CreateValidationErrorArgs & { modelClass?: ModelClass<Model> });
|
|
@@ -1423,22 +1436,39 @@ declare namespace Objection {
|
|
|
1423
1436
|
new (): T;
|
|
1424
1437
|
}
|
|
1425
1438
|
|
|
1439
|
+
interface PrototypeType<T> extends Function {
|
|
1440
|
+
prototype: T;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
interface ConstructorFunctionType<T = any> extends PrototypeType<T> {
|
|
1444
|
+
new (...args: any[]): T;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// for internal use on generic static this deduction, copied from https://github.com/microsoft/TypeScript/issues/5863#issuecomment-1483978415
|
|
1448
|
+
type ConstructorType<T = unknown, Static extends Record<string, any> = PrototypeType<T>> = (
|
|
1449
|
+
ConstructorFunctionType<T> | PrototypeType<T>
|
|
1450
|
+
) & {
|
|
1451
|
+
[Key in keyof Static]: Static[Key];
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1426
1454
|
export interface ModelConstructor<M extends Model> extends Constructor<M> {}
|
|
1427
1455
|
|
|
1428
1456
|
export interface ModelClass<M extends Model> extends ModelConstructor<M> {
|
|
1429
1457
|
QueryBuilder: typeof QueryBuilder;
|
|
1430
1458
|
|
|
1431
1459
|
tableName: string;
|
|
1432
|
-
idColumn: string | string[];
|
|
1460
|
+
idColumn: null | string | string[] | readonly string[];
|
|
1433
1461
|
jsonSchema: JSONSchema;
|
|
1434
1462
|
relationMappings: RelationMappings | RelationMappingsThunk;
|
|
1435
1463
|
modelPaths: string[];
|
|
1436
|
-
jsonAttributes: string[];
|
|
1464
|
+
jsonAttributes: string[] | readonly string[];
|
|
1437
1465
|
virtualAttributes: string[];
|
|
1438
1466
|
uidProp: string;
|
|
1439
1467
|
uidRefProp: string;
|
|
1440
1468
|
dbRefProp: string;
|
|
1441
1469
|
propRefRegex: RegExp;
|
|
1470
|
+
graphUnrelateProp: string;
|
|
1471
|
+
graphDeleteProp: string;
|
|
1442
1472
|
pickJsonSchemaProperties: boolean;
|
|
1443
1473
|
relatedFindQueryMutates: boolean;
|
|
1444
1474
|
relatedInsertQueryMutates: boolean;
|
|
@@ -1473,6 +1503,9 @@ declare namespace Objection {
|
|
|
1473
1503
|
fromJson(json: object, opt?: ModelOptions): M;
|
|
1474
1504
|
fromDatabaseJson(json: object): M;
|
|
1475
1505
|
|
|
1506
|
+
columnNameToPropertyName(columnName: string): string;
|
|
1507
|
+
propertyNameToColumnName(propertyName: string): string;
|
|
1508
|
+
|
|
1476
1509
|
createValidator(): Validator;
|
|
1477
1510
|
createValidationError(args: CreateValidationErrorArgs): Error;
|
|
1478
1511
|
createNotFoundError(queryContext: QueryContext, args: CreateNotFoundErrorArgs): Error;
|
|
@@ -1535,16 +1568,18 @@ declare namespace Objection {
|
|
|
1535
1568
|
static QueryBuilder: typeof QueryBuilder;
|
|
1536
1569
|
|
|
1537
1570
|
static tableName: string;
|
|
1538
|
-
static idColumn: string | string[];
|
|
1571
|
+
static idColumn: null | string | string[] | readonly string[];
|
|
1539
1572
|
static jsonSchema: JSONSchema;
|
|
1540
1573
|
static relationMappings: RelationMappings | RelationMappingsThunk;
|
|
1541
1574
|
static modelPaths: string[];
|
|
1542
|
-
static jsonAttributes: string[];
|
|
1575
|
+
static jsonAttributes: string[] | readonly string[];
|
|
1543
1576
|
static virtualAttributes: string[];
|
|
1544
1577
|
static uidProp: string;
|
|
1545
1578
|
static uidRefProp: string;
|
|
1546
1579
|
static dbRefProp: string;
|
|
1547
1580
|
static propRefRegex: RegExp;
|
|
1581
|
+
static graphUnrelateProp: string;
|
|
1582
|
+
static graphDeleteProp: string;
|
|
1548
1583
|
static pickJsonSchemaProperties: boolean;
|
|
1549
1584
|
static relatedFindQueryMutates: boolean;
|
|
1550
1585
|
static relatedInsertQueryMutates: boolean;
|
|
@@ -1565,12 +1600,12 @@ declare namespace Objection {
|
|
|
1565
1600
|
static defaultGraphOptions?: GraphOptions;
|
|
1566
1601
|
|
|
1567
1602
|
static query<M extends Model>(
|
|
1568
|
-
this:
|
|
1603
|
+
this: ConstructorType<M>,
|
|
1569
1604
|
trxOrKnex?: TransactionOrKnex,
|
|
1570
1605
|
): QueryBuilderType<M>;
|
|
1571
1606
|
|
|
1572
1607
|
static relatedQuery<M extends Model, K extends keyof M>(
|
|
1573
|
-
this:
|
|
1608
|
+
this: ConstructorType<M>,
|
|
1574
1609
|
relationName: K,
|
|
1575
1610
|
trxOrKnex?: TransactionOrKnex,
|
|
1576
1611
|
): ArrayRelatedQueryBuilder<M[K]>;
|
|
@@ -1580,8 +1615,11 @@ declare namespace Objection {
|
|
|
1580
1615
|
trxOrKnex?: TransactionOrKnex,
|
|
1581
1616
|
): QueryBuilderType<RM>;
|
|
1582
1617
|
|
|
1583
|
-
static fromJson<M extends Model>(this:
|
|
1584
|
-
static fromDatabaseJson<M extends Model>(this:
|
|
1618
|
+
static fromJson<M extends Model>(this: ConstructorType<M>, json: object, opt?: ModelOptions): M;
|
|
1619
|
+
static fromDatabaseJson<M extends Model>(this: ConstructorType<M>, json: object): M;
|
|
1620
|
+
|
|
1621
|
+
static columnNameToPropertyName(columnName: string): string;
|
|
1622
|
+
static propertyNameToColumnName(propertyName: string): string;
|
|
1585
1623
|
|
|
1586
1624
|
static createValidator(): Validator;
|
|
1587
1625
|
static createValidationError(args: CreateValidationErrorArgs): Error;
|
|
@@ -1596,7 +1634,7 @@ declare namespace Objection {
|
|
|
1596
1634
|
|
|
1597
1635
|
static transaction<T>(callback: (trx: Transaction) => Promise<T>): Promise<T>;
|
|
1598
1636
|
static transaction<T>(
|
|
1599
|
-
trxOrKnex: TransactionOrKnex,
|
|
1637
|
+
trxOrKnex: TransactionOrKnex | undefined,
|
|
1600
1638
|
callback: (trx: Transaction) => Promise<T>,
|
|
1601
1639
|
): Promise<T>;
|
|
1602
1640
|
|
|
@@ -1604,14 +1642,14 @@ declare namespace Objection {
|
|
|
1604
1642
|
static bindTransaction<M>(this: M, trxOrKnex: TransactionOrKnex): M;
|
|
1605
1643
|
|
|
1606
1644
|
static fetchGraph<M extends Model>(
|
|
1607
|
-
this:
|
|
1645
|
+
this: ConstructorType<M>,
|
|
1608
1646
|
modelOrObject: PartialModelObject<M>,
|
|
1609
1647
|
expression: RelationExpression<M>,
|
|
1610
1648
|
options?: FetchGraphOptions,
|
|
1611
1649
|
): SingleQueryBuilder<QueryBuilderType<M>>;
|
|
1612
1650
|
|
|
1613
1651
|
static fetchGraph<M extends Model>(
|
|
1614
|
-
this:
|
|
1652
|
+
this: ConstructorType<M>,
|
|
1615
1653
|
modelOrObject: PartialModelObject<M>[],
|
|
1616
1654
|
expression: RelationExpression<M>,
|
|
1617
1655
|
options?: FetchGraphOptions,
|
|
@@ -1667,7 +1705,7 @@ declare namespace Objection {
|
|
|
1667
1705
|
$formatDatabaseJson(json: Pojo): Pojo;
|
|
1668
1706
|
$parseDatabaseJson(json: Pojo): Pojo;
|
|
1669
1707
|
|
|
1670
|
-
$formatJson(json: Pojo): Pojo;
|
|
1708
|
+
$formatJson(json: Pojo, opt?: Pojo): Pojo;
|
|
1671
1709
|
$parseJson(json: Pojo, opt?: ModelOptions): Pojo;
|
|
1672
1710
|
|
|
1673
1711
|
$beforeValidate(jsonSchema: JSONSchema, json: Pojo, opt: ModelOptions): JSONSchema;
|
|
@@ -1831,14 +1869,7 @@ declare namespace Objection {
|
|
|
1831
1869
|
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
1832
1870
|
*/
|
|
1833
1871
|
export type JSONSchemaTypeName =
|
|
1834
|
-
| 'string
|
|
1835
|
-
| 'number'
|
|
1836
|
-
| 'integer'
|
|
1837
|
-
| 'boolean'
|
|
1838
|
-
| 'object'
|
|
1839
|
-
| 'array'
|
|
1840
|
-
| 'null'
|
|
1841
|
-
| string;
|
|
1872
|
+
'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null' | string;
|
|
1842
1873
|
|
|
1843
1874
|
export type JSONSchemaType = JSONSchemaArray[] | boolean | number | null | object | string;
|
|
1844
1875
|
|
|
@@ -1870,6 +1901,13 @@ declare namespace Objection {
|
|
|
1870
1901
|
$schema?: JSONSchemaVersion;
|
|
1871
1902
|
$comment?: string;
|
|
1872
1903
|
|
|
1904
|
+
/**
|
|
1905
|
+
* @see https://json-schema.org/draft/2019-09/release-notes
|
|
1906
|
+
*/
|
|
1907
|
+
$defs?: {
|
|
1908
|
+
[key: string]: JSONSchemaDefinition;
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1873
1911
|
/**
|
|
1874
1912
|
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
|
|
1875
1913
|
*/
|