@yandjin-mikro-orm/knex 6.1.4-rc-sti-changes-1
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/AbstractSqlConnection.d.ts +58 -0
- package/AbstractSqlConnection.js +206 -0
- package/AbstractSqlDriver.d.ts +73 -0
- package/AbstractSqlDriver.js +1378 -0
- package/AbstractSqlPlatform.d.ts +25 -0
- package/AbstractSqlPlatform.js +86 -0
- package/LICENSE +21 -0
- package/MonkeyPatchable.d.ts +11 -0
- package/MonkeyPatchable.js +39 -0
- package/PivotCollectionPersister.d.ts +17 -0
- package/PivotCollectionPersister.js +131 -0
- package/README.md +383 -0
- package/SqlEntityManager.d.ts +25 -0
- package/SqlEntityManager.js +40 -0
- package/SqlEntityRepository.d.ts +24 -0
- package/SqlEntityRepository.js +36 -0
- package/index.d.ts +18 -0
- package/index.js +40 -0
- package/index.mjs +215 -0
- package/package.json +71 -0
- package/query/ArrayCriteriaNode.d.ts +10 -0
- package/query/ArrayCriteriaNode.js +25 -0
- package/query/CriteriaNode.d.ts +31 -0
- package/query/CriteriaNode.js +147 -0
- package/query/CriteriaNodeFactory.d.ts +12 -0
- package/query/CriteriaNodeFactory.js +90 -0
- package/query/ObjectCriteriaNode.d.ts +15 -0
- package/query/ObjectCriteriaNode.js +233 -0
- package/query/QueryBuilder.d.ts +291 -0
- package/query/QueryBuilder.js +1445 -0
- package/query/QueryBuilderHelper.d.ts +64 -0
- package/query/QueryBuilderHelper.js +747 -0
- package/query/ScalarCriteriaNode.d.ts +10 -0
- package/query/ScalarCriteriaNode.js +56 -0
- package/query/enums.d.ts +15 -0
- package/query/enums.js +20 -0
- package/query/index.d.ts +8 -0
- package/query/index.js +24 -0
- package/schema/DatabaseSchema.d.ts +29 -0
- package/schema/DatabaseSchema.js +140 -0
- package/schema/DatabaseTable.d.ts +61 -0
- package/schema/DatabaseTable.js +727 -0
- package/schema/SchemaComparator.d.ts +59 -0
- package/schema/SchemaComparator.js +603 -0
- package/schema/SchemaHelper.d.ts +56 -0
- package/schema/SchemaHelper.js +274 -0
- package/schema/SqlSchemaGenerator.d.ts +63 -0
- package/schema/SqlSchemaGenerator.js +598 -0
- package/schema/index.d.ts +5 -0
- package/schema/index.js +21 -0
- package/typings.d.ts +174 -0
- package/typings.js +2 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Knex } from "knex";
|
|
2
|
+
import { Connection, type AnyEntity, type Configuration, type ConnectionOptions, type EntityData, type IsolationLevel, type QueryResult, type Transaction, type TransactionEventBroadcaster, type LoggingOptions } from "@yandjin-mikro-orm/core";
|
|
3
|
+
import type { AbstractSqlPlatform } from "./AbstractSqlPlatform";
|
|
4
|
+
export declare abstract class AbstractSqlConnection extends Connection {
|
|
5
|
+
private static __patched;
|
|
6
|
+
protected platform: AbstractSqlPlatform;
|
|
7
|
+
protected client: Knex;
|
|
8
|
+
constructor(config: Configuration, options?: ConnectionOptions, type?: "read" | "write");
|
|
9
|
+
abstract createKnex(): void;
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
connect(): void | Promise<void>;
|
|
12
|
+
getKnex(): Knex;
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
close(force?: boolean): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
isConnected(): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
checkConnection(): Promise<{
|
|
25
|
+
ok: boolean;
|
|
26
|
+
reason?: string;
|
|
27
|
+
error?: Error;
|
|
28
|
+
}>;
|
|
29
|
+
transactional<T>(cb: (trx: Transaction<Knex.Transaction>) => Promise<T>, options?: {
|
|
30
|
+
isolationLevel?: IsolationLevel;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
ctx?: Knex.Transaction;
|
|
33
|
+
eventBroadcaster?: TransactionEventBroadcaster;
|
|
34
|
+
}): Promise<T>;
|
|
35
|
+
begin(options?: {
|
|
36
|
+
isolationLevel?: IsolationLevel;
|
|
37
|
+
readOnly?: boolean;
|
|
38
|
+
ctx?: Knex.Transaction;
|
|
39
|
+
eventBroadcaster?: TransactionEventBroadcaster;
|
|
40
|
+
}): Promise<Knex.Transaction>;
|
|
41
|
+
commit(ctx: Knex.Transaction, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
|
|
42
|
+
rollback(ctx: Knex.Transaction, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
|
|
43
|
+
execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(queryOrKnex: string | Knex.QueryBuilder | Knex.Raw, params?: unknown[], method?: "all" | "get" | "run", ctx?: Transaction, loggerContext?: LoggingOptions): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Execute raw SQL queries from file
|
|
46
|
+
*/
|
|
47
|
+
loadFile(path: string): Promise<void>;
|
|
48
|
+
protected createKnexClient(type: string): Knex;
|
|
49
|
+
protected getKnexOptions(type: string): Knex.Config;
|
|
50
|
+
private getSql;
|
|
51
|
+
/**
|
|
52
|
+
* do not call `positionBindings` when there are no bindings - it was messing up with
|
|
53
|
+
* already interpolated strings containing `?`, and escaping that was not enough to
|
|
54
|
+
* support edge cases like `\\?` strings (as `positionBindings` was removing the `\\`)
|
|
55
|
+
*/
|
|
56
|
+
private patchKnexClient;
|
|
57
|
+
protected abstract transformRawResult<T>(res: any, method: "all" | "get" | "run"): T;
|
|
58
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractSqlConnection = void 0;
|
|
4
|
+
const knex_1 = require("knex");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const core_1 = require("@yandjin-mikro-orm/core");
|
|
7
|
+
const MonkeyPatchable_1 = require("./MonkeyPatchable");
|
|
8
|
+
const parentTransactionSymbol = Symbol("parentTransaction");
|
|
9
|
+
function isRootTransaction(trx) {
|
|
10
|
+
return !Object.getOwnPropertySymbols(trx).includes(parentTransactionSymbol);
|
|
11
|
+
}
|
|
12
|
+
class AbstractSqlConnection extends core_1.Connection {
|
|
13
|
+
static __patched = false;
|
|
14
|
+
client;
|
|
15
|
+
constructor(config, options, type) {
|
|
16
|
+
super(config, options, type);
|
|
17
|
+
this.patchKnexClient();
|
|
18
|
+
}
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
connect() {
|
|
21
|
+
this.createKnex();
|
|
22
|
+
}
|
|
23
|
+
getKnex() {
|
|
24
|
+
if (!this.client) {
|
|
25
|
+
this.createKnex();
|
|
26
|
+
}
|
|
27
|
+
return this.client;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
async close(force) {
|
|
33
|
+
await super.close(force);
|
|
34
|
+
await this.getKnex().destroy();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
async isConnected() {
|
|
40
|
+
const check = await this.checkConnection();
|
|
41
|
+
return check.ok;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @inheritDoc
|
|
45
|
+
*/
|
|
46
|
+
async checkConnection() {
|
|
47
|
+
try {
|
|
48
|
+
await this.getKnex().raw("select 1");
|
|
49
|
+
return { ok: true };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return { ok: false, reason: error.message, error };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async transactional(cb, options = {}) {
|
|
56
|
+
const trx = await this.begin(options);
|
|
57
|
+
try {
|
|
58
|
+
const ret = await cb(trx);
|
|
59
|
+
await this.commit(trx, options.eventBroadcaster);
|
|
60
|
+
return ret;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
await this.rollback(trx, options.eventBroadcaster);
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async begin(options = {}) {
|
|
68
|
+
if (!options.ctx) {
|
|
69
|
+
await options.eventBroadcaster?.dispatchEvent(core_1.EventType.beforeTransactionStart);
|
|
70
|
+
}
|
|
71
|
+
const trx = await (options.ctx || this.getKnex()).transaction(null, {
|
|
72
|
+
isolationLevel: options.isolationLevel,
|
|
73
|
+
readOnly: options.readOnly,
|
|
74
|
+
});
|
|
75
|
+
if (!options.ctx) {
|
|
76
|
+
await options.eventBroadcaster?.dispatchEvent(core_1.EventType.afterTransactionStart, trx);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
trx[parentTransactionSymbol] =
|
|
80
|
+
options.ctx;
|
|
81
|
+
}
|
|
82
|
+
return trx;
|
|
83
|
+
}
|
|
84
|
+
async commit(ctx, eventBroadcaster) {
|
|
85
|
+
const runTrxHooks = isRootTransaction(ctx);
|
|
86
|
+
if (runTrxHooks) {
|
|
87
|
+
await eventBroadcaster?.dispatchEvent(core_1.EventType.beforeTransactionCommit, ctx);
|
|
88
|
+
}
|
|
89
|
+
ctx.commit();
|
|
90
|
+
await ctx.executionPromise; // https://github.com/knex/knex/issues/3847#issuecomment-626330453
|
|
91
|
+
if (runTrxHooks) {
|
|
92
|
+
await eventBroadcaster?.dispatchEvent(core_1.EventType.afterTransactionCommit, ctx);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async rollback(ctx, eventBroadcaster) {
|
|
96
|
+
const runTrxHooks = isRootTransaction(ctx);
|
|
97
|
+
if (runTrxHooks) {
|
|
98
|
+
await eventBroadcaster?.dispatchEvent(core_1.EventType.beforeTransactionRollback, ctx);
|
|
99
|
+
}
|
|
100
|
+
await ctx.rollback();
|
|
101
|
+
if (runTrxHooks) {
|
|
102
|
+
await eventBroadcaster?.dispatchEvent(core_1.EventType.afterTransactionRollback, ctx);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async execute(queryOrKnex, params = [], method = "all", ctx, loggerContext) {
|
|
106
|
+
await this.ensureConnection();
|
|
107
|
+
if (core_1.Utils.isObject(queryOrKnex)) {
|
|
108
|
+
ctx ??= queryOrKnex.client.transacting ? queryOrKnex : null;
|
|
109
|
+
const q = queryOrKnex.toSQL();
|
|
110
|
+
queryOrKnex = q.sql;
|
|
111
|
+
params = q.bindings;
|
|
112
|
+
}
|
|
113
|
+
const formatted = this.platform.formatQuery(queryOrKnex, params);
|
|
114
|
+
const sql = this.getSql(queryOrKnex, formatted, loggerContext);
|
|
115
|
+
return this.executeQuery(sql, async () => {
|
|
116
|
+
const query = this.getKnex().raw(formatted);
|
|
117
|
+
if (ctx) {
|
|
118
|
+
query.transacting(ctx);
|
|
119
|
+
}
|
|
120
|
+
const res = await query;
|
|
121
|
+
return this.transformRawResult(res, method);
|
|
122
|
+
}, { query: queryOrKnex, params, ...loggerContext });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Execute raw SQL queries from file
|
|
126
|
+
*/
|
|
127
|
+
async loadFile(path) {
|
|
128
|
+
const buf = await (0, fs_extra_1.readFile)(path);
|
|
129
|
+
await this.getKnex().raw(buf.toString());
|
|
130
|
+
}
|
|
131
|
+
createKnexClient(type) {
|
|
132
|
+
const driverOptions = this.config.get("driverOptions");
|
|
133
|
+
if (driverOptions.context?.client instanceof knex_1.knex.Client) {
|
|
134
|
+
this.logger.log("info", "Reusing knex client provided via `driverOptions`");
|
|
135
|
+
return driverOptions;
|
|
136
|
+
}
|
|
137
|
+
return (0, knex_1.knex)(this.getKnexOptions(type)).on("query", (data) => {
|
|
138
|
+
if (!data.__knexQueryUid) {
|
|
139
|
+
this.logQuery(data.sql.toLowerCase().replace(/;$/, ""));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getKnexOptions(type) {
|
|
144
|
+
const config = core_1.Utils.mergeConfig({
|
|
145
|
+
client: type,
|
|
146
|
+
connection: this.getConnectionOptions(),
|
|
147
|
+
pool: this.config.get("pool"),
|
|
148
|
+
}, this.config.get("driverOptions"));
|
|
149
|
+
const options = config.connection;
|
|
150
|
+
const password = options.password;
|
|
151
|
+
if (!(password instanceof Function)) {
|
|
152
|
+
return config;
|
|
153
|
+
}
|
|
154
|
+
config.connection = async () => {
|
|
155
|
+
const pw = await password();
|
|
156
|
+
if (typeof pw === "string") {
|
|
157
|
+
return { ...options, password: pw };
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
...options,
|
|
161
|
+
password: pw.password,
|
|
162
|
+
expirationChecker: pw.expirationChecker,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
return config;
|
|
166
|
+
}
|
|
167
|
+
getSql(query, formatted, context) {
|
|
168
|
+
const logger = this.config.getLogger();
|
|
169
|
+
if (!logger.isEnabled("query", context)) {
|
|
170
|
+
return query;
|
|
171
|
+
}
|
|
172
|
+
if (logger.isEnabled("query-params", context)) {
|
|
173
|
+
return formatted;
|
|
174
|
+
}
|
|
175
|
+
return this.getKnex().client.positionBindings(query);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* do not call `positionBindings` when there are no bindings - it was messing up with
|
|
179
|
+
* already interpolated strings containing `?`, and escaping that was not enough to
|
|
180
|
+
* support edge cases like `\\?` strings (as `positionBindings` was removing the `\\`)
|
|
181
|
+
*/
|
|
182
|
+
patchKnexClient() {
|
|
183
|
+
const { Client, TableCompiler } = MonkeyPatchable_1.MonkeyPatchable;
|
|
184
|
+
const query = Client.prototype.query;
|
|
185
|
+
if (AbstractSqlConnection.__patched) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
AbstractSqlConnection.__patched = true;
|
|
189
|
+
Client.prototype.query = function (connection, obj) {
|
|
190
|
+
if (typeof obj === "string") {
|
|
191
|
+
obj = { sql: obj };
|
|
192
|
+
}
|
|
193
|
+
if ((obj.bindings ?? []).length > 0) {
|
|
194
|
+
return query.call(this, connection, obj);
|
|
195
|
+
}
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
197
|
+
const { __knexUid, __knexTxId } = connection;
|
|
198
|
+
this.emit("query", Object.assign({ __knexUid, __knexTxId }, obj));
|
|
199
|
+
return MonkeyPatchable_1.MonkeyPatchable.QueryExecutioner.executeQuery(connection, obj, this);
|
|
200
|
+
};
|
|
201
|
+
TableCompiler.prototype.raw = function (query) {
|
|
202
|
+
this.pushQuery(query);
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.AbstractSqlConnection = AbstractSqlConnection;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Knex } from "knex";
|
|
2
|
+
import { type AnyEntity, type Collection, type Configuration, type ConnectionType, type Constructor, type CountOptions, DatabaseDriver, type DeleteOptions, type Dictionary, type DriverMethodOptions, type EntityData, type EntityDictionary, type EntityField, EntityManagerType, type EntityMetadata, type EntityName, type EntityProperty, type FilterQuery, type FindOneOptions, type FindOptions, type IDatabaseDriver, type LockOptions, type LoggingOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type ObjectQuery, type Options, type OrderDefinition, type PopulateOptions, type Primary, type QueryOrderMap, type QueryResult, type Transaction, type UpsertManyOptions, type UpsertOptions } from "@yandjin-mikro-orm/core";
|
|
3
|
+
import type { AbstractSqlConnection } from "./AbstractSqlConnection";
|
|
4
|
+
import type { AbstractSqlPlatform } from "./AbstractSqlPlatform";
|
|
5
|
+
import { QueryBuilder, QueryType } from "./query";
|
|
6
|
+
import { SqlEntityManager } from "./SqlEntityManager";
|
|
7
|
+
import type { Field } from "./typings";
|
|
8
|
+
export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlConnection = AbstractSqlConnection, Platform extends AbstractSqlPlatform = AbstractSqlPlatform> extends DatabaseDriver<Connection> {
|
|
9
|
+
[EntityManagerType]: SqlEntityManager<this>;
|
|
10
|
+
protected readonly connection: Connection;
|
|
11
|
+
protected readonly replicas: Connection[];
|
|
12
|
+
protected readonly platform: Platform;
|
|
13
|
+
protected constructor(config: Configuration, platform: Platform, connection: Constructor<Connection>, connector: string[]);
|
|
14
|
+
getPlatform(): Platform;
|
|
15
|
+
createEntityManager<D extends IDatabaseDriver = IDatabaseDriver>(useContext?: boolean): D[typeof EntityManagerType];
|
|
16
|
+
find<T extends object, P extends string = never, F extends string = "*", E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
|
|
17
|
+
findOne<T extends object, P extends string = never, F extends string = "*", E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
|
|
18
|
+
protected hasToManyJoins<T extends object>(hint: PopulateOptions<T>, meta: EntityMetadata<T>): boolean;
|
|
19
|
+
findVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
|
|
20
|
+
countVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: CountOptions<T, any>): Promise<number>;
|
|
21
|
+
protected findFromVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any> | CountOptions<T, any>, type: QueryType): Promise<EntityData<T>[] | number>;
|
|
22
|
+
protected wrapVirtualExpressionInSubquery<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any>, type: QueryType): Promise<T[] | number>;
|
|
23
|
+
mapResult<T extends object>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], qb?: QueryBuilder<T>, map?: Dictionary): EntityData<T> | null;
|
|
24
|
+
private mapJoinedProps;
|
|
25
|
+
count<T extends object>(entityName: string, where: any, options?: CountOptions<T>): Promise<number>;
|
|
26
|
+
nativeInsert<T extends object>(entityName: string, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
27
|
+
nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
|
|
28
|
+
nativeUpdate<T extends object>(entityName: string, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T> & UpsertOptions<T>): Promise<QueryResult<T>>;
|
|
29
|
+
nativeUpdateMany<T extends object>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
|
|
30
|
+
nativeDelete<T extends object>(entityName: string, where: FilterQuery<T> | string | any, options?: DeleteOptions<T>): Promise<QueryResult<T>>;
|
|
31
|
+
syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
|
|
32
|
+
loadFromPivotTable<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where?: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>, pivotJoin?: boolean): Promise<Dictionary<T[]>>;
|
|
33
|
+
private getPivotOrderBy;
|
|
34
|
+
execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(queryOrKnex: string | Knex.QueryBuilder | Knex.Raw, params?: any[], method?: "all" | "get" | "run", ctx?: Transaction, loggerContext?: LoggingOptions): Promise<T>;
|
|
35
|
+
/**
|
|
36
|
+
* 1:1 owner side needs to be marked for population so QB auto-joins the owner id
|
|
37
|
+
*/
|
|
38
|
+
protected autoJoinOneToOneOwner<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], fields?: readonly EntityField<T, any>[]): PopulateOptions<T>[];
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
joinedProps<T>(meta: EntityMetadata, populate: PopulateOptions<T>[], options?: {
|
|
43
|
+
strategy?: Options["loadStrategy"];
|
|
44
|
+
}): PopulateOptions<T>[];
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
mergeJoinedResult<T extends object>(rawResults: EntityData<T>[], meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[]): EntityData<T>[];
|
|
49
|
+
protected getFieldsForJoinedLoad<T extends object>(qb: QueryBuilder<T>, meta: EntityMetadata<T>, explicitFields?: Field<T>[], exclude?: Field<T>[], populate?: PopulateOptions<T>[], options?: {
|
|
50
|
+
strategy?: Options["loadStrategy"];
|
|
51
|
+
populateWhere?: FindOptions<any>["populateWhere"];
|
|
52
|
+
}, parentTableAlias?: string, parentJoinPath?: string): Field<T>[];
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
mapPropToFieldNames<T extends object>(qb: QueryBuilder<T>, prop: EntityProperty<T>, tableAlias?: string): Field<T>[];
|
|
57
|
+
/** @internal */
|
|
58
|
+
createQueryBuilder<T extends object>(entityName: EntityName<T> | QueryBuilder<T>, ctx?: Transaction<Knex.Transaction>, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions): QueryBuilder<T>;
|
|
59
|
+
protected resolveConnectionType(args: {
|
|
60
|
+
ctx?: Transaction<Knex.Transaction>;
|
|
61
|
+
connectionType?: ConnectionType;
|
|
62
|
+
}): ConnectionType;
|
|
63
|
+
protected extractManyToMany<T>(entityName: string, data: EntityDictionary<T>): EntityData<T>;
|
|
64
|
+
protected processManyToMany<T extends object>(meta: EntityMetadata<T> | undefined, pks: Primary<T>[], collections: EntityData<T>, clear: boolean, options?: DriverMethodOptions): Promise<void>;
|
|
65
|
+
lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
|
|
66
|
+
protected buildPopulateWhere<T extends object>(meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[], options: Pick<FindOptions<any>, "populateWhere">): ObjectQuery<T>;
|
|
67
|
+
protected buildOrderBy<T extends object>(qb: QueryBuilder<T>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], options: Pick<FindOptions<any>, "strategy" | "orderBy" | "populateOrderBy">): QueryOrderMap<T>[];
|
|
68
|
+
protected buildPopulateOrderBy<T extends object>(qb: QueryBuilder<T>, meta: EntityMetadata<T>, populateOrderBy: QueryOrderMap<T>[], parentPath: string, explicit: boolean, parentAlias?: string): QueryOrderMap<T>[];
|
|
69
|
+
protected buildJoinedPropsOrderBy<T extends object>(qb: QueryBuilder<T>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], options?: Pick<FindOptions<any>, "strategy" | "orderBy" | "populateOrderBy">, parentPath?: string): QueryOrderMap<T>[];
|
|
70
|
+
protected normalizeFields<T extends object>(fields: Field<T>[], prefix?: string): string[];
|
|
71
|
+
protected processField<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T> | undefined, field: string, ret: Field<T>[], populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: QueryBuilder<T>): void;
|
|
72
|
+
protected buildFields<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: QueryBuilder<T>, alias: string, options: Pick<FindOptions<T, any, any, any>, "strategy" | "fields" | "exclude">): Field<T>[];
|
|
73
|
+
}
|