@mikro-orm/sql 7.0.0-dev.97 → 7.0.0-dev.99

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.
Files changed (91) hide show
  1. package/AbstractSqlConnection.d.ts +57 -0
  2. package/AbstractSqlConnection.js +239 -0
  3. package/AbstractSqlDriver.d.ts +94 -0
  4. package/AbstractSqlDriver.js +1387 -0
  5. package/AbstractSqlPlatform.d.ts +38 -0
  6. package/AbstractSqlPlatform.js +104 -0
  7. package/LICENSE +21 -0
  8. package/PivotCollectionPersister.d.ts +22 -0
  9. package/PivotCollectionPersister.js +159 -0
  10. package/README.md +390 -0
  11. package/SqlEntityManager.d.ts +33 -0
  12. package/SqlEntityManager.js +44 -0
  13. package/SqlEntityRepository.d.ts +19 -0
  14. package/SqlEntityRepository.js +26 -0
  15. package/dialects/index.d.ts +4 -0
  16. package/dialects/index.js +4 -0
  17. package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +14 -0
  18. package/dialects/mssql/MsSqlNativeQueryBuilder.js +200 -0
  19. package/dialects/mssql/index.d.ts +1 -0
  20. package/dialects/mssql/index.js +1 -0
  21. package/dialects/mysql/MySqlExceptionConverter.d.ts +9 -0
  22. package/dialects/mysql/MySqlExceptionConverter.js +80 -0
  23. package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +7 -0
  24. package/dialects/mysql/MySqlNativeQueryBuilder.js +77 -0
  25. package/dialects/mysql/MySqlPlatform.d.ts +45 -0
  26. package/dialects/mysql/MySqlPlatform.js +116 -0
  27. package/dialects/mysql/MySqlSchemaHelper.d.ts +36 -0
  28. package/dialects/mysql/MySqlSchemaHelper.js +269 -0
  29. package/dialects/mysql/index.d.ts +4 -0
  30. package/dialects/mysql/index.js +4 -0
  31. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +5 -0
  32. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +8 -0
  33. package/dialects/postgresql/PostgreSqlTableCompiler.d.ts +1 -0
  34. package/dialects/postgresql/PostgreSqlTableCompiler.js +1 -0
  35. package/dialects/postgresql/index.d.ts +1 -0
  36. package/dialects/postgresql/index.js +1 -0
  37. package/dialects/sqlite/BaseSqliteConnection.d.ts +6 -0
  38. package/dialects/sqlite/BaseSqliteConnection.js +8 -0
  39. package/dialects/sqlite/BaseSqlitePlatform.d.ts +70 -0
  40. package/dialects/sqlite/BaseSqlitePlatform.js +104 -0
  41. package/dialects/sqlite/SqliteExceptionConverter.d.ts +9 -0
  42. package/dialects/sqlite/SqliteExceptionConverter.js +54 -0
  43. package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +6 -0
  44. package/dialects/sqlite/SqliteNativeQueryBuilder.js +11 -0
  45. package/dialects/sqlite/SqliteSchemaHelper.d.ts +38 -0
  46. package/dialects/sqlite/SqliteSchemaHelper.js +379 -0
  47. package/dialects/sqlite/index.d.ts +5 -0
  48. package/dialects/sqlite/index.js +5 -0
  49. package/index.d.ts +19 -0
  50. package/index.js +19 -0
  51. package/package.json +3 -3
  52. package/plugin/index.d.ts +53 -0
  53. package/plugin/index.js +42 -0
  54. package/plugin/transformer.d.ts +115 -0
  55. package/plugin/transformer.js +883 -0
  56. package/query/ArrayCriteriaNode.d.ts +11 -0
  57. package/query/ArrayCriteriaNode.js +24 -0
  58. package/query/CriteriaNode.d.ts +29 -0
  59. package/query/CriteriaNode.js +121 -0
  60. package/query/CriteriaNodeFactory.d.ts +12 -0
  61. package/query/CriteriaNodeFactory.js +90 -0
  62. package/query/NativeQueryBuilder.d.ts +108 -0
  63. package/query/NativeQueryBuilder.js +425 -0
  64. package/query/ObjectCriteriaNode.d.ts +19 -0
  65. package/query/ObjectCriteriaNode.js +249 -0
  66. package/query/QueryBuilder.d.ts +389 -0
  67. package/query/QueryBuilder.js +1558 -0
  68. package/query/QueryBuilderHelper.d.ts +73 -0
  69. package/query/QueryBuilderHelper.js +756 -0
  70. package/query/ScalarCriteriaNode.d.ts +10 -0
  71. package/query/ScalarCriteriaNode.js +49 -0
  72. package/query/enums.d.ts +18 -0
  73. package/query/enums.js +20 -0
  74. package/query/index.d.ts +10 -0
  75. package/query/index.js +10 -0
  76. package/query/raw.d.ts +59 -0
  77. package/query/raw.js +68 -0
  78. package/schema/DatabaseSchema.d.ts +45 -0
  79. package/schema/DatabaseSchema.js +185 -0
  80. package/schema/DatabaseTable.d.ts +68 -0
  81. package/schema/DatabaseTable.js +793 -0
  82. package/schema/SchemaComparator.d.ts +58 -0
  83. package/schema/SchemaComparator.js +577 -0
  84. package/schema/SchemaHelper.d.ts +76 -0
  85. package/schema/SchemaHelper.js +545 -0
  86. package/schema/SqlSchemaGenerator.d.ts +65 -0
  87. package/schema/SqlSchemaGenerator.js +375 -0
  88. package/schema/index.d.ts +5 -0
  89. package/schema/index.js +5 -0
  90. package/typings.d.ts +272 -0
  91. package/typings.js +1 -0
