nestjs-query-mikro-orm 0.0.8 → 0.1.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 +1 -1
- package/dist/index.cjs +621 -298
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -72
- package/dist/index.d.ts +71 -72
- package/dist/index.mjs +610 -287
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EntityName, AnyEntity, FilterQuery, EntityMetadata } from '@mikro-orm/core';
|
|
1
|
+
import { EntityName, AnyEntity, FilterQuery, EntityMetadata, EntityRepository } from '@mikro-orm/core';
|
|
2
2
|
import { DynamicModule, FactoryProvider } from '@nestjs/common';
|
|
3
|
-
import {
|
|
4
|
-
import { AggregateResponse, AggregateQuery, Filter, Query, Paging, SortField, CommonFieldComparisonBetweenType, FilterComparisonOperators, Class, GetByIdOptions, FindRelationOptions, ModifyRelationOptions, QueryService, DeepPartial, FindByIdOptions, UpdateOneOptions, UpdateManyResponse, DeleteOneOptions, DeleteManyResponse, Filterable } from '@nestjs-query/core';
|
|
3
|
+
import { Filter, Query, SortField, FilterComparisonOperators, CommonFieldComparisonBetweenType, AggregateQuery, AggregateResponse, Class, GetByIdOptions, FindRelationOptions, ModifyRelationOptions, QueryService, DeepPartial, FindByIdOptions, UpdateOneOptions, UpdateManyResponse, DeleteOneOptions, DeleteManyResponse, Filterable } from '@ptc-org/nestjs-query-core';
|
|
5
4
|
|
|
6
5
|
declare class NestjsQueryMikroOrmModule {
|
|
7
6
|
static forFeature(entities: EntityName<AnyEntity>[], contextName?: string): DynamicModule;
|
|
@@ -9,43 +8,6 @@ declare class NestjsQueryMikroOrmModule {
|
|
|
9
8
|
|
|
10
9
|
declare const createMikroOrmQueryServiceProviders: (entities: EntityName<AnyEntity>[], contextName?: string) => FactoryProvider[];
|
|
11
10
|
|
|
12
|
-
declare enum AggregateFuncs {
|
|
13
|
-
AVG = "AVG",
|
|
14
|
-
SUM = "SUM",
|
|
15
|
-
COUNT = "COUNT",
|
|
16
|
-
MAX = "MAX",
|
|
17
|
-
MIN = "MIN"
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @internal
|
|
21
|
-
* Builds aggregate queries for MikroORM.
|
|
22
|
-
*/
|
|
23
|
-
declare class AggregateBuilder<Entity extends object> {
|
|
24
|
-
static asyncConvertToAggregateResponse<Entity>(responsePromise: Promise<Record<string, unknown>[]>): Promise<AggregateResponse<Entity>[]>;
|
|
25
|
-
static getAggregateSelects<Entity>(query: AggregateQuery<Entity>): string[];
|
|
26
|
-
private static getAggregateGroupBySelects;
|
|
27
|
-
private static getAggregateFuncSelects;
|
|
28
|
-
static getAggregateAlias<Entity>(func: AggregateFuncs, field: keyof Entity): string;
|
|
29
|
-
static getGroupByAlias<Entity>(field: keyof Entity): string;
|
|
30
|
-
static convertToAggregateResponse<Entity>(rawAggregates: Record<string, unknown>[]): AggregateResponse<Entity>[];
|
|
31
|
-
/**
|
|
32
|
-
* Gets the actual database column name for a property from entity metadata.
|
|
33
|
-
* @param metadata - the entity metadata
|
|
34
|
-
* @param propertyName - the property name
|
|
35
|
-
* @returns the database column name
|
|
36
|
-
*/
|
|
37
|
-
private getColumnName;
|
|
38
|
-
/**
|
|
39
|
-
* Builds aggregate SELECT clause for MikroORM QueryBuilder.
|
|
40
|
-
* @param qb - the MikroORM QueryBuilder
|
|
41
|
-
* @param aggregate - the aggregates to select.
|
|
42
|
-
* @param alias - optional alias to use to qualify an identifier
|
|
43
|
-
*/
|
|
44
|
-
build<Qb extends QueryBuilder<Entity>>(qb: Qb, aggregate: AggregateQuery<Entity>, alias?: string): Qb;
|
|
45
|
-
private createAggSelect;
|
|
46
|
-
private createGroupBySelect;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
11
|
/**
|
|
50
12
|
* @internal
|
|
51
13
|
* Builds a WHERE clause from a Filter for MikroORM.
|
|
@@ -83,6 +45,16 @@ declare class WhereBuilder<Entity> {
|
|
|
83
45
|
private isBetweenValue;
|
|
84
46
|
}
|
|
85
47
|
|
|
48
|
+
interface QueryBuilder<T = unknown> {
|
|
49
|
+
andWhere?(filter: FilterQuery<T>): this;
|
|
50
|
+
orderBy?(o: Record<string, unknown> | unknown): this;
|
|
51
|
+
groupBy?(field: string): this;
|
|
52
|
+
addSelect?(s: unknown): this;
|
|
53
|
+
mainAlias?: {
|
|
54
|
+
metadata?: EntityMetadata<T>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
86
58
|
/**
|
|
87
59
|
* @internal
|
|
88
60
|
*
|
|
@@ -99,30 +71,24 @@ interface NestedRecord<E = unknown> {
|
|
|
99
71
|
declare class FilterQueryBuilder<Entity extends object> {
|
|
100
72
|
readonly repo: EntityRepository<Entity>;
|
|
101
73
|
readonly whereBuilder: WhereBuilder<Entity>;
|
|
102
|
-
|
|
103
|
-
constructor(repo: EntityRepository<Entity>, whereBuilder?: WhereBuilder<Entity>, aggregateBuilder?: AggregateBuilder<Entity>);
|
|
74
|
+
constructor(repo: EntityRepository<Entity>, whereBuilder?: WhereBuilder<Entity>);
|
|
104
75
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @param query - the query to apply.
|
|
108
|
-
*/
|
|
109
|
-
select(query: Query<Entity>): QueryBuilder<Entity>;
|
|
110
|
-
selectById(id: string | number | (string | number)[], query: Query<Entity>): QueryBuilder<Entity>;
|
|
111
|
-
aggregate(query: Query<Entity>, aggregate: AggregateQuery<Entity>): QueryBuilder<Entity>;
|
|
112
|
-
/**
|
|
113
|
-
* Applies paging to a MikroORM query builder
|
|
114
|
-
* @param qb - the MikroORM QueryBuilder
|
|
115
|
-
* @param paging - the Paging options.
|
|
76
|
+
* NOTE: QueryBuilder-specific helpers removed; use `buildFindOptions` to
|
|
77
|
+
* produce a filter and options for `em.find`/`repo.find`.
|
|
116
78
|
*/
|
|
117
|
-
applyPaging<Q extends QueryBuilder<Entity>>(qb: Q, paging?: Paging): Q;
|
|
118
79
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* @param aggregate - the aggregates to select.
|
|
123
|
-
* @param alias - optional alias to use to qualify an identifier
|
|
80
|
+
* Build a filter query and find options suitable for `em.find`/`repo.find` calls.
|
|
81
|
+
* This keeps usage DB-agnostic by returning plain filter objects and options
|
|
82
|
+
* instead of driver-specific QueryBuilder instances.
|
|
124
83
|
*/
|
|
125
|
-
|
|
84
|
+
buildFindOptions(query: Query<Entity>): {
|
|
85
|
+
filterQuery?: FilterQuery<Entity>;
|
|
86
|
+
options?: {
|
|
87
|
+
limit?: number;
|
|
88
|
+
offset?: number;
|
|
89
|
+
orderBy?: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
126
92
|
/**
|
|
127
93
|
* Applies the filter from a Query to a MikroORM QueryBuilder.
|
|
128
94
|
*
|
|
@@ -171,7 +137,7 @@ type EntityComparisonField<Entity, F extends keyof Entity> = Entity[F] | Entity[
|
|
|
171
137
|
* Maps nestjs-query comparison operators to MikroORM operators.
|
|
172
138
|
* This is a simplified version since MikroORM uses object-based filters.
|
|
173
139
|
*/
|
|
174
|
-
declare class
|
|
140
|
+
declare class ComparisonBuilder<Entity> {
|
|
175
141
|
/**
|
|
176
142
|
* Maps a comparison operator to MikroORM filter format.
|
|
177
143
|
*
|
|
@@ -202,12 +168,7 @@ declare class RelationQueryBuilder<Entity extends object, Relation extends objec
|
|
|
202
168
|
readonly filterQueryBuilder: FilterQueryBuilder<Relation>;
|
|
203
169
|
constructor(repo: EntityRepository<Entity>, relation: string);
|
|
204
170
|
/**
|
|
205
|
-
*
|
|
206
|
-
* This is useful for testing or when you need to inspect/modify the query before execution.
|
|
207
|
-
*/
|
|
208
|
-
select(entity: Entity, query: Query<Relation>): QueryBuilder<Relation>;
|
|
209
|
-
/**
|
|
210
|
-
* Executes the select query and returns the results.
|
|
171
|
+
* Executes a relation select using `em.find` so the implementation is database-agnostic.
|
|
211
172
|
*/
|
|
212
173
|
selectAndExecute(entity: Entity, query: Query<Relation>): Promise<Relation[]>;
|
|
213
174
|
count(entity: Entity, query: Query<Relation>): Promise<number>;
|
|
@@ -221,6 +182,44 @@ declare class RelationQueryBuilder<Entity extends object, Relation extends objec
|
|
|
221
182
|
}[];
|
|
222
183
|
}
|
|
223
184
|
|
|
185
|
+
declare enum AggregateFuncs {
|
|
186
|
+
AVG = "AVG",
|
|
187
|
+
SUM = "SUM",
|
|
188
|
+
COUNT = "COUNT",
|
|
189
|
+
MAX = "MAX",
|
|
190
|
+
MIN = "MIN"
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @internal
|
|
194
|
+
* Builds aggregate queries for MikroORM.
|
|
195
|
+
*/
|
|
196
|
+
declare class AggregateBuilder<Entity extends object> {
|
|
197
|
+
static buildSelectExpressions<Entity>(aggregate: AggregateQuery<Entity>, alias?: string): [string, string][];
|
|
198
|
+
static asyncConvertToAggregateResponse<Entity>(responsePromise: Promise<Record<string, unknown>[]>): Promise<AggregateResponse<Entity>[]>;
|
|
199
|
+
static getAggregateSelects<Entity>(query: AggregateQuery<Entity>): string[];
|
|
200
|
+
private static getAggregateGroupBySelects;
|
|
201
|
+
private static getAggregateFuncSelects;
|
|
202
|
+
static getAggregateAlias<Entity>(func: AggregateFuncs, field: keyof Entity): string;
|
|
203
|
+
static getGroupByAlias<Entity>(field: keyof Entity): string;
|
|
204
|
+
static convertToAggregateResponse<Entity>(rawAggregates: Record<string, unknown>[]): AggregateResponse<Entity>[];
|
|
205
|
+
/**
|
|
206
|
+
* Gets the actual database column name for a property from entity metadata.
|
|
207
|
+
* @param metadata - the entity metadata
|
|
208
|
+
* @param propertyName - the property name
|
|
209
|
+
* @returns the database column name
|
|
210
|
+
*/
|
|
211
|
+
private getColumnName;
|
|
212
|
+
/**
|
|
213
|
+
* Builds aggregate SELECT clause for MikroORM QueryBuilder.
|
|
214
|
+
* @param qb - the MikroORM QueryBuilder
|
|
215
|
+
* @param aggregate - the aggregates to select.
|
|
216
|
+
* @param alias - optional alias to use to qualify an identifier
|
|
217
|
+
*/
|
|
218
|
+
build<Qb extends QueryBuilder<Entity>>(qb: Qb, aggregate: AggregateQuery<Entity>, alias?: string): Qb;
|
|
219
|
+
private createAggSelect;
|
|
220
|
+
private createGroupBySelect;
|
|
221
|
+
}
|
|
222
|
+
|
|
224
223
|
/**
|
|
225
224
|
* Base class to house relations loading.
|
|
226
225
|
* @internal
|
|
@@ -376,7 +375,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
376
375
|
constructor(repo: EntityRepository<Entity>, opts?: MikroOrmQueryServiceOpts<Entity>);
|
|
377
376
|
get EntityClass(): Class<Entity>;
|
|
378
377
|
/**
|
|
379
|
-
* Query for multiple entities, using a Query from `@nestjs-query
|
|
378
|
+
* Query for multiple entities, using a Query from `@ptc-org/nestjs-query-core`.
|
|
380
379
|
*
|
|
381
380
|
* @example
|
|
382
381
|
* ```ts
|
|
@@ -451,7 +450,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
451
450
|
*/
|
|
452
451
|
updateOne(id: number | string, update: DeepPartial<Entity>, opts?: UpdateOneOptions<Entity>): Promise<Entity>;
|
|
453
452
|
/**
|
|
454
|
-
* Update multiple entities with a `@nestjs-query
|
|
453
|
+
* Update multiple entities with a `@ptc-org/nestjs-query-core` Filter.
|
|
455
454
|
*
|
|
456
455
|
* @example
|
|
457
456
|
* ```ts
|
|
@@ -478,7 +477,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
478
477
|
*/
|
|
479
478
|
deleteOne(id: string | number, opts?: DeleteOneOptions<Entity>): Promise<Entity>;
|
|
480
479
|
/**
|
|
481
|
-
* Delete multiple records with a `@nestjs-query
|
|
480
|
+
* Delete multiple records with a `@ptc-org/nestjs-query-core` `Filter`.
|
|
482
481
|
*
|
|
483
482
|
* @example
|
|
484
483
|
*
|
|
@@ -505,7 +504,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
505
504
|
*/
|
|
506
505
|
restoreOne(id: string | number, opts?: Filterable<Entity>): Promise<Entity>;
|
|
507
506
|
/**
|
|
508
|
-
* Restores multiple records with a `@nestjs-query
|
|
507
|
+
* Restores multiple records with a `@ptc-org/nestjs-query-core` `Filter`.
|
|
509
508
|
*
|
|
510
509
|
* @example
|
|
511
510
|
*
|
|
@@ -525,4 +524,4 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
525
524
|
private ensureSoftDeleteEnabled;
|
|
526
525
|
}
|
|
527
526
|
|
|
528
|
-
export { AggregateBuilder, type EntityComparisonField, type EntityIndexRelation, FilterQueryBuilder, MikroOrmQueryService, type MikroOrmQueryServiceOpts, type NestedRecord, NestjsQueryMikroOrmModule, RelationQueryBuilder, RelationQueryService,
|
|
527
|
+
export { AggregateBuilder, ComparisonBuilder, type EntityComparisonField, type EntityIndexRelation, FilterQueryBuilder, MikroOrmQueryService, type MikroOrmQueryServiceOpts, type NestedRecord, NestjsQueryMikroOrmModule, RelationQueryBuilder, RelationQueryService, WhereBuilder, createMikroOrmQueryServiceProviders };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EntityName, AnyEntity, FilterQuery, EntityMetadata } from '@mikro-orm/core';
|
|
1
|
+
import { EntityName, AnyEntity, FilterQuery, EntityMetadata, EntityRepository } from '@mikro-orm/core';
|
|
2
2
|
import { DynamicModule, FactoryProvider } from '@nestjs/common';
|
|
3
|
-
import {
|
|
4
|
-
import { AggregateResponse, AggregateQuery, Filter, Query, Paging, SortField, CommonFieldComparisonBetweenType, FilterComparisonOperators, Class, GetByIdOptions, FindRelationOptions, ModifyRelationOptions, QueryService, DeepPartial, FindByIdOptions, UpdateOneOptions, UpdateManyResponse, DeleteOneOptions, DeleteManyResponse, Filterable } from '@nestjs-query/core';
|
|
3
|
+
import { Filter, Query, SortField, FilterComparisonOperators, CommonFieldComparisonBetweenType, AggregateQuery, AggregateResponse, Class, GetByIdOptions, FindRelationOptions, ModifyRelationOptions, QueryService, DeepPartial, FindByIdOptions, UpdateOneOptions, UpdateManyResponse, DeleteOneOptions, DeleteManyResponse, Filterable } from '@ptc-org/nestjs-query-core';
|
|
5
4
|
|
|
6
5
|
declare class NestjsQueryMikroOrmModule {
|
|
7
6
|
static forFeature(entities: EntityName<AnyEntity>[], contextName?: string): DynamicModule;
|
|
@@ -9,43 +8,6 @@ declare class NestjsQueryMikroOrmModule {
|
|
|
9
8
|
|
|
10
9
|
declare const createMikroOrmQueryServiceProviders: (entities: EntityName<AnyEntity>[], contextName?: string) => FactoryProvider[];
|
|
11
10
|
|
|
12
|
-
declare enum AggregateFuncs {
|
|
13
|
-
AVG = "AVG",
|
|
14
|
-
SUM = "SUM",
|
|
15
|
-
COUNT = "COUNT",
|
|
16
|
-
MAX = "MAX",
|
|
17
|
-
MIN = "MIN"
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @internal
|
|
21
|
-
* Builds aggregate queries for MikroORM.
|
|
22
|
-
*/
|
|
23
|
-
declare class AggregateBuilder<Entity extends object> {
|
|
24
|
-
static asyncConvertToAggregateResponse<Entity>(responsePromise: Promise<Record<string, unknown>[]>): Promise<AggregateResponse<Entity>[]>;
|
|
25
|
-
static getAggregateSelects<Entity>(query: AggregateQuery<Entity>): string[];
|
|
26
|
-
private static getAggregateGroupBySelects;
|
|
27
|
-
private static getAggregateFuncSelects;
|
|
28
|
-
static getAggregateAlias<Entity>(func: AggregateFuncs, field: keyof Entity): string;
|
|
29
|
-
static getGroupByAlias<Entity>(field: keyof Entity): string;
|
|
30
|
-
static convertToAggregateResponse<Entity>(rawAggregates: Record<string, unknown>[]): AggregateResponse<Entity>[];
|
|
31
|
-
/**
|
|
32
|
-
* Gets the actual database column name for a property from entity metadata.
|
|
33
|
-
* @param metadata - the entity metadata
|
|
34
|
-
* @param propertyName - the property name
|
|
35
|
-
* @returns the database column name
|
|
36
|
-
*/
|
|
37
|
-
private getColumnName;
|
|
38
|
-
/**
|
|
39
|
-
* Builds aggregate SELECT clause for MikroORM QueryBuilder.
|
|
40
|
-
* @param qb - the MikroORM QueryBuilder
|
|
41
|
-
* @param aggregate - the aggregates to select.
|
|
42
|
-
* @param alias - optional alias to use to qualify an identifier
|
|
43
|
-
*/
|
|
44
|
-
build<Qb extends QueryBuilder<Entity>>(qb: Qb, aggregate: AggregateQuery<Entity>, alias?: string): Qb;
|
|
45
|
-
private createAggSelect;
|
|
46
|
-
private createGroupBySelect;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
11
|
/**
|
|
50
12
|
* @internal
|
|
51
13
|
* Builds a WHERE clause from a Filter for MikroORM.
|
|
@@ -83,6 +45,16 @@ declare class WhereBuilder<Entity> {
|
|
|
83
45
|
private isBetweenValue;
|
|
84
46
|
}
|
|
85
47
|
|
|
48
|
+
interface QueryBuilder<T = unknown> {
|
|
49
|
+
andWhere?(filter: FilterQuery<T>): this;
|
|
50
|
+
orderBy?(o: Record<string, unknown> | unknown): this;
|
|
51
|
+
groupBy?(field: string): this;
|
|
52
|
+
addSelect?(s: unknown): this;
|
|
53
|
+
mainAlias?: {
|
|
54
|
+
metadata?: EntityMetadata<T>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
86
58
|
/**
|
|
87
59
|
* @internal
|
|
88
60
|
*
|
|
@@ -99,30 +71,24 @@ interface NestedRecord<E = unknown> {
|
|
|
99
71
|
declare class FilterQueryBuilder<Entity extends object> {
|
|
100
72
|
readonly repo: EntityRepository<Entity>;
|
|
101
73
|
readonly whereBuilder: WhereBuilder<Entity>;
|
|
102
|
-
|
|
103
|
-
constructor(repo: EntityRepository<Entity>, whereBuilder?: WhereBuilder<Entity>, aggregateBuilder?: AggregateBuilder<Entity>);
|
|
74
|
+
constructor(repo: EntityRepository<Entity>, whereBuilder?: WhereBuilder<Entity>);
|
|
104
75
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @param query - the query to apply.
|
|
108
|
-
*/
|
|
109
|
-
select(query: Query<Entity>): QueryBuilder<Entity>;
|
|
110
|
-
selectById(id: string | number | (string | number)[], query: Query<Entity>): QueryBuilder<Entity>;
|
|
111
|
-
aggregate(query: Query<Entity>, aggregate: AggregateQuery<Entity>): QueryBuilder<Entity>;
|
|
112
|
-
/**
|
|
113
|
-
* Applies paging to a MikroORM query builder
|
|
114
|
-
* @param qb - the MikroORM QueryBuilder
|
|
115
|
-
* @param paging - the Paging options.
|
|
76
|
+
* NOTE: QueryBuilder-specific helpers removed; use `buildFindOptions` to
|
|
77
|
+
* produce a filter and options for `em.find`/`repo.find`.
|
|
116
78
|
*/
|
|
117
|
-
applyPaging<Q extends QueryBuilder<Entity>>(qb: Q, paging?: Paging): Q;
|
|
118
79
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* @param aggregate - the aggregates to select.
|
|
123
|
-
* @param alias - optional alias to use to qualify an identifier
|
|
80
|
+
* Build a filter query and find options suitable for `em.find`/`repo.find` calls.
|
|
81
|
+
* This keeps usage DB-agnostic by returning plain filter objects and options
|
|
82
|
+
* instead of driver-specific QueryBuilder instances.
|
|
124
83
|
*/
|
|
125
|
-
|
|
84
|
+
buildFindOptions(query: Query<Entity>): {
|
|
85
|
+
filterQuery?: FilterQuery<Entity>;
|
|
86
|
+
options?: {
|
|
87
|
+
limit?: number;
|
|
88
|
+
offset?: number;
|
|
89
|
+
orderBy?: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
126
92
|
/**
|
|
127
93
|
* Applies the filter from a Query to a MikroORM QueryBuilder.
|
|
128
94
|
*
|
|
@@ -171,7 +137,7 @@ type EntityComparisonField<Entity, F extends keyof Entity> = Entity[F] | Entity[
|
|
|
171
137
|
* Maps nestjs-query comparison operators to MikroORM operators.
|
|
172
138
|
* This is a simplified version since MikroORM uses object-based filters.
|
|
173
139
|
*/
|
|
174
|
-
declare class
|
|
140
|
+
declare class ComparisonBuilder<Entity> {
|
|
175
141
|
/**
|
|
176
142
|
* Maps a comparison operator to MikroORM filter format.
|
|
177
143
|
*
|
|
@@ -202,12 +168,7 @@ declare class RelationQueryBuilder<Entity extends object, Relation extends objec
|
|
|
202
168
|
readonly filterQueryBuilder: FilterQueryBuilder<Relation>;
|
|
203
169
|
constructor(repo: EntityRepository<Entity>, relation: string);
|
|
204
170
|
/**
|
|
205
|
-
*
|
|
206
|
-
* This is useful for testing or when you need to inspect/modify the query before execution.
|
|
207
|
-
*/
|
|
208
|
-
select(entity: Entity, query: Query<Relation>): QueryBuilder<Relation>;
|
|
209
|
-
/**
|
|
210
|
-
* Executes the select query and returns the results.
|
|
171
|
+
* Executes a relation select using `em.find` so the implementation is database-agnostic.
|
|
211
172
|
*/
|
|
212
173
|
selectAndExecute(entity: Entity, query: Query<Relation>): Promise<Relation[]>;
|
|
213
174
|
count(entity: Entity, query: Query<Relation>): Promise<number>;
|
|
@@ -221,6 +182,44 @@ declare class RelationQueryBuilder<Entity extends object, Relation extends objec
|
|
|
221
182
|
}[];
|
|
222
183
|
}
|
|
223
184
|
|
|
185
|
+
declare enum AggregateFuncs {
|
|
186
|
+
AVG = "AVG",
|
|
187
|
+
SUM = "SUM",
|
|
188
|
+
COUNT = "COUNT",
|
|
189
|
+
MAX = "MAX",
|
|
190
|
+
MIN = "MIN"
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @internal
|
|
194
|
+
* Builds aggregate queries for MikroORM.
|
|
195
|
+
*/
|
|
196
|
+
declare class AggregateBuilder<Entity extends object> {
|
|
197
|
+
static buildSelectExpressions<Entity>(aggregate: AggregateQuery<Entity>, alias?: string): [string, string][];
|
|
198
|
+
static asyncConvertToAggregateResponse<Entity>(responsePromise: Promise<Record<string, unknown>[]>): Promise<AggregateResponse<Entity>[]>;
|
|
199
|
+
static getAggregateSelects<Entity>(query: AggregateQuery<Entity>): string[];
|
|
200
|
+
private static getAggregateGroupBySelects;
|
|
201
|
+
private static getAggregateFuncSelects;
|
|
202
|
+
static getAggregateAlias<Entity>(func: AggregateFuncs, field: keyof Entity): string;
|
|
203
|
+
static getGroupByAlias<Entity>(field: keyof Entity): string;
|
|
204
|
+
static convertToAggregateResponse<Entity>(rawAggregates: Record<string, unknown>[]): AggregateResponse<Entity>[];
|
|
205
|
+
/**
|
|
206
|
+
* Gets the actual database column name for a property from entity metadata.
|
|
207
|
+
* @param metadata - the entity metadata
|
|
208
|
+
* @param propertyName - the property name
|
|
209
|
+
* @returns the database column name
|
|
210
|
+
*/
|
|
211
|
+
private getColumnName;
|
|
212
|
+
/**
|
|
213
|
+
* Builds aggregate SELECT clause for MikroORM QueryBuilder.
|
|
214
|
+
* @param qb - the MikroORM QueryBuilder
|
|
215
|
+
* @param aggregate - the aggregates to select.
|
|
216
|
+
* @param alias - optional alias to use to qualify an identifier
|
|
217
|
+
*/
|
|
218
|
+
build<Qb extends QueryBuilder<Entity>>(qb: Qb, aggregate: AggregateQuery<Entity>, alias?: string): Qb;
|
|
219
|
+
private createAggSelect;
|
|
220
|
+
private createGroupBySelect;
|
|
221
|
+
}
|
|
222
|
+
|
|
224
223
|
/**
|
|
225
224
|
* Base class to house relations loading.
|
|
226
225
|
* @internal
|
|
@@ -376,7 +375,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
376
375
|
constructor(repo: EntityRepository<Entity>, opts?: MikroOrmQueryServiceOpts<Entity>);
|
|
377
376
|
get EntityClass(): Class<Entity>;
|
|
378
377
|
/**
|
|
379
|
-
* Query for multiple entities, using a Query from `@nestjs-query
|
|
378
|
+
* Query for multiple entities, using a Query from `@ptc-org/nestjs-query-core`.
|
|
380
379
|
*
|
|
381
380
|
* @example
|
|
382
381
|
* ```ts
|
|
@@ -451,7 +450,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
451
450
|
*/
|
|
452
451
|
updateOne(id: number | string, update: DeepPartial<Entity>, opts?: UpdateOneOptions<Entity>): Promise<Entity>;
|
|
453
452
|
/**
|
|
454
|
-
* Update multiple entities with a `@nestjs-query
|
|
453
|
+
* Update multiple entities with a `@ptc-org/nestjs-query-core` Filter.
|
|
455
454
|
*
|
|
456
455
|
* @example
|
|
457
456
|
* ```ts
|
|
@@ -478,7 +477,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
478
477
|
*/
|
|
479
478
|
deleteOne(id: string | number, opts?: DeleteOneOptions<Entity>): Promise<Entity>;
|
|
480
479
|
/**
|
|
481
|
-
* Delete multiple records with a `@nestjs-query
|
|
480
|
+
* Delete multiple records with a `@ptc-org/nestjs-query-core` `Filter`.
|
|
482
481
|
*
|
|
483
482
|
* @example
|
|
484
483
|
*
|
|
@@ -505,7 +504,7 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
505
504
|
*/
|
|
506
505
|
restoreOne(id: string | number, opts?: Filterable<Entity>): Promise<Entity>;
|
|
507
506
|
/**
|
|
508
|
-
* Restores multiple records with a `@nestjs-query
|
|
507
|
+
* Restores multiple records with a `@ptc-org/nestjs-query-core` `Filter`.
|
|
509
508
|
*
|
|
510
509
|
* @example
|
|
511
510
|
*
|
|
@@ -525,4 +524,4 @@ declare class MikroOrmQueryService<Entity extends object> extends RelationQueryS
|
|
|
525
524
|
private ensureSoftDeleteEnabled;
|
|
526
525
|
}
|
|
527
526
|
|
|
528
|
-
export { AggregateBuilder, type EntityComparisonField, type EntityIndexRelation, FilterQueryBuilder, MikroOrmQueryService, type MikroOrmQueryServiceOpts, type NestedRecord, NestjsQueryMikroOrmModule, RelationQueryBuilder, RelationQueryService,
|
|
527
|
+
export { AggregateBuilder, ComparisonBuilder, type EntityComparisonField, type EntityIndexRelation, FilterQueryBuilder, MikroOrmQueryService, type MikroOrmQueryServiceOpts, type NestedRecord, NestjsQueryMikroOrmModule, RelationQueryBuilder, RelationQueryService, WhereBuilder, createMikroOrmQueryServiceProviders };
|