@mikro-orm/knex 6.0.0-dev.2 → 6.0.0-dev.200
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/AbstractSqlConnection.d.ts → AbstractSqlConnection.d.ts} +8 -4
- package/{dist/AbstractSqlConnection.js → AbstractSqlConnection.js} +35 -18
- package/AbstractSqlDriver.d.ts +73 -0
- package/AbstractSqlDriver.js +1085 -0
- package/AbstractSqlPlatform.d.ts +22 -0
- package/{dist/AbstractSqlPlatform.js → AbstractSqlPlatform.js} +46 -19
- package/{dist/MonkeyPatchable.d.ts → MonkeyPatchable.d.ts} +1 -0
- package/{dist/MonkeyPatchable.js → MonkeyPatchable.js} +3 -0
- package/PivotCollectionPersister.d.ts +17 -0
- package/PivotCollectionPersister.js +128 -0
- package/{dist/README.md → README.md} +66 -109
- package/{dist/SqlEntityManager.d.ts → SqlEntityManager.d.ts} +6 -10
- package/{dist/SqlEntityManager.js → SqlEntityManager.js} +5 -10
- package/SqlEntityRepository.d.ts +24 -0
- package/{dist/SqlEntityRepository.js → SqlEntityRepository.js} +11 -8
- package/{dist/index.d.ts → index.d.ts} +1 -0
- package/{dist/index.js → index.js} +6 -1
- package/index.mjs +211 -0
- package/package.json +20 -49
- package/query/ArrayCriteriaNode.d.ts +10 -0
- package/{dist/query → query}/ArrayCriteriaNode.js +7 -2
- package/{dist/query → query}/CriteriaNode.d.ts +11 -9
- package/{dist/query → query}/CriteriaNode.js +31 -15
- package/query/CriteriaNodeFactory.d.ts +12 -0
- package/{dist/query → query}/CriteriaNodeFactory.js +32 -15
- package/query/ObjectCriteriaNode.d.ts +15 -0
- package/{dist/query → query}/ObjectCriteriaNode.js +68 -21
- package/query/QueryBuilder.d.ts +284 -0
- package/query/QueryBuilder.js +1218 -0
- package/{dist/query → query}/QueryBuilderHelper.d.ts +26 -23
- package/query/QueryBuilderHelper.js +661 -0
- package/query/ScalarCriteriaNode.d.ts +10 -0
- package/{dist/query → query}/ScalarCriteriaNode.js +12 -8
- package/query/enums.d.ts +15 -0
- package/query/enums.js +20 -0
- package/{dist/query → query}/index.js +5 -1
- package/{dist/schema → schema}/DatabaseSchema.d.ts +6 -3
- package/{dist/schema → schema}/DatabaseSchema.js +35 -25
- package/{dist/schema → schema}/DatabaseTable.d.ts +21 -13
- package/schema/DatabaseTable.js +645 -0
- package/{dist/schema → schema}/SchemaComparator.d.ts +9 -7
- package/{dist/schema → schema}/SchemaComparator.js +99 -25
- package/{dist/schema → schema}/SchemaHelper.d.ts +20 -13
- package/{dist/schema → schema}/SchemaHelper.js +70 -18
- package/{dist/schema/SchemaGenerator.d.ts → schema/SqlSchemaGenerator.d.ts} +11 -14
- package/{dist/schema/SchemaGenerator.js → schema/SqlSchemaGenerator.js} +149 -63
- package/{dist/schema → schema}/index.d.ts +1 -1
- package/{dist/schema → schema}/index.js +6 -2
- package/{dist/typings.d.ts → typings.d.ts} +45 -22
- package/CHANGELOG.md +0 -661
- package/dist/AbstractSqlDriver.d.ts +0 -55
- package/dist/AbstractSqlDriver.js +0 -644
- package/dist/AbstractSqlPlatform.d.ts +0 -21
- package/dist/LICENSE +0 -21
- package/dist/SqlEntityRepository.d.ts +0 -23
- package/dist/index.mjs +0 -26
- package/dist/package.json +0 -99
- package/dist/query/ArrayCriteriaNode.d.ts +0 -9
- package/dist/query/CriteriaNodeFactory.d.ts +0 -12
- package/dist/query/ObjectCriteriaNode.d.ts +0 -14
- package/dist/query/QueryBuilder.d.ts +0 -211
- package/dist/query/QueryBuilder.js +0 -688
- package/dist/query/QueryBuilderHelper.js +0 -523
- package/dist/query/ScalarCriteriaNode.d.ts +0 -9
- package/dist/query/enums.d.ts +0 -8
- package/dist/query/enums.js +0 -12
- package/dist/schema/DatabaseTable.js +0 -319
- /package/{dist/query → query}/index.d.ts +0 -0
- /package/{dist/typings.js → typings.js} +0 -0
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Martin Adámek
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
import type { EntityName } from '@mikro-orm/core';
|
|
3
|
-
import { EntityRepository } from '@mikro-orm/core';
|
|
4
|
-
import type { SqlEntityManager } from './SqlEntityManager';
|
|
5
|
-
import type { QueryBuilder } from './query';
|
|
6
|
-
export declare class SqlEntityRepository<T> extends EntityRepository<T> {
|
|
7
|
-
protected readonly _em: SqlEntityManager;
|
|
8
|
-
protected readonly entityName: EntityName<T>;
|
|
9
|
-
constructor(_em: SqlEntityManager, entityName: EntityName<T>);
|
|
10
|
-
/**
|
|
11
|
-
* Creates a QueryBuilder instance
|
|
12
|
-
*/
|
|
13
|
-
createQueryBuilder(alias?: string): QueryBuilder<T>;
|
|
14
|
-
/**
|
|
15
|
-
* Shortcut for `createQueryBuilder()`
|
|
16
|
-
*/
|
|
17
|
-
qb(alias?: string): QueryBuilder<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Returns configured knex instance.
|
|
20
|
-
*/
|
|
21
|
-
getKnex(type?: 'read' | 'write'): Knex;
|
|
22
|
-
protected get em(): SqlEntityManager;
|
|
23
|
-
}
|
package/dist/index.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import mod from "./index.js";
|
|
2
|
-
|
|
3
|
-
export default mod;
|
|
4
|
-
export const AbstractSqlConnection = mod.AbstractSqlConnection;
|
|
5
|
-
export const AbstractSqlDriver = mod.AbstractSqlDriver;
|
|
6
|
-
export const AbstractSqlPlatform = mod.AbstractSqlPlatform;
|
|
7
|
-
export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
|
|
8
|
-
export const CriteriaNode = mod.CriteriaNode;
|
|
9
|
-
export const CriteriaNodeFactory = mod.CriteriaNodeFactory;
|
|
10
|
-
export const DatabaseSchema = mod.DatabaseSchema;
|
|
11
|
-
export const DatabaseTable = mod.DatabaseTable;
|
|
12
|
-
export const EntityManager = mod.EntityManager;
|
|
13
|
-
export const EntityRepository = mod.EntityRepository;
|
|
14
|
-
export const Knex = mod.Knex;
|
|
15
|
-
export const MonkeyPatchable = mod.MonkeyPatchable;
|
|
16
|
-
export const ObjectCriteriaNode = mod.ObjectCriteriaNode;
|
|
17
|
-
export const QueryBuilder = mod.QueryBuilder;
|
|
18
|
-
export const QueryBuilderHelper = mod.QueryBuilderHelper;
|
|
19
|
-
export const QueryType = mod.QueryType;
|
|
20
|
-
export const ScalarCriteriaNode = mod.ScalarCriteriaNode;
|
|
21
|
-
export const SchemaComparator = mod.SchemaComparator;
|
|
22
|
-
export const SchemaGenerator = mod.SchemaGenerator;
|
|
23
|
-
export const SchemaHelper = mod.SchemaHelper;
|
|
24
|
-
export const SqlEntityManager = mod.SqlEntityManager;
|
|
25
|
-
export const SqlEntityRepository = mod.SqlEntityRepository;
|
|
26
|
-
export const knex = mod.knex;
|
package/dist/package.json
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "5.0.0",
|
|
4
|
-
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"module": "index.mjs",
|
|
7
|
-
"typings": "index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./package.json",
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./index.mjs",
|
|
12
|
-
"require": "./index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"orm",
|
|
21
|
-
"mongo",
|
|
22
|
-
"mongodb",
|
|
23
|
-
"mysql",
|
|
24
|
-
"mariadb",
|
|
25
|
-
"postgresql",
|
|
26
|
-
"sqlite",
|
|
27
|
-
"sqlite3",
|
|
28
|
-
"ts",
|
|
29
|
-
"typescript",
|
|
30
|
-
"js",
|
|
31
|
-
"javascript",
|
|
32
|
-
"entity",
|
|
33
|
-
"ddd",
|
|
34
|
-
"mikro-orm",
|
|
35
|
-
"unit-of-work",
|
|
36
|
-
"data-mapper",
|
|
37
|
-
"identity-map"
|
|
38
|
-
],
|
|
39
|
-
"author": "Martin Adámek",
|
|
40
|
-
"license": "MIT",
|
|
41
|
-
"bugs": {
|
|
42
|
-
"url": "https://github.com/mikro-orm/mikro-orm/issues"
|
|
43
|
-
},
|
|
44
|
-
"homepage": "https://mikro-orm.io",
|
|
45
|
-
"engines": {
|
|
46
|
-
"node": ">= 14.0.0"
|
|
47
|
-
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"build": "yarn clean && yarn compile && yarn copy",
|
|
50
|
-
"postbuild": "yarn gen-esm-wrapper index.js index.mjs",
|
|
51
|
-
"clean": "rimraf ./dist",
|
|
52
|
-
"compile": "tsc -p tsconfig.build.json",
|
|
53
|
-
"copy": "ts-node -T ../../scripts/copy.ts"
|
|
54
|
-
},
|
|
55
|
-
"publishConfig": {
|
|
56
|
-
"access": "public"
|
|
57
|
-
},
|
|
58
|
-
"dependencies": {
|
|
59
|
-
"fs-extra": "10.0.0",
|
|
60
|
-
"knex": "1.0.1",
|
|
61
|
-
"sqlstring": "2.3.2"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@mikro-orm/core": "^5.0.0"
|
|
65
|
-
},
|
|
66
|
-
"peerDependencies": {
|
|
67
|
-
"@mikro-orm/core": "^5.0.0",
|
|
68
|
-
"@mikro-orm/entity-generator": "^5.0.0",
|
|
69
|
-
"@mikro-orm/migrations": "^5.0.0",
|
|
70
|
-
"@vscode/sqlite3": "^5.0.0",
|
|
71
|
-
"mssql": "^7.0.0",
|
|
72
|
-
"mysql": "^2.18.1",
|
|
73
|
-
"mysql2": "^2.1.0",
|
|
74
|
-
"pg": "^8.0.3"
|
|
75
|
-
},
|
|
76
|
-
"peerDependenciesMeta": {
|
|
77
|
-
"@mikro-orm/entity-generator": {
|
|
78
|
-
"optional": true
|
|
79
|
-
},
|
|
80
|
-
"@mikro-orm/migrations": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
|
-
"@vscode/sqlite3": {
|
|
84
|
-
"optional": true
|
|
85
|
-
},
|
|
86
|
-
"mssql": {
|
|
87
|
-
"optional": true
|
|
88
|
-
},
|
|
89
|
-
"mysql": {
|
|
90
|
-
"optional": true
|
|
91
|
-
},
|
|
92
|
-
"mysql2": {
|
|
93
|
-
"optional": true
|
|
94
|
-
},
|
|
95
|
-
"pg": {
|
|
96
|
-
"optional": true
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CriteriaNode } from './CriteriaNode';
|
|
2
|
-
import type { IQueryBuilder } from '../typings';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare class ArrayCriteriaNode extends CriteriaNode {
|
|
7
|
-
process<T>(qb: IQueryBuilder<T>, alias?: string): any;
|
|
8
|
-
willAutoJoin<T>(qb: IQueryBuilder<T>, alias?: string): any;
|
|
9
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Dictionary, EntityMetadata, MetadataStorage } from '@mikro-orm/core';
|
|
2
|
-
import type { ICriteriaNode } from '../typings';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare class CriteriaNodeFactory {
|
|
7
|
-
static createNode(metadata: MetadataStorage, entityName: string, payload: any, parent?: ICriteriaNode, key?: string): ICriteriaNode;
|
|
8
|
-
static createScalarNode(metadata: MetadataStorage, entityName: string, payload: any, parent?: ICriteriaNode, key?: string): ICriteriaNode;
|
|
9
|
-
static createArrayNode(metadata: MetadataStorage, entityName: string, payload: any[], parent?: ICriteriaNode, key?: string): ICriteriaNode;
|
|
10
|
-
static createObjectNode(metadata: MetadataStorage, entityName: string, payload: Dictionary, parent?: ICriteriaNode, key?: string): ICriteriaNode;
|
|
11
|
-
static createObjectItemNode(metadata: MetadataStorage, entityName: string, node: ICriteriaNode, payload: Dictionary, item: string, meta?: EntityMetadata): ICriteriaNode;
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CriteriaNode } from './CriteriaNode';
|
|
2
|
-
import type { IQueryBuilder } from '../typings';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare class ObjectCriteriaNode extends CriteriaNode {
|
|
7
|
-
process<T>(qb: IQueryBuilder<T>, alias?: string): any;
|
|
8
|
-
willAutoJoin<T>(qb: IQueryBuilder<T>, alias?: string): boolean;
|
|
9
|
-
shouldInline(payload: any): boolean;
|
|
10
|
-
private inlineChildPayload;
|
|
11
|
-
private shouldAutoJoin;
|
|
12
|
-
private autoJoin;
|
|
13
|
-
private isPrefixed;
|
|
14
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
import type { AnyEntity, Dictionary, EntityData, EntityProperty, RequiredEntityData, GroupOperator, MetadataStorage, PopulateOptions, QBFilterQuery, QueryOrderMap, QueryResult, FlushMode } from '@mikro-orm/core';
|
|
3
|
-
import { LockMode, QueryFlag } from '@mikro-orm/core';
|
|
4
|
-
import { QueryType } from './enums';
|
|
5
|
-
import type { AbstractSqlDriver } from '../AbstractSqlDriver';
|
|
6
|
-
import type { SqlEntityManager } from '../SqlEntityManager';
|
|
7
|
-
import type { Field } from '../typings';
|
|
8
|
-
/**
|
|
9
|
-
* SQL query builder with fluent interface.
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* const qb = orm.em.createQueryBuilder(Publisher);
|
|
13
|
-
* qb.select('*')
|
|
14
|
-
* .where({
|
|
15
|
-
* name: 'test 123',
|
|
16
|
-
* type: PublisherType.GLOBAL,
|
|
17
|
-
* })
|
|
18
|
-
* .orderBy({
|
|
19
|
-
* name: QueryOrder.DESC,
|
|
20
|
-
* type: QueryOrder.ASC,
|
|
21
|
-
* })
|
|
22
|
-
* .limit(2, 1);
|
|
23
|
-
*
|
|
24
|
-
* const publisher = await qb.getSingleResult();
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare class QueryBuilder<T extends AnyEntity<T> = AnyEntity> {
|
|
28
|
-
private readonly entityName;
|
|
29
|
-
private readonly metadata;
|
|
30
|
-
private readonly driver;
|
|
31
|
-
private readonly context?;
|
|
32
|
-
private connectionType?;
|
|
33
|
-
private readonly em?;
|
|
34
|
-
readonly alias: string;
|
|
35
|
-
/** @internal */
|
|
36
|
-
type: QueryType;
|
|
37
|
-
/** @internal */
|
|
38
|
-
_fields?: Field<T>[];
|
|
39
|
-
/** @internal */
|
|
40
|
-
_populate: PopulateOptions<T>[];
|
|
41
|
-
/** @internal */
|
|
42
|
-
_populateMap: Dictionary<string>;
|
|
43
|
-
private aliasCounter;
|
|
44
|
-
private flags;
|
|
45
|
-
private finalized;
|
|
46
|
-
private _joins;
|
|
47
|
-
private _aliasMap;
|
|
48
|
-
private _schema?;
|
|
49
|
-
private _cond;
|
|
50
|
-
private _data;
|
|
51
|
-
private _orderBy;
|
|
52
|
-
private _groupBy;
|
|
53
|
-
private _having;
|
|
54
|
-
private _onConflict?;
|
|
55
|
-
private _limit?;
|
|
56
|
-
private _offset?;
|
|
57
|
-
private _joinedProps;
|
|
58
|
-
private _cache?;
|
|
59
|
-
private _indexHint?;
|
|
60
|
-
private flushMode?;
|
|
61
|
-
private lockMode?;
|
|
62
|
-
private lockTables?;
|
|
63
|
-
private subQueries;
|
|
64
|
-
private innerPromise?;
|
|
65
|
-
private readonly platform;
|
|
66
|
-
private readonly knex;
|
|
67
|
-
private readonly helper;
|
|
68
|
-
/**
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
constructor(entityName: string, metadata: MetadataStorage, driver: AbstractSqlDriver, context?: Knex.Transaction<any, any[]> | undefined, alias?: string, connectionType?: "write" | "read" | undefined, em?: SqlEntityManager<AbstractSqlDriver<import("..").AbstractSqlConnection>> | undefined);
|
|
72
|
-
select(fields: Field<T> | Field<T>[], distinct?: boolean): SelectQueryBuilder<T>;
|
|
73
|
-
addSelect(fields: Field<T> | Field<T>[]): SelectQueryBuilder<T>;
|
|
74
|
-
insert(data: RequiredEntityData<T> | RequiredEntityData<T>[]): InsertQueryBuilder<T>;
|
|
75
|
-
update(data: EntityData<T>): UpdateQueryBuilder<T>;
|
|
76
|
-
delete(cond?: QBFilterQuery): DeleteQueryBuilder<T>;
|
|
77
|
-
truncate(): TruncateQueryBuilder<T>;
|
|
78
|
-
count(field?: string | string[], distinct?: boolean): CountQueryBuilder<T>;
|
|
79
|
-
join(field: string, alias: string, cond?: QBFilterQuery, type?: 'leftJoin' | 'innerJoin' | 'pivotJoin', path?: string): this;
|
|
80
|
-
leftJoin(field: string, alias: string, cond?: QBFilterQuery): this;
|
|
81
|
-
joinAndSelect(field: string, alias: string, cond?: QBFilterQuery, type?: 'leftJoin' | 'innerJoin' | 'pivotJoin', path?: string): this;
|
|
82
|
-
leftJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery): this;
|
|
83
|
-
protected getFieldsForJoinedLoad<U extends AnyEntity<U>>(prop: EntityProperty<U>, alias: string): Field<U>[];
|
|
84
|
-
withSubQuery(subQuery: Knex.QueryBuilder, alias: string): this;
|
|
85
|
-
where(cond: QBFilterQuery<T>, operator?: keyof typeof GroupOperator): this;
|
|
86
|
-
where(cond: string, params?: any[], operator?: keyof typeof GroupOperator): this;
|
|
87
|
-
andWhere(cond: QBFilterQuery<T>): this;
|
|
88
|
-
andWhere(cond: string, params?: any[]): this;
|
|
89
|
-
orWhere(cond: QBFilterQuery<T>): this;
|
|
90
|
-
orWhere(cond: string, params?: any[]): this;
|
|
91
|
-
orderBy(orderBy: QueryOrderMap<unknown> | QueryOrderMap<unknown>[]): this;
|
|
92
|
-
groupBy(fields: (string | keyof T) | readonly (string | keyof T)[]): this;
|
|
93
|
-
having(cond?: QBFilterQuery | string, params?: any[]): this;
|
|
94
|
-
onConflict(fields?: string | string[]): this;
|
|
95
|
-
ignore(): this;
|
|
96
|
-
merge(data?: EntityData<T> | Field<T>[]): this;
|
|
97
|
-
/**
|
|
98
|
-
* @internal
|
|
99
|
-
*/
|
|
100
|
-
populate(populate: PopulateOptions<T>[]): this;
|
|
101
|
-
/**
|
|
102
|
-
* @internal
|
|
103
|
-
*/
|
|
104
|
-
ref(field: string): Knex.Ref<string, {
|
|
105
|
-
[x: string]: string;
|
|
106
|
-
}>;
|
|
107
|
-
raw<R = Knex.Raw>(sql: string, bindings?: Knex.RawBinding[] | Knex.ValueDict): R;
|
|
108
|
-
limit(limit?: number, offset?: number): this;
|
|
109
|
-
offset(offset?: number): this;
|
|
110
|
-
withSchema(schema?: string): this;
|
|
111
|
-
setLockMode(mode?: LockMode, tables?: string[]): this;
|
|
112
|
-
setFlushMode(flushMode?: FlushMode): this;
|
|
113
|
-
setFlag(flag: QueryFlag): this;
|
|
114
|
-
unsetFlag(flag: QueryFlag): this;
|
|
115
|
-
cache(config?: boolean | number | [string, number]): this;
|
|
116
|
-
/**
|
|
117
|
-
* Adds index hint to the FROM clause.
|
|
118
|
-
*/
|
|
119
|
-
indexHint(sql: string): this;
|
|
120
|
-
getKnexQuery(): Knex.QueryBuilder;
|
|
121
|
-
/**
|
|
122
|
-
* Returns the query with parameters as wildcards.
|
|
123
|
-
*/
|
|
124
|
-
getQuery(): string;
|
|
125
|
-
/**
|
|
126
|
-
* Returns the list of all parameters for this query.
|
|
127
|
-
*/
|
|
128
|
-
getParams(): readonly Knex.Value[];
|
|
129
|
-
/**
|
|
130
|
-
* Returns raw interpolated query string with all the parameters inlined.
|
|
131
|
-
*/
|
|
132
|
-
getFormattedQuery(): string;
|
|
133
|
-
getAliasForJoinPath(path?: string): string | undefined;
|
|
134
|
-
getNextAlias(entityName?: string): string;
|
|
135
|
-
/**
|
|
136
|
-
* Executes this QB and returns the raw results, mapped to the property names (unless disabled via last parameter).
|
|
137
|
-
* Use `method` to specify what kind of result you want to get (array/single/meta).
|
|
138
|
-
*/
|
|
139
|
-
execute<U = any>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<U>;
|
|
140
|
-
/**
|
|
141
|
-
* Alias for `qb.getResultList()`
|
|
142
|
-
*/
|
|
143
|
-
getResult(): Promise<T[]>;
|
|
144
|
-
/**
|
|
145
|
-
* Executes the query, returning array of results
|
|
146
|
-
*/
|
|
147
|
-
getResultList(): Promise<T[]>;
|
|
148
|
-
/**
|
|
149
|
-
* Executes the query, returning the first result or null
|
|
150
|
-
*/
|
|
151
|
-
getSingleResult(): Promise<T | null>;
|
|
152
|
-
/**
|
|
153
|
-
* Executes count query (without offset and limit), returning total count of results
|
|
154
|
-
*/
|
|
155
|
-
getCount(field?: string | string[], distinct?: boolean): Promise<number>;
|
|
156
|
-
/**
|
|
157
|
-
* Provides promise-like interface so we can await the QB instance.
|
|
158
|
-
*/
|
|
159
|
-
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<T[] | number | QueryResult<T>>;
|
|
160
|
-
private getInnerPromise;
|
|
161
|
-
/**
|
|
162
|
-
* Returns knex instance with sub-query aliased with given alias.
|
|
163
|
-
* You can provide `EntityName.propName` as alias, then the field name will be used based on the metadata
|
|
164
|
-
*/
|
|
165
|
-
as(alias: string): Knex.QueryBuilder;
|
|
166
|
-
clone(): QueryBuilder<T>;
|
|
167
|
-
getKnex(): Knex.QueryBuilder;
|
|
168
|
-
private joinReference;
|
|
169
|
-
private prepareFields;
|
|
170
|
-
private init;
|
|
171
|
-
private getQueryBase;
|
|
172
|
-
private finalize;
|
|
173
|
-
private wrapPaginateSubQuery;
|
|
174
|
-
private wrapModifySubQuery;
|
|
175
|
-
private autoJoinPivotTable;
|
|
176
|
-
}
|
|
177
|
-
export interface RunQueryBuilder<T> extends Omit<QueryBuilder<T>, 'getResult' | 'getSingleResult' | 'getResultList' | 'where'> {
|
|
178
|
-
where(cond: QBFilterQuery<T> | string, params?: keyof typeof GroupOperator | any[], operator?: keyof typeof GroupOperator): this;
|
|
179
|
-
execute<U = QueryResult<T>>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<U>;
|
|
180
|
-
then<TResult1 = QueryResult<T>, TResult2 = never>(onfulfilled?: ((value: QueryResult<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<QueryResult<T>>;
|
|
181
|
-
}
|
|
182
|
-
export interface SelectQueryBuilder<T> extends QueryBuilder<T> {
|
|
183
|
-
execute<U = T[]>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<U>;
|
|
184
|
-
execute<U = T[]>(method: 'all', mapResults?: boolean): Promise<U>;
|
|
185
|
-
execute<U = T>(method: 'get', mapResults?: boolean): Promise<U>;
|
|
186
|
-
execute<U = QueryResult<T>>(method: 'run', mapResults?: boolean): Promise<U>;
|
|
187
|
-
then<TResult1 = T[], TResult2 = never>(onfulfilled?: ((value: T[]) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<T[]>;
|
|
188
|
-
}
|
|
189
|
-
export interface CountQueryBuilder<T> extends QueryBuilder<T> {
|
|
190
|
-
execute<U = {
|
|
191
|
-
count: number;
|
|
192
|
-
}[]>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<U>;
|
|
193
|
-
execute<U = {
|
|
194
|
-
count: number;
|
|
195
|
-
}[]>(method: 'all', mapResults?: boolean): Promise<U>;
|
|
196
|
-
execute<U = {
|
|
197
|
-
count: number;
|
|
198
|
-
}>(method: 'get', mapResults?: boolean): Promise<U>;
|
|
199
|
-
execute<U = QueryResult<{
|
|
200
|
-
count: number;
|
|
201
|
-
}>>(method: 'run', mapResults?: boolean): Promise<U>;
|
|
202
|
-
then<TResult1 = number, TResult2 = never>(onfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<number>;
|
|
203
|
-
}
|
|
204
|
-
export interface InsertQueryBuilder<T> extends RunQueryBuilder<T> {
|
|
205
|
-
}
|
|
206
|
-
export interface UpdateQueryBuilder<T> extends RunQueryBuilder<T> {
|
|
207
|
-
}
|
|
208
|
-
export interface DeleteQueryBuilder<T> extends RunQueryBuilder<T> {
|
|
209
|
-
}
|
|
210
|
-
export interface TruncateQueryBuilder<T> extends RunQueryBuilder<T> {
|
|
211
|
-
}
|