@@ -0,0 +1,389 @@
1
+ import { type AnyEntity, type ConnectionType, type Dictionary, type EntityData, type EntityKey, type EntityManager, type EntityMetadata, type EntityName, type EntityProperty, type ExpandProperty, type FilterOptions, type FlushMode, type GroupOperator, type Loaded, LockMode, type LoggingOptions, type MetadataStorage, type ObjectQuery, PopulateHint, type PopulateOptions, type QBFilterQuery, type QBQueryOrderMap, QueryFlag, type QueryOrderMap, type QueryResult, RawQueryFragment, type RequiredEntityData, type Transaction } from '@mikro-orm/core';
2
+ import { JoinType, QueryType } from './enums.js';
3
+ import type { AbstractSqlDriver } from '../AbstractSqlDriver.js';
4
+ import { type Alias, type OnConflictClause, QueryBuilderHelper } from './QueryBuilderHelper.js';
5
+ import type { SqlEntityManager } from '../SqlEntityManager.js';
6
+ import type { Field, ICriteriaNodeProcessOptions, JoinOptions } from '../typings.js';
7
+ import type { AbstractSqlPlatform } from '../AbstractSqlPlatform.js';
8
+ import { NativeQueryBuilder } from './NativeQueryBuilder.js';
9
+ export interface ExecuteOptions {
10
+ mapResults?: boolean;
11
+ mergeResults?: boolean;
12
+ }
13
+ export interface QBStreamOptions {
14
+ /**
15
+ * Results are mapped to entities, if you set `mapResults: false` you will get POJOs instead.
16
+ *
17
+ * @default true
18
+ */
19
+ mapResults?: boolean;
20
+ /**
21
+ * When populating to-many relations, the ORM streams fully merged entities instead of yielding every row.
22
+ * You can opt out of this behavior by specifying `mergeResults: false`. This will yield every row from
23
+ * the SQL result, but still mapped to entities, meaning that to-many collections will contain at most
24
+ * one item, and you will get duplicate root entities when they have multiple items in the populated
25
+ * collection.
26
+ *
27
+ * @default true
28
+ */
29
+ mergeResults?: boolean;
30
+ /**
31
+ * When enabled, the driver will return the raw database results without renaming the fields to match the entity property names.
32
+ *
33
+ * @default false
34
+ */
35
+ rawResults?: boolean;
36
+ }
37
+ type AnyString = string & {};
38
+ type Compute<T> = {
39
+ [K in keyof T]: T[K];
40
+ } & {};
41
+ type IsNever<T, True = true, False = false> = [T] extends [never] ? True : False;
42
+ type GetAlias<T extends string> = T extends `${infer A}.${string}` ? A : never;
43
+ type GetPropName<T extends string> = T extends `${string}.${infer P}` ? P : T;
44
+ type AppendToHint<Parent extends string, Child extends string> = `${Parent}.${Child}`;
45
+ type AddToContext<Type extends object, Context, Field extends string, Alias extends string, Select extends boolean> = {
46
+ [K in Alias]: [GetPath<Context, Field>, K, ExpandProperty<Type[GetPropName<Field> & keyof Type]>, Select];
47
+ };
48
+ type GetPath<Context, Field extends string> = GetAlias<Field> extends infer Alias ? IsNever<Alias> extends true ? GetPropName<Field> : Alias extends keyof Context ? Context[Alias] extends [infer Path, ...any[]] ? AppendToHint<Path & string, GetPropName<Field>> : GetPropName<Field> : GetPropName<Field> : GetPropName<Field>;
49
+ type GetType<Type extends object, Context, Field extends string> = GetAlias<Field> extends infer Alias ? IsNever<Alias> extends true ? Type : Alias extends keyof Context ? Context[Alias] extends [string, string, infer PropType] ? PropType & object : Type : Type : Type;
50
+ type AddToHint<RootAlias, Context, Field extends string, Select extends boolean = false> = Select extends true ? GetAlias<Field> extends infer Alias ? IsNever<Alias> extends true ? GetPropName<Field> : Alias extends RootAlias ? GetPropName<Field> : Alias extends keyof Context ? Context[Alias] extends [infer Path, ...any[]] ? AppendToHint<Path & string, GetPropName<Field>> : GetPropName<Field> : GetPropName<Field> : GetPropName<Field> : never;
51
+ export type ModifyHint<RootAlias, Context, Hint extends string, Field extends string, Select extends boolean = false> = Hint | AddToHint<RootAlias, Context, Field, Select>;
52
+ export type ModifyContext<Entity extends object, Context, Field extends string, Alias extends string, Select extends boolean = false> = Compute<IsNever<Context> extends true ? AddToContext<GetType<Entity, object, Field>, object, Field, Alias, Select> : Context & AddToContext<GetType<Entity, Context, Field>, Context, Field, Alias, Select>>;
53
+ type EntityRelations<T> = EntityKey<T, true>;
54
+ type AddAliasesFromContext<Context> = Context[keyof Context] extends infer Join ? Join extends any ? Join extends [string, infer Alias, infer Type, any] ? `${Alias & string}.${EntityRelations<Type & {}>}` : never : never : never;
55
+ export type QBField<Entity, RootAlias extends string, Context> = (EntityRelations<Entity> | `${RootAlias}.${EntityRelations<Entity>}` | AddAliasesFromContext<Context>) & {} | AnyString;
56
+ type EntityKeyOrString<Entity extends object = AnyEntity> = AnyString | keyof Entity;
57
+ /**
58
+ * SQL query builder with fluent interface.
59
+ *
60
+ * ```ts
61
+ * const qb = orm.em.createQueryBuilder(Publisher);
62
+ * qb.select('*')
63
+ * .where({
64
+ * name: 'test 123',
65
+ * type: PublisherType.GLOBAL,
66
+ * })
67
+ * .orderBy({
68
+ * name: QueryOrder.DESC,
69
+ * type: QueryOrder.ASC,
70
+ * })
71
+ * .limit(2, 1);
72
+ *
73
+ * const publisher = await qb.getSingleResult();
74
+ * ```
75
+ */
76
+ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias extends string = never, Hint extends string = never, Context extends object = never> {
77
+ protected readonly metadata: MetadataStorage;
78
+ protected readonly driver: AbstractSqlDriver;
79
+ protected readonly context?: Transaction | undefined;
80
+ protected connectionType?: ConnectionType | undefined;
81
+ protected em?: SqlEntityManager | undefined;
82
+ protected loggerContext?: (LoggingOptions & Dictionary) | undefined;
83
+ get mainAlias(): Alias<Entity>;
84
+ get alias(): string;
85
+ get helper(): QueryBuilderHelper;
86
+ get type(): QueryType;
87
+ /** @internal */
88
+ _type?: QueryType;
89
+ /** @internal */
90
+ _fields?: Field<Entity>[];
91
+ /** @internal */
92
+ _populate: PopulateOptions<Entity>[];
93
+ /** @internal */
94
+ _populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
95
+ /** @internal */
96
+ _populateFilter?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
97
+ /** @internal */
98
+ __populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
99
+ /** @internal */
100
+ _populateMap: Dictionary<string>;
101
+ /** @internal */
102
+ readonly rawFragments: Set<string>;
103
+ protected aliasCounter: number;
104
+ protected flags: Set<QueryFlag>;
105
+ protected finalized: boolean;
106
+ protected populateHintFinalized: boolean;
107
+ protected _joins: Dictionary<JoinOptions>;
108
+ protected _explicitAlias: boolean;
109
+ protected _schema?: string;
110
+ protected _cond: Dictionary;
111
+ protected _data: Dictionary;
112
+ protected _orderBy: QueryOrderMap<Entity>[];
113
+ protected _groupBy: Field<Entity>[];
114
+ protected _having: Dictionary;
115
+ protected _returning?: Field<Entity>[];
116
+ protected _onConflict?: OnConflictClause<Entity>[];
117
+ protected _limit?: number;
118
+ protected _offset?: number;
119
+ protected _distinctOn?: string[];
120
+ protected _joinedProps: Map<string, PopulateOptions<any>>;
121
+ protected _cache?: boolean | number | [string, number];
122
+ protected _indexHint?: string;
123
+ protected _comments: string[];
124
+ protected _hintComments: string[];
125
+ protected flushMode?: FlushMode;
126
+ protected lockMode?: LockMode;
127
+ protected lockTables?: string[];
128
+ protected subQueries: Dictionary<string>;
129
+ protected _mainAlias?: Alias<Entity>;
130
+ protected _aliases: Dictionary<Alias<any>>;
131
+ protected _helper?: QueryBuilderHelper;
132
+ protected _query?: {
133
+ sql?: string;
134
+ params?: readonly unknown[];
135
+ qb: NativeQueryBuilder;
136
+ };
137
+ protected readonly platform: AbstractSqlPlatform;
138
+ /**
139
+ * @internal
140
+ */
141
+ constructor(entityName: EntityName<Entity> | QueryBuilder<Entity, any, any>, metadata: MetadataStorage, driver: AbstractSqlDriver, context?: Transaction | undefined, alias?: string, connectionType?: ConnectionType | undefined, em?: SqlEntityManager | undefined, loggerContext?: (LoggingOptions & Dictionary) | undefined);
142
+ select(fields: Field<Entity> | Field<Entity>[], distinct?: boolean): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
143
+ addSelect(fields: Field<Entity> | Field<Entity>[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
144
+ distinct(): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
145
+ /** postgres only */
146
+ distinctOn(fields: EntityKeyOrString<Entity> | EntityKeyOrString<Entity>[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
147
+ insert(data: RequiredEntityData<Entity> | RequiredEntityData<Entity>[]): InsertQueryBuilder<Entity>;
148
+ update(data: EntityData<Entity>): UpdateQueryBuilder<Entity>;
149
+ delete(cond?: QBFilterQuery): DeleteQueryBuilder<Entity>;
150
+ truncate(): TruncateQueryBuilder<Entity>;
151
+ count(field?: EntityKeyOrString<Entity> | EntityKeyOrString<Entity>[], distinct?: boolean): CountQueryBuilder<Entity>;
152
+ join<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | RawQueryFragment | QueryBuilder<any>, alias: Alias, cond?: QBFilterQuery, type?: JoinType, path?: string, schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field> & {}, ModifyContext<Entity, Context, Field, Alias>>;
153
+ innerJoin<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | RawQueryFragment | QueryBuilder<any>, alias: Alias, cond?: QBFilterQuery, schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field> & {}, ModifyContext<Entity, Context, Field, Alias>>;
154
+ innerJoinLateral(field: RawQueryFragment | QueryBuilder<any>, alias: string, cond: QBFilterQuery, schema?: string): this;
155
+ leftJoin<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | RawQueryFragment | QueryBuilder<any>, alias: Alias, cond?: QBFilterQuery, schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field> & {}, ModifyContext<Entity, Context, Field, Alias>>;
156
+ leftJoinLateral(field: RawQueryFragment | QueryBuilder<any>, alias: string, cond: QBFilterQuery, schema?: string): this;
157
+ joinAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | [field: Field, qb: RawQueryFragment | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, type?: JoinType, path?: string, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
158
+ leftJoinAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | [field: Field, qb: RawQueryFragment | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
159
+ leftJoinLateralAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: [field: Field, qb: RawQueryFragment | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
160
+ innerJoinAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | [field: Field, qb: RawQueryFragment | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
161
+ innerJoinLateralAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: [field: Field, qb: RawQueryFragment | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
162
+ protected getFieldsForJoinedLoad(prop: EntityProperty<Entity>, alias: string, explicitFields?: string[]): Field<Entity>[];
163
+ /**
164
+ * Apply filters to the QB where condition.
165
+ */
166
+ applyFilters(filterOptions?: FilterOptions): Promise<void>;
167
+ private readonly autoJoinedPaths;
168
+ /**
169
+ * @internal
170
+ */
171
+ scheduleFilterCheck(path: string): void;
172
+ /**
173
+ * @internal
174
+ */
175
+ applyJoinedFilters(em: EntityManager, filterOptions: FilterOptions | undefined): Promise<void>;
176
+ withSubQuery(subQuery: RawQueryFragment | NativeQueryBuilder, alias: string): this;
177
+ where(cond: QBFilterQuery<Entity>, operator?: keyof typeof GroupOperator): this;
178
+ where(cond: string, params?: any[], operator?: keyof typeof GroupOperator): this;
179
+ andWhere(cond: QBFilterQuery<Entity>): this;
180
+ andWhere(cond: string, params?: any[]): this;
181
+ orWhere(cond: QBFilterQuery<Entity>): this;
182
+ orWhere(cond: string, params?: any[]): this;
183
+ orderBy(orderBy: QBQueryOrderMap<Entity> | QBQueryOrderMap<Entity>[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
184
+ andOrderBy(orderBy: QBQueryOrderMap<Entity> | QBQueryOrderMap<Entity>[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
185
+ private processOrderBy;
186
+ groupBy(fields: EntityKeyOrString<Entity> | readonly EntityKeyOrString<Entity>[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
187
+ having(cond?: QBFilterQuery | string, params?: any[], operator?: keyof typeof GroupOperator): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
188
+ andHaving(cond?: QBFilterQuery | string, params?: any[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
189
+ orHaving(cond?: QBFilterQuery | string, params?: any[]): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
190
+ onConflict(fields?: Field<Entity> | Field<Entity>[]): InsertQueryBuilder<Entity>;
191
+ ignore(): this;
192
+ merge(data?: EntityData<Entity> | Field<Entity>[]): this;
193
+ returning(fields?: Field<Entity> | Field<Entity>[]): this;
194
+ /**
195
+ * @internal
196
+ */
197
+ populate(populate: PopulateOptions<Entity>[], populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`, populateFilter?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`): this;
198
+ limit(limit?: number, offset?: number): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
199
+ offset(offset?: number): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
200
+ withSchema(schema?: string): this;
201
+ setLockMode(mode?: LockMode, tables?: string[]): this;
202
+ setFlushMode(flushMode?: FlushMode): this;
203
+ setFlag(flag: QueryFlag): this;
204
+ unsetFlag(flag: QueryFlag): this;
205
+ hasFlag(flag: QueryFlag): boolean;
206
+ cache(config?: boolean | number | [string, number]): this;
207
+ /**
208
+ * Adds index hint to the FROM clause.
209
+ */
210
+ indexHint(sql: string | undefined): this;
211
+ /**
212
+ * Prepend comment to the sql query using the syntax `/* ... *&#8205;/`. Some characters are forbidden such as `/*, *&#8205;/` and `?`.
213
+ */
214
+ comment(comment: string | string[] | undefined): this;
215
+ /**
216
+ * Add hints to the query using comment-like syntax `/*+ ... *&#8205;/`. MySQL and Oracle use this syntax for optimizer hints.
217
+ * Also various DB proxies and routers use this syntax to pass hints to alter their behavior. In other dialects the hints
218
+ * are ignored as simple comments.
219
+ */
220
+ hintComment(comment: string | string[] | undefined): this;
221
+ /**
222
+ * Specifies FROM which entity's table select/update/delete will be executed, removing all previously set FROM-s.
223
+ * Allows setting a main string alias of the selection data.
224
+ */
225
+ from<Entity extends AnyEntity<Entity> = AnyEntity>(target: QueryBuilder<Entity>, aliasName?: string): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
226
+ from<Entity extends AnyEntity<Entity> = AnyEntity>(target: EntityName<Entity>): SelectQueryBuilder<Entity, RootAlias, Hint, Context>;
227
+ getNativeQuery(processVirtualEntity?: boolean): NativeQueryBuilder;
228
+ /**
229
+ * @internal
230
+ */
231
+ clearRawFragmentsCache(): void;
232
+ /**
233
+ * Returns the query with parameters as wildcards.
234
+ */
235
+ getQuery(): string;
236
+ /**
237
+ * Returns raw fragment representation of this QueryBuilder.
238
+ */
239
+ toRaw(): RawQueryFragment;
240
+ toQuery(): {
241
+ sql: string;
242
+ params: readonly unknown[];
243
+ };
244
+ /**
245
+ * Returns the list of all parameters for this query.
246
+ */
247
+ getParams(): readonly unknown[];
248
+ /**
249
+ * Returns raw interpolated query string with all the parameters inlined.
250
+ */
251
+ getFormattedQuery(): string;
252
+ /**
253
+ * @internal
254
+ */
255
+ getAliasForJoinPath(path?: string | JoinOptions, options?: ICriteriaNodeProcessOptions): string | undefined;
256
+ /**
257
+ * @internal
258
+ */
259
+ getJoinForPath(path: string, options?: ICriteriaNodeProcessOptions): JoinOptions | undefined;
260
+ /**
261
+ * @internal
262
+ */
263
+ getNextAlias(entityName?: string): string;
264
+ /**
265
+ * @internal
266
+ */
267
+ getAliasMap(): Dictionary<string>;
268
+ /**
269
+ * Executes this QB and returns the raw results, mapped to the property names (unless disabled via last parameter).
270
+ * Use `method` to specify what kind of result you want to get (array/single/meta).
271
+ */
272
+ execute<U = any>(method?: 'all' | 'get' | 'run', options?: ExecuteOptions | boolean): Promise<U>;
273
+ private getConnection;
274
+ /**
275
+ * Executes the query and returns an async iterable (async generator) that yields results one by one.
276
+ * By default, the results are merged and mapped to entity instances, without adding them to the identity map.
277
+ * You can disable merging and mapping by passing the options `{ mergeResults: false, mapResults: false }`.
278
+ * This is useful for processing large datasets without loading everything into memory at once.
279
+ *
280
+ * ```ts
281
+ * const qb = em.createQueryBuilder(Book, 'b');
282
+ * qb.select('*').where({ title: '1984' }).leftJoinAndSelect('b.author', 'a');
283
+ *
284
+ * for await (const book of qb.stream()) {
285
+ * // book is an instance of Book entity
286
+ * console.log(book.title, book.author.name);
287
+ * }
288
+ * ```
289
+ */
290
+ stream(options?: QBStreamOptions): AsyncIterableIterator<Loaded<Entity, Hint>>;
291
+ /**
292
+ * Alias for `qb.getResultList()`
293
+ */
294
+ getResult(): Promise<Loaded<Entity, Hint>[]>;
295
+ /**
296
+ * Executes the query, returning array of results mapped to entity instances.
297
+ */
298
+ getResultList(limit?: number): Promise<Loaded<Entity, Hint>[]>;
299
+ private propagatePopulateHint;
300
+ private mapResult;
301
+ private mapResults;
302
+ /**
303
+ * Executes the query, returning the first result or null
304
+ */
305
+ getSingleResult(): Promise<Entity | null>;
306
+ /**
307
+ * Executes count query (without offset and limit), returning total count of results
308
+ */
309
+ getCount(field?: EntityKeyOrString<Entity> | EntityKeyOrString<Entity>[], distinct?: boolean): Promise<number>;
310
+ /**
311
+ * Executes the query, returning both array of results and total count query (without offset and limit).
312
+ */
313
+ getResultAndCount(): Promise<[Entity[], number]>;
314
+ /**
315
+ * Returns native query builder instance with sub-query aliased with given alias.
316
+ * You can provide `EntityName.propName` as alias, then the field name will be used based on the metadata
317
+ */
318
+ as(alias: string): NativeQueryBuilder;
319
+ clone(reset?: boolean | string[]): QueryBuilder<Entity>;
320
+ /**
321
+ * Sets logger context for this query builder.
322
+ */
323
+ setLoggerContext(context: LoggingOptions & Dictionary): void;
324
+ /**
325
+ * Gets logger context for this query builder.
326
+ */
327
+ getLoggerContext<T extends Dictionary & LoggingOptions = Dictionary>(): T;
328
+ private fromVirtual;
329
+ private joinReference;
330
+ protected prepareFields<T>(fields: Field<T>[], type?: 'where' | 'groupBy' | 'sub-query'): (string | RawQueryFragment)[];
331
+ private init;
332
+ private getQueryBase;
333
+ private applyDiscriminatorCondition;
334
+ private finalize;
335
+ /** @internal */
336
+ processPopulateHint(): void;
337
+ private processPopulateWhere;
338
+ private mergeOnConditions;
339
+ /**
340
+ * When adding an inner join on a left joined relation, we need to nest them,
341
+ * otherwise the inner join could discard rows of the root table.
342
+ */
343
+ private processNestedJoins;
344
+ private hasToManyJoins;
345
+ protected wrapPaginateSubQuery(meta: EntityMetadata): void;
346
+ private pruneExtraJoins;
347
+ private wrapModifySubQuery;
348
+ private getSchema;
349
+ private createAlias;
350
+ private createMainAlias;
351
+ private fromSubQuery;
352
+ private fromEntityName;
353
+ private createQueryBuilderHelper;
354
+ private ensureFromClause;
355
+ private ensureNotFinalized;
356
+ }
357
+ export interface RunQueryBuilder<Entity extends object> extends Omit<QueryBuilder<Entity, any, any>, 'getResult' | 'getSingleResult' | 'getResultList' | 'where'> {
358
+ where(cond: QBFilterQuery<Entity> | string, params?: keyof typeof GroupOperator | any[], operator?: keyof typeof GroupOperator): this;
359
+ execute<Result = QueryResult<Entity>>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<Result>;
360
+ }
361
+ export interface SelectQueryBuilder<Entity extends object = AnyEntity, RootAlias extends string = never, Hint extends string = never, Context extends object = never> extends QueryBuilder<Entity, RootAlias, Hint, Context> {
362
+ execute<Result = Entity[]>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<Result>;
363
+ execute<Result = Entity[]>(method: 'all', mapResults?: boolean): Promise<Result>;
364
+ execute<Result = Entity>(method: 'get', mapResults?: boolean): Promise<Result>;
365
+ execute<Result = QueryResult<Entity>>(method: 'run', mapResults?: boolean): Promise<Result>;
366
+ }
367
+ export interface CountQueryBuilder<Entity extends object> extends QueryBuilder<Entity, any, any> {
368
+ execute<Result = {
369
+ count: number;
370
+ }[]>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<Result>;
371
+ execute<Result = {
372
+ count: number;
373
+ }[]>(method: 'all', mapResults?: boolean): Promise<Result>;
374
+ execute<Result = {
375
+ count: number;
376
+ }>(method: 'get', mapResults?: boolean): Promise<Result>;
377
+ execute<Result = QueryResult<{
378
+ count: number;
379
+ }>>(method: 'run', mapResults?: boolean): Promise<Result>;
380
+ }
381
+ export interface InsertQueryBuilder<T extends object> extends RunQueryBuilder<T> {
382
+ }
383
+ export interface UpdateQueryBuilder<T extends object> extends RunQueryBuilder<T> {
384
+ }
385
+ export interface DeleteQueryBuilder<T extends object> extends RunQueryBuilder<T> {
386
+ }
387
+ export interface TruncateQueryBuilder<T extends object> extends RunQueryBuilder<T> {
388
+ }
389
+ export {};