nestjs-query-mikro-orm 0.0.4 → 0.0.6
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/index.cjs +735 -576
- package/dist/index.cjs.map +1 -7
- package/dist/index.d.cts +528 -0
- package/dist/index.d.ts +528 -5
- package/dist/{index.js → index.mjs} +707 -517
- package/dist/index.mjs.map +1 -0
- package/package.json +14 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -7
- package/dist/lib/common/index.d.ts +0 -2
- package/dist/lib/common/index.d.ts.map +0 -1
- package/dist/lib/common/randomString.d.ts +0 -2
- package/dist/lib/common/randomString.d.ts.map +0 -1
- package/dist/lib/nest-query-mikro-orm.module.d.ts +0 -6
- package/dist/lib/nest-query-mikro-orm.module.d.ts.map +0 -1
- package/dist/lib/providers.d.ts +0 -4
- package/dist/lib/providers.d.ts.map +0 -1
- package/dist/lib/query/aggregate.builder.d.ts +0 -40
- package/dist/lib/query/aggregate.builder.d.ts.map +0 -1
- package/dist/lib/query/filter-query.builder.d.ts +0 -84
- package/dist/lib/query/filter-query.builder.d.ts.map +0 -1
- package/dist/lib/query/index.d.ts +0 -6
- package/dist/lib/query/index.d.ts.map +0 -1
- package/dist/lib/query/relation-query.builder.d.ts +0 -36
- package/dist/lib/query/relation-query.builder.d.ts.map +0 -1
- package/dist/lib/query/sql-comparison.builder.d.ts +0 -27
- package/dist/lib/query/sql-comparison.builder.d.ts.map +0 -1
- package/dist/lib/query/where.builder.d.ts +0 -39
- package/dist/lib/query/where.builder.d.ts.map +0 -1
- package/dist/lib/services/index.d.ts +0 -3
- package/dist/lib/services/index.d.ts.map +0 -1
- package/dist/lib/services/mikro-orm-query.service.d.ts +0 -180
- package/dist/lib/services/mikro-orm-query.service.d.ts.map +0 -1
- package/dist/lib/services/relation-query.service.d.ts +0 -132
- package/dist/lib/services/relation-query.service.d.ts.map +0 -1
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,92 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
AggregateBuilder: () => AggregateBuilder,
|
|
34
|
-
FilterQueryBuilder: () => FilterQueryBuilder,
|
|
35
|
-
MikroOrmQueryService: () => MikroOrmQueryService,
|
|
36
|
-
NestjsQueryMikroOrmModule: () => NestjsQueryMikroOrmModule,
|
|
37
|
-
RelationQueryBuilder: () => RelationQueryBuilder,
|
|
38
|
-
RelationQueryService: () => RelationQueryService,
|
|
39
|
-
SQLComparisonBuilder: () => SQLComparisonBuilder,
|
|
40
|
-
WhereBuilder: () => WhereBuilder,
|
|
41
|
-
createMikroOrmQueryServiceProviders: () => createMikroOrmQueryServiceProviders
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(src_exports);
|
|
44
|
-
|
|
45
|
-
// src/lib/nest-query-mikro-orm.module.ts
|
|
46
|
-
var import_nestjs2 = require("@mikro-orm/nestjs");
|
|
1
|
+
'use strict';
|
|
47
2
|
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
var
|
|
3
|
+
var nestjs = require('@mikro-orm/nestjs');
|
|
4
|
+
var core$1 = require('@nestjs-query/core');
|
|
5
|
+
var core = require('@mikro-orm/core');
|
|
6
|
+
var assembler_serializer = require('@nestjs-query/core/dist/src/assemblers/assembler.serializer');
|
|
7
|
+
var common = require('@nestjs/common');
|
|
8
|
+
var classTransformer = require('class-transformer');
|
|
9
|
+
var merge = require('lodash.merge');
|
|
10
|
+
var camelCase = require('camel-case');
|
|
51
11
|
|
|
52
|
-
|
|
53
|
-
var import_core5 = require("@mikro-orm/core");
|
|
54
|
-
var import_core6 = require("@nestjs-query/core");
|
|
55
|
-
var import_assembler = require("@nestjs-query/core/dist/src/assemblers/assembler.serializer");
|
|
56
|
-
var import_common2 = require("@nestjs/common");
|
|
57
|
-
var import_class_transformer = require("class-transformer");
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
58
13
|
|
|
59
|
-
|
|
60
|
-
var import_core2 = require("@nestjs-query/core");
|
|
61
|
-
var import_lodash = __toESM(require("lodash.merge"), 1);
|
|
14
|
+
var merge__default = /*#__PURE__*/_interopDefault(merge);
|
|
62
15
|
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
var import_common = require("@nestjs/common");
|
|
66
|
-
var import_camel_case = require("camel-case");
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
67
18
|
var AGG_REGEXP = /(AVG|SUM|COUNT|MAX|MIN|GROUP_BY)_(.*)/;
|
|
68
19
|
var AggregateBuilder = class _AggregateBuilder {
|
|
20
|
+
static {
|
|
21
|
+
__name(this, "AggregateBuilder");
|
|
22
|
+
}
|
|
69
23
|
static async asyncConvertToAggregateResponse(responsePromise) {
|
|
70
24
|
const aggResponse = await responsePromise;
|
|
71
25
|
return this.convertToAggregateResponse(aggResponse);
|
|
72
26
|
}
|
|
73
27
|
static getAggregateSelects(query) {
|
|
74
|
-
return [
|
|
28
|
+
return [
|
|
29
|
+
...this.getAggregateGroupBySelects(query),
|
|
30
|
+
...this.getAggregateFuncSelects(query)
|
|
31
|
+
];
|
|
75
32
|
}
|
|
76
33
|
static getAggregateGroupBySelects(query) {
|
|
77
34
|
return (query.groupBy ?? []).map((f) => this.getGroupByAlias(f));
|
|
78
35
|
}
|
|
79
36
|
static getAggregateFuncSelects(query) {
|
|
80
37
|
const aggs = [
|
|
81
|
-
[
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[
|
|
38
|
+
[
|
|
39
|
+
"COUNT",
|
|
40
|
+
query.count
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
"SUM",
|
|
44
|
+
query.sum
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"AVG",
|
|
48
|
+
query.avg
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"MAX",
|
|
52
|
+
query.max
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"MIN",
|
|
56
|
+
query.min
|
|
57
|
+
]
|
|
86
58
|
];
|
|
87
59
|
return aggs.reduce((cols, [func, fields]) => {
|
|
88
60
|
const aliases = (fields ?? []).map((f) => this.getAggregateAlias(func, f));
|
|
89
|
-
return [
|
|
61
|
+
return [
|
|
62
|
+
...cols,
|
|
63
|
+
...aliases
|
|
64
|
+
];
|
|
90
65
|
}, []);
|
|
91
66
|
}
|
|
92
67
|
static getAggregateAlias(func, field) {
|
|
@@ -103,22 +78,25 @@ var AggregateBuilder = class _AggregateBuilder {
|
|
|
103
78
|
throw new Error("Unknown aggregate column encountered.");
|
|
104
79
|
}
|
|
105
80
|
const [matchedFunc, matchedFieldName] = matchResult.slice(1);
|
|
106
|
-
const aggFunc =
|
|
81
|
+
const aggFunc = camelCase.camelCase(matchedFunc.toLowerCase());
|
|
107
82
|
const fieldName = matchedFieldName;
|
|
108
83
|
const aggResult = agg[aggFunc] || {};
|
|
109
84
|
return {
|
|
110
85
|
...agg,
|
|
111
|
-
[aggFunc]: {
|
|
86
|
+
[aggFunc]: {
|
|
87
|
+
...aggResult,
|
|
88
|
+
[fieldName]: response[resultField]
|
|
89
|
+
}
|
|
112
90
|
};
|
|
113
91
|
}, {});
|
|
114
92
|
});
|
|
115
93
|
}
|
|
116
94
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
95
|
+
* Gets the actual database column name for a property from entity metadata.
|
|
96
|
+
* @param metadata - the entity metadata
|
|
97
|
+
* @param propertyName - the property name
|
|
98
|
+
* @returns the database column name
|
|
99
|
+
*/
|
|
122
100
|
getColumnName(metadata, propertyName) {
|
|
123
101
|
const prop = metadata.properties[propertyName];
|
|
124
102
|
if (prop && prop.fieldNames && prop.fieldNames.length > 0) {
|
|
@@ -127,26 +105,26 @@ var AggregateBuilder = class _AggregateBuilder {
|
|
|
127
105
|
return propertyName;
|
|
128
106
|
}
|
|
129
107
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
108
|
+
* Builds aggregate SELECT clause for MikroORM QueryBuilder.
|
|
109
|
+
* @param qb - the MikroORM QueryBuilder
|
|
110
|
+
* @param aggregate - the aggregates to select.
|
|
111
|
+
* @param alias - optional alias to use to qualify an identifier
|
|
112
|
+
*/
|
|
135
113
|
build(qb, aggregate, alias) {
|
|
136
114
|
const metadata = qb.mainAlias?.metadata;
|
|
137
115
|
const selects = [
|
|
138
116
|
...this.createGroupBySelect(aggregate.groupBy, alias, metadata),
|
|
139
|
-
...this.createAggSelect("COUNT"
|
|
140
|
-
...this.createAggSelect("SUM"
|
|
141
|
-
...this.createAggSelect("AVG"
|
|
142
|
-
...this.createAggSelect("MAX"
|
|
143
|
-
...this.createAggSelect("MIN"
|
|
117
|
+
...this.createAggSelect("COUNT", aggregate.count, alias, metadata),
|
|
118
|
+
...this.createAggSelect("SUM", aggregate.sum, alias, metadata),
|
|
119
|
+
...this.createAggSelect("AVG", aggregate.avg, alias, metadata),
|
|
120
|
+
...this.createAggSelect("MAX", aggregate.max, alias, metadata),
|
|
121
|
+
...this.createAggSelect("MIN", aggregate.min, alias, metadata)
|
|
144
122
|
];
|
|
145
123
|
if (!selects.length) {
|
|
146
|
-
throw new
|
|
124
|
+
throw new common.BadRequestException("No aggregate fields found.");
|
|
147
125
|
}
|
|
148
126
|
selects.forEach(([selectExpr, selectAlias]) => {
|
|
149
|
-
qb.addSelect(
|
|
127
|
+
qb.addSelect(core.raw(`${selectExpr} as "${selectAlias}"`));
|
|
150
128
|
});
|
|
151
129
|
return qb;
|
|
152
130
|
}
|
|
@@ -157,7 +135,10 @@ var AggregateBuilder = class _AggregateBuilder {
|
|
|
157
135
|
return fields.map((field) => {
|
|
158
136
|
const columnName = metadata ? this.getColumnName(metadata, field) : field;
|
|
159
137
|
const col = alias ? `\`${alias}\`.\`${columnName}\`` : `\`${columnName}\``;
|
|
160
|
-
return [
|
|
138
|
+
return [
|
|
139
|
+
`${func}(${col})`,
|
|
140
|
+
_AggregateBuilder.getAggregateAlias(func, field)
|
|
141
|
+
];
|
|
161
142
|
});
|
|
162
143
|
}
|
|
163
144
|
createGroupBySelect(fields, alias, metadata) {
|
|
@@ -167,27 +148,37 @@ var AggregateBuilder = class _AggregateBuilder {
|
|
|
167
148
|
return fields.map((field) => {
|
|
168
149
|
const columnName = metadata ? this.getColumnName(metadata, field) : field;
|
|
169
150
|
const col = alias ? `\`${alias}\`.\`${columnName}\`` : `\`${columnName}\``;
|
|
170
|
-
return [
|
|
151
|
+
return [
|
|
152
|
+
`${col}`,
|
|
153
|
+
_AggregateBuilder.getGroupByAlias(field)
|
|
154
|
+
];
|
|
171
155
|
});
|
|
172
156
|
}
|
|
173
157
|
};
|
|
174
158
|
|
|
175
159
|
// src/lib/query/where.builder.ts
|
|
176
160
|
var WhereBuilder = class {
|
|
161
|
+
static {
|
|
162
|
+
__name(this, "WhereBuilder");
|
|
163
|
+
}
|
|
177
164
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
165
|
+
* Builds a MikroORM FilterQuery from a nestjs-query Filter.
|
|
166
|
+
* @param filter - the filter to build the WHERE clause from.
|
|
167
|
+
*/
|
|
181
168
|
build(filter) {
|
|
182
169
|
const { and, or } = filter;
|
|
183
170
|
const conditions = [];
|
|
184
171
|
if (and && and.length) {
|
|
185
172
|
const andConditions = and.map((f) => this.build(f));
|
|
186
|
-
conditions.push({
|
|
173
|
+
conditions.push({
|
|
174
|
+
$and: andConditions
|
|
175
|
+
});
|
|
187
176
|
}
|
|
188
177
|
if (or && or.length) {
|
|
189
178
|
const orConditions = or.map((f) => this.build(f));
|
|
190
|
-
conditions.push({
|
|
179
|
+
conditions.push({
|
|
180
|
+
$or: orConditions
|
|
181
|
+
});
|
|
191
182
|
}
|
|
192
183
|
const fieldConditions = this.buildFieldComparisons(filter);
|
|
193
184
|
if (Object.keys(fieldConditions).length > 0) {
|
|
@@ -199,11 +190,13 @@ var WhereBuilder = class {
|
|
|
199
190
|
if (conditions.length === 1) {
|
|
200
191
|
return conditions[0];
|
|
201
192
|
}
|
|
202
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
$and: conditions
|
|
195
|
+
};
|
|
203
196
|
}
|
|
204
197
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
* Known nestjs-query comparison operators
|
|
199
|
+
*/
|
|
207
200
|
KNOWN_OPERATORS = /* @__PURE__ */ new Set([
|
|
208
201
|
"eq",
|
|
209
202
|
"neq",
|
|
@@ -223,8 +216,8 @@ var WhereBuilder = class {
|
|
|
223
216
|
"notbetween"
|
|
224
217
|
]);
|
|
225
218
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
219
|
+
* Check if an object contains comparison operators (not nested relation filters)
|
|
220
|
+
*/
|
|
228
221
|
isComparisonObject(obj) {
|
|
229
222
|
if (obj === null || typeof obj !== "object" || Array.isArray(obj)) {
|
|
230
223
|
return false;
|
|
@@ -233,9 +226,9 @@ var WhereBuilder = class {
|
|
|
233
226
|
return keys.some((key) => this.KNOWN_OPERATORS.has(key.toLowerCase()));
|
|
234
227
|
}
|
|
235
228
|
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
* Creates field comparisons from a filter. This method will ignore and/or properties.
|
|
230
|
+
* @param filter - the filter with fields to create comparisons for.
|
|
231
|
+
*/
|
|
239
232
|
buildFieldComparisons(filter) {
|
|
240
233
|
const result = {};
|
|
241
234
|
Object.keys(filter).forEach((field) => {
|
|
@@ -253,9 +246,9 @@ var WhereBuilder = class {
|
|
|
253
246
|
return result;
|
|
254
247
|
}
|
|
255
248
|
/**
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
* Builds a MikroORM comparison from a nestjs-query FilterFieldComparison.
|
|
250
|
+
* @param comparison - the comparison to convert.
|
|
251
|
+
*/
|
|
259
252
|
buildComparison(comparison) {
|
|
260
253
|
const conditions = {};
|
|
261
254
|
const operators = Object.keys(comparison);
|
|
@@ -270,75 +263,121 @@ var WhereBuilder = class {
|
|
|
270
263
|
return conditions;
|
|
271
264
|
}
|
|
272
265
|
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
266
|
+
* Maps a nestjs-query operator to a MikroORM operator.
|
|
267
|
+
* @param operator - the nestjs-query operator.
|
|
268
|
+
* @param value - the value to compare.
|
|
269
|
+
*/
|
|
277
270
|
mapOperator(operator, value) {
|
|
278
271
|
const normalizedOp = operator.toLowerCase();
|
|
279
272
|
switch (normalizedOp) {
|
|
280
273
|
case "eq":
|
|
281
|
-
return {
|
|
274
|
+
return {
|
|
275
|
+
$eq: value
|
|
276
|
+
};
|
|
282
277
|
case "neq":
|
|
283
|
-
return {
|
|
278
|
+
return {
|
|
279
|
+
$ne: value
|
|
280
|
+
};
|
|
284
281
|
case "gt":
|
|
285
|
-
return {
|
|
282
|
+
return {
|
|
283
|
+
$gt: value
|
|
284
|
+
};
|
|
286
285
|
case "gte":
|
|
287
|
-
return {
|
|
286
|
+
return {
|
|
287
|
+
$gte: value
|
|
288
|
+
};
|
|
288
289
|
case "lt":
|
|
289
|
-
return {
|
|
290
|
+
return {
|
|
291
|
+
$lt: value
|
|
292
|
+
};
|
|
290
293
|
case "lte":
|
|
291
|
-
return {
|
|
294
|
+
return {
|
|
295
|
+
$lte: value
|
|
296
|
+
};
|
|
292
297
|
case "like":
|
|
293
|
-
return {
|
|
298
|
+
return {
|
|
299
|
+
$like: value
|
|
300
|
+
};
|
|
294
301
|
case "notlike":
|
|
295
|
-
return {
|
|
302
|
+
return {
|
|
303
|
+
$not: {
|
|
304
|
+
$like: value
|
|
305
|
+
}
|
|
306
|
+
};
|
|
296
307
|
case "ilike":
|
|
297
|
-
return {
|
|
308
|
+
return {
|
|
309
|
+
$ilike: value
|
|
310
|
+
};
|
|
298
311
|
case "notilike":
|
|
299
|
-
return {
|
|
312
|
+
return {
|
|
313
|
+
$not: {
|
|
314
|
+
$ilike: value
|
|
315
|
+
}
|
|
316
|
+
};
|
|
300
317
|
case "in":
|
|
301
|
-
return {
|
|
318
|
+
return {
|
|
319
|
+
$in: value
|
|
320
|
+
};
|
|
302
321
|
case "notin":
|
|
303
|
-
return {
|
|
322
|
+
return {
|
|
323
|
+
$nin: value
|
|
324
|
+
};
|
|
304
325
|
case "is":
|
|
305
326
|
if (value === null) {
|
|
306
|
-
return {
|
|
327
|
+
return {
|
|
328
|
+
$eq: null
|
|
329
|
+
};
|
|
307
330
|
}
|
|
308
331
|
if (value === true) {
|
|
309
|
-
return {
|
|
332
|
+
return {
|
|
333
|
+
$eq: true
|
|
334
|
+
};
|
|
310
335
|
}
|
|
311
336
|
if (value === false) {
|
|
312
|
-
return {
|
|
337
|
+
return {
|
|
338
|
+
$eq: false
|
|
339
|
+
};
|
|
313
340
|
}
|
|
314
341
|
throw new Error(`Unexpected is operator param ${JSON.stringify(value)}`);
|
|
315
342
|
case "isnot":
|
|
316
343
|
if (value === null) {
|
|
317
|
-
return {
|
|
344
|
+
return {
|
|
345
|
+
$ne: null
|
|
346
|
+
};
|
|
318
347
|
}
|
|
319
348
|
if (value === true) {
|
|
320
|
-
return {
|
|
349
|
+
return {
|
|
350
|
+
$ne: true
|
|
351
|
+
};
|
|
321
352
|
}
|
|
322
353
|
if (value === false) {
|
|
323
|
-
return {
|
|
354
|
+
return {
|
|
355
|
+
$ne: false
|
|
356
|
+
};
|
|
324
357
|
}
|
|
325
358
|
throw new Error(`Unexpected isNot operator param ${JSON.stringify(value)}`);
|
|
326
359
|
case "between":
|
|
327
360
|
if (this.isBetweenValue(value)) {
|
|
328
|
-
return {
|
|
361
|
+
return {
|
|
362
|
+
$gte: value.lower,
|
|
363
|
+
$lte: value.upper
|
|
364
|
+
};
|
|
329
365
|
}
|
|
330
|
-
throw new Error(
|
|
331
|
-
`Invalid value for between expected {lower: val, upper: val} got ${JSON.stringify(value)}`
|
|
332
|
-
);
|
|
366
|
+
throw new Error(`Invalid value for between expected {lower: val, upper: val} got ${JSON.stringify(value)}`);
|
|
333
367
|
case "notbetween":
|
|
334
368
|
if (this.isBetweenValue(value)) {
|
|
335
369
|
return {
|
|
336
|
-
$or: [
|
|
370
|
+
$or: [
|
|
371
|
+
{
|
|
372
|
+
$lt: value.lower
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
$gt: value.upper
|
|
376
|
+
}
|
|
377
|
+
]
|
|
337
378
|
};
|
|
338
379
|
}
|
|
339
|
-
throw new Error(
|
|
340
|
-
`Invalid value for not between expected {lower: val, upper: val} got ${JSON.stringify(value)}`
|
|
341
|
-
);
|
|
380
|
+
throw new Error(`Invalid value for not between expected {lower: val, upper: val} got ${JSON.stringify(value)}`);
|
|
342
381
|
default:
|
|
343
382
|
throw new Error(`Unknown operator ${operator}`);
|
|
344
383
|
}
|
|
@@ -350,16 +389,22 @@ var WhereBuilder = class {
|
|
|
350
389
|
|
|
351
390
|
// src/lib/query/filter-query.builder.ts
|
|
352
391
|
var FilterQueryBuilder = class {
|
|
392
|
+
static {
|
|
393
|
+
__name(this, "FilterQueryBuilder");
|
|
394
|
+
}
|
|
395
|
+
repo;
|
|
396
|
+
whereBuilder;
|
|
397
|
+
aggregateBuilder;
|
|
353
398
|
constructor(repo, whereBuilder = new WhereBuilder(), aggregateBuilder = new AggregateBuilder()) {
|
|
354
399
|
this.repo = repo;
|
|
355
400
|
this.whereBuilder = whereBuilder;
|
|
356
401
|
this.aggregateBuilder = aggregateBuilder;
|
|
357
402
|
}
|
|
358
403
|
/**
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
404
|
+
* Create a MikroORM QueryBuilder with `WHERE`, `ORDER BY` and `LIMIT/OFFSET` clauses.
|
|
405
|
+
*
|
|
406
|
+
* @param query - the query to apply.
|
|
407
|
+
*/
|
|
363
408
|
select(query) {
|
|
364
409
|
const alias = this.getEntityAlias();
|
|
365
410
|
const qb = this.createQueryBuilder(alias);
|
|
@@ -374,9 +419,15 @@ var FilterQueryBuilder = class {
|
|
|
374
419
|
const metadata = this.repo.getEntityManager().getMetadata().get(this.repo.getEntityName());
|
|
375
420
|
const primaryKey = metadata.primaryKeys[0];
|
|
376
421
|
if (Array.isArray(id)) {
|
|
377
|
-
qb.where({
|
|
422
|
+
qb.where({
|
|
423
|
+
[primaryKey]: {
|
|
424
|
+
$in: id
|
|
425
|
+
}
|
|
426
|
+
});
|
|
378
427
|
} else {
|
|
379
|
-
qb.where({
|
|
428
|
+
qb.where({
|
|
429
|
+
[primaryKey]: id
|
|
430
|
+
});
|
|
380
431
|
}
|
|
381
432
|
this.applyFilter(qb, query.filter, alias);
|
|
382
433
|
this.applySorting(qb, query.sorting, alias);
|
|
@@ -393,10 +444,10 @@ var FilterQueryBuilder = class {
|
|
|
393
444
|
return qb;
|
|
394
445
|
}
|
|
395
446
|
/**
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
447
|
+
* Applies paging to a MikroORM query builder
|
|
448
|
+
* @param qb - the MikroORM QueryBuilder
|
|
449
|
+
* @param paging - the Paging options.
|
|
450
|
+
*/
|
|
400
451
|
applyPaging(qb, paging) {
|
|
401
452
|
if (!paging) {
|
|
402
453
|
return qb;
|
|
@@ -410,22 +461,22 @@ var FilterQueryBuilder = class {
|
|
|
410
461
|
return qb;
|
|
411
462
|
}
|
|
412
463
|
/**
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
464
|
+
* Applies the aggregate selects from a Query to a MikroORM QueryBuilder.
|
|
465
|
+
*
|
|
466
|
+
* @param qb - the MikroORM QueryBuilder.
|
|
467
|
+
* @param aggregate - the aggregates to select.
|
|
468
|
+
* @param alias - optional alias to use to qualify an identifier
|
|
469
|
+
*/
|
|
419
470
|
applyAggregate(qb, aggregate, alias) {
|
|
420
471
|
return this.aggregateBuilder.build(qb, aggregate, alias);
|
|
421
472
|
}
|
|
422
473
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
474
|
+
* Applies the filter from a Query to a MikroORM QueryBuilder.
|
|
475
|
+
*
|
|
476
|
+
* @param qb - the MikroORM QueryBuilder.
|
|
477
|
+
* @param filter - the filter.
|
|
478
|
+
* @param _alias - optional alias to use to qualify an identifier (unused in MikroORM)
|
|
479
|
+
*/
|
|
429
480
|
applyFilter(qb, filter, _alias) {
|
|
430
481
|
if (!filter) {
|
|
431
482
|
return qb;
|
|
@@ -434,26 +485,26 @@ var FilterQueryBuilder = class {
|
|
|
434
485
|
return qb.andWhere(mikroOrmFilter);
|
|
435
486
|
}
|
|
436
487
|
/**
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
488
|
+
* Applies the ORDER BY clause to a MikroORM QueryBuilder.
|
|
489
|
+
* @param qb - the MikroORM QueryBuilder.
|
|
490
|
+
* @param sorts - an array of SortFields to create the ORDER BY clause.
|
|
491
|
+
* @param _alias - optional alias to use to qualify an identifier (unused in MikroORM)
|
|
492
|
+
*/
|
|
442
493
|
applySorting(qb, sorts, _alias) {
|
|
443
494
|
if (!sorts || sorts.length === 0) {
|
|
444
495
|
return qb;
|
|
445
496
|
}
|
|
446
|
-
const orderBy = sorts.reduce(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
);
|
|
497
|
+
const orderBy = sorts.reduce((acc, { field, direction, nulls }) => {
|
|
498
|
+
const order = direction === "ASC" ? "asc" : "desc";
|
|
499
|
+
let orderValue = order;
|
|
500
|
+
if (nulls) {
|
|
501
|
+
orderValue = `${order} ${nulls.toLowerCase().replace("_", " ")}`;
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
...acc,
|
|
505
|
+
[field]: orderValue
|
|
506
|
+
};
|
|
507
|
+
}, {});
|
|
457
508
|
return qb.orderBy(orderBy);
|
|
458
509
|
}
|
|
459
510
|
applyGroupBy(qb, groupBy, _alias) {
|
|
@@ -469,36 +520,33 @@ var FilterQueryBuilder = class {
|
|
|
469
520
|
if (!groupBy || groupBy.length === 0) {
|
|
470
521
|
return qb;
|
|
471
522
|
}
|
|
472
|
-
const orderBy = groupBy.reduce(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}),
|
|
477
|
-
{}
|
|
478
|
-
);
|
|
523
|
+
const orderBy = groupBy.reduce((acc, field) => ({
|
|
524
|
+
...acc,
|
|
525
|
+
[field]: "asc"
|
|
526
|
+
}), {});
|
|
479
527
|
return qb.orderBy(orderBy);
|
|
480
528
|
}
|
|
481
529
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
530
|
+
* Create a MikroORM QueryBuilder.
|
|
531
|
+
*/
|
|
484
532
|
createQueryBuilder(alias) {
|
|
485
533
|
return this.repo.createQueryBuilder(alias);
|
|
486
534
|
}
|
|
487
535
|
/**
|
|
488
|
-
|
|
489
|
-
|
|
536
|
+
* Gets the entity alias based on the entity name.
|
|
537
|
+
*/
|
|
490
538
|
getEntityAlias() {
|
|
491
539
|
const em = this.repo.getEntityManager();
|
|
492
540
|
const meta = em.getMetadata().get(this.repo.getEntityName());
|
|
493
541
|
return meta.className;
|
|
494
542
|
}
|
|
495
543
|
/**
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
544
|
+
* Checks if a filter references any relations.
|
|
545
|
+
* @param filter
|
|
546
|
+
* @private
|
|
547
|
+
*
|
|
548
|
+
* @returns true if there are any referenced relations
|
|
549
|
+
*/
|
|
502
550
|
filterHasRelations(filter) {
|
|
503
551
|
if (!filter) {
|
|
504
552
|
return false;
|
|
@@ -507,7 +555,7 @@ var FilterQueryBuilder = class {
|
|
|
507
555
|
}
|
|
508
556
|
getReferencedRelations(filter) {
|
|
509
557
|
const relationNames = this.relationNames;
|
|
510
|
-
const referencedFields =
|
|
558
|
+
const referencedFields = core$1.getFilterFields(filter);
|
|
511
559
|
return referencedFields.filter((f) => relationNames.includes(f));
|
|
512
560
|
}
|
|
513
561
|
getReferencedRelationsRecursive(metadataOrFilter = {}, filter) {
|
|
@@ -524,14 +572,12 @@ var FilterQueryBuilder = class {
|
|
|
524
572
|
metadata = em.getMetadata().get(this.repo.getEntityName());
|
|
525
573
|
actualFilter = metadataOrFilter;
|
|
526
574
|
}
|
|
527
|
-
const referencedFields = Array.from(
|
|
528
|
-
new Set(Object.keys(actualFilter))
|
|
529
|
-
);
|
|
575
|
+
const referencedFields = Array.from(new Set(Object.keys(actualFilter)));
|
|
530
576
|
return referencedFields.reduce((prev, curr) => {
|
|
531
577
|
const currFilterValue = actualFilter[curr];
|
|
532
578
|
if ((curr === "and" || curr === "or") && currFilterValue) {
|
|
533
579
|
for (const subFilter of currFilterValue) {
|
|
534
|
-
prev =
|
|
580
|
+
prev = merge__default.default(prev, this.getReferencedRelationsRecursiveInternal(metadata, subFilter));
|
|
535
581
|
}
|
|
536
582
|
}
|
|
537
583
|
const referencedRelation = metadata.relations.find((r) => r.name === curr);
|
|
@@ -541,7 +587,7 @@ var FilterQueryBuilder = class {
|
|
|
541
587
|
const nestedRelations = nestedFilter ? this.getReferencedRelationsRecursiveInternal(targetMeta, nestedFilter) : {};
|
|
542
588
|
return {
|
|
543
589
|
...prev,
|
|
544
|
-
[curr]:
|
|
590
|
+
[curr]: merge__default.default(prev[curr] ?? {}, nestedRelations)
|
|
545
591
|
};
|
|
546
592
|
}, {});
|
|
547
593
|
}
|
|
@@ -552,7 +598,7 @@ var FilterQueryBuilder = class {
|
|
|
552
598
|
const currFilterValue = filter[curr];
|
|
553
599
|
if ((curr === "and" || curr === "or") && currFilterValue) {
|
|
554
600
|
for (const subFilter of currFilterValue) {
|
|
555
|
-
prev =
|
|
601
|
+
prev = merge__default.default(prev, this.getReferencedRelationsRecursiveInternal(metadata, subFilter));
|
|
556
602
|
}
|
|
557
603
|
}
|
|
558
604
|
const referencedRelation = metadata.relations.find((r) => r.name === curr);
|
|
@@ -562,7 +608,7 @@ var FilterQueryBuilder = class {
|
|
|
562
608
|
const nestedRelations = nestedFilter ? this.getReferencedRelationsRecursiveInternal(targetMeta, nestedFilter) : {};
|
|
563
609
|
return {
|
|
564
610
|
...prev,
|
|
565
|
-
[curr]:
|
|
611
|
+
[curr]: merge__default.default(prev[curr] ?? {}, nestedRelations)
|
|
566
612
|
};
|
|
567
613
|
}, {});
|
|
568
614
|
}
|
|
@@ -575,46 +621,101 @@ var FilterQueryBuilder = class {
|
|
|
575
621
|
|
|
576
622
|
// src/lib/query/sql-comparison.builder.ts
|
|
577
623
|
var SQLComparisonBuilder = class {
|
|
624
|
+
static {
|
|
625
|
+
__name(this, "SQLComparisonBuilder");
|
|
626
|
+
}
|
|
578
627
|
/**
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
628
|
+
* Maps a comparison operator to MikroORM filter format.
|
|
629
|
+
*
|
|
630
|
+
* @param field - the property in Entity to create the comparison for.
|
|
631
|
+
* @param cmp - the FilterComparisonOperator (eq, neq, gt, etc...)
|
|
632
|
+
* @param val - the value to compare to
|
|
633
|
+
*/
|
|
585
634
|
build(field, cmp, val) {
|
|
586
635
|
const normalizedCmp = cmp.toLowerCase();
|
|
587
636
|
switch (normalizedCmp) {
|
|
588
637
|
case "eq":
|
|
589
|
-
return {
|
|
638
|
+
return {
|
|
639
|
+
[field]: {
|
|
640
|
+
$eq: val
|
|
641
|
+
}
|
|
642
|
+
};
|
|
590
643
|
case "neq":
|
|
591
|
-
return {
|
|
644
|
+
return {
|
|
645
|
+
[field]: {
|
|
646
|
+
$ne: val
|
|
647
|
+
}
|
|
648
|
+
};
|
|
592
649
|
case "gt":
|
|
593
|
-
return {
|
|
650
|
+
return {
|
|
651
|
+
[field]: {
|
|
652
|
+
$gt: val
|
|
653
|
+
}
|
|
654
|
+
};
|
|
594
655
|
case "gte":
|
|
595
|
-
return {
|
|
656
|
+
return {
|
|
657
|
+
[field]: {
|
|
658
|
+
$gte: val
|
|
659
|
+
}
|
|
660
|
+
};
|
|
596
661
|
case "lt":
|
|
597
|
-
return {
|
|
662
|
+
return {
|
|
663
|
+
[field]: {
|
|
664
|
+
$lt: val
|
|
665
|
+
}
|
|
666
|
+
};
|
|
598
667
|
case "lte":
|
|
599
|
-
return {
|
|
668
|
+
return {
|
|
669
|
+
[field]: {
|
|
670
|
+
$lte: val
|
|
671
|
+
}
|
|
672
|
+
};
|
|
600
673
|
case "like":
|
|
601
|
-
return {
|
|
674
|
+
return {
|
|
675
|
+
[field]: {
|
|
676
|
+
$like: val
|
|
677
|
+
}
|
|
678
|
+
};
|
|
602
679
|
case "notlike":
|
|
603
|
-
return {
|
|
680
|
+
return {
|
|
681
|
+
[field]: {
|
|
682
|
+
$not: {
|
|
683
|
+
$like: val
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
};
|
|
604
687
|
case "ilike":
|
|
605
|
-
return {
|
|
688
|
+
return {
|
|
689
|
+
[field]: {
|
|
690
|
+
$ilike: val
|
|
691
|
+
}
|
|
692
|
+
};
|
|
606
693
|
case "notilike":
|
|
607
|
-
return {
|
|
694
|
+
return {
|
|
695
|
+
[field]: {
|
|
696
|
+
$not: {
|
|
697
|
+
$ilike: val
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
};
|
|
608
701
|
case "is":
|
|
609
702
|
return this.isComparison(field, val);
|
|
610
703
|
case "isnot":
|
|
611
704
|
return this.isNotComparison(field, val);
|
|
612
705
|
case "in":
|
|
613
706
|
this.checkNonEmptyArray(val);
|
|
614
|
-
return {
|
|
707
|
+
return {
|
|
708
|
+
[field]: {
|
|
709
|
+
$in: val
|
|
710
|
+
}
|
|
711
|
+
};
|
|
615
712
|
case "notin":
|
|
616
713
|
this.checkNonEmptyArray(val);
|
|
617
|
-
return {
|
|
714
|
+
return {
|
|
715
|
+
[field]: {
|
|
716
|
+
$nin: val
|
|
717
|
+
}
|
|
718
|
+
};
|
|
618
719
|
case "between":
|
|
619
720
|
return this.betweenComparison(field, val);
|
|
620
721
|
case "notbetween":
|
|
@@ -625,25 +726,49 @@ var SQLComparisonBuilder = class {
|
|
|
625
726
|
}
|
|
626
727
|
isComparison(field, val) {
|
|
627
728
|
if (val === null) {
|
|
628
|
-
return {
|
|
729
|
+
return {
|
|
730
|
+
[field]: {
|
|
731
|
+
$eq: null
|
|
732
|
+
}
|
|
733
|
+
};
|
|
629
734
|
}
|
|
630
735
|
if (val === true) {
|
|
631
|
-
return {
|
|
736
|
+
return {
|
|
737
|
+
[field]: {
|
|
738
|
+
$eq: true
|
|
739
|
+
}
|
|
740
|
+
};
|
|
632
741
|
}
|
|
633
742
|
if (val === false) {
|
|
634
|
-
return {
|
|
743
|
+
return {
|
|
744
|
+
[field]: {
|
|
745
|
+
$eq: false
|
|
746
|
+
}
|
|
747
|
+
};
|
|
635
748
|
}
|
|
636
749
|
throw new Error(`Unexpected is operator param ${JSON.stringify(val)}`);
|
|
637
750
|
}
|
|
638
751
|
isNotComparison(field, val) {
|
|
639
752
|
if (val === null) {
|
|
640
|
-
return {
|
|
753
|
+
return {
|
|
754
|
+
[field]: {
|
|
755
|
+
$ne: null
|
|
756
|
+
}
|
|
757
|
+
};
|
|
641
758
|
}
|
|
642
759
|
if (val === true) {
|
|
643
|
-
return {
|
|
760
|
+
return {
|
|
761
|
+
[field]: {
|
|
762
|
+
$ne: true
|
|
763
|
+
}
|
|
764
|
+
};
|
|
644
765
|
}
|
|
645
766
|
if (val === false) {
|
|
646
|
-
return {
|
|
767
|
+
return {
|
|
768
|
+
[field]: {
|
|
769
|
+
$ne: false
|
|
770
|
+
}
|
|
771
|
+
};
|
|
647
772
|
}
|
|
648
773
|
throw new Error(`Unexpected isNot operator param ${JSON.stringify(val)}`);
|
|
649
774
|
}
|
|
@@ -664,19 +789,26 @@ var SQLComparisonBuilder = class {
|
|
|
664
789
|
}
|
|
665
790
|
};
|
|
666
791
|
}
|
|
667
|
-
throw new Error(
|
|
668
|
-
`Invalid value for between expected {lower: val, upper: val} got ${JSON.stringify(val)}`
|
|
669
|
-
);
|
|
792
|
+
throw new Error(`Invalid value for between expected {lower: val, upper: val} got ${JSON.stringify(val)}`);
|
|
670
793
|
}
|
|
671
794
|
notBetweenComparison(field, val) {
|
|
672
795
|
if (this.isBetweenVal(val)) {
|
|
673
796
|
return {
|
|
674
|
-
$or: [
|
|
797
|
+
$or: [
|
|
798
|
+
{
|
|
799
|
+
[field]: {
|
|
800
|
+
$lt: val.lower
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
[field]: {
|
|
805
|
+
$gt: val.upper
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
]
|
|
675
809
|
};
|
|
676
810
|
}
|
|
677
|
-
throw new Error(
|
|
678
|
-
`Invalid value for not between expected {lower: val, upper: val} got ${JSON.stringify(val)}`
|
|
679
|
-
);
|
|
811
|
+
throw new Error(`Invalid value for not between expected {lower: val, upper: val} got ${JSON.stringify(val)}`);
|
|
680
812
|
}
|
|
681
813
|
isBetweenVal(val) {
|
|
682
814
|
return val !== null && typeof val === "object" && "lower" in val && "upper" in val;
|
|
@@ -685,21 +817,24 @@ var SQLComparisonBuilder = class {
|
|
|
685
817
|
|
|
686
818
|
// src/lib/query/relation-query.builder.ts
|
|
687
819
|
var RelationQueryBuilder = class {
|
|
820
|
+
static {
|
|
821
|
+
__name(this, "RelationQueryBuilder");
|
|
822
|
+
}
|
|
823
|
+
repo;
|
|
824
|
+
relation;
|
|
825
|
+
filterQueryBuilder;
|
|
688
826
|
constructor(repo, relation) {
|
|
689
827
|
this.repo = repo;
|
|
690
828
|
this.relation = relation;
|
|
691
829
|
const relationMeta = this.getRelationMeta();
|
|
692
830
|
const em = this.repo.getEntityManager();
|
|
693
|
-
const relationRepo = em.getRepository(
|
|
694
|
-
relationMeta.type
|
|
695
|
-
);
|
|
831
|
+
const relationRepo = em.getRepository(relationMeta.type);
|
|
696
832
|
this.filterQueryBuilder = new FilterQueryBuilder(relationRepo);
|
|
697
833
|
}
|
|
698
|
-
filterQueryBuilder;
|
|
699
834
|
/**
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
835
|
+
* Builds and returns a QueryBuilder for selecting relations without executing it.
|
|
836
|
+
* This is useful for testing or when you need to inspect/modify the query before execution.
|
|
837
|
+
*/
|
|
703
838
|
select(entity, query) {
|
|
704
839
|
const relationMeta = this.getRelationMeta();
|
|
705
840
|
const em = this.repo.getEntityManager();
|
|
@@ -731,8 +866,8 @@ var RelationQueryBuilder = class {
|
|
|
731
866
|
return qb;
|
|
732
867
|
}
|
|
733
868
|
/**
|
|
734
|
-
|
|
735
|
-
|
|
869
|
+
* Executes the select query and returns the results.
|
|
870
|
+
*/
|
|
736
871
|
async selectAndExecute(entity, query) {
|
|
737
872
|
const qb = this.select(entity, query);
|
|
738
873
|
return qb.getResultList();
|
|
@@ -797,7 +932,9 @@ var RelationQueryBuilder = class {
|
|
|
797
932
|
fkValue = relationValue;
|
|
798
933
|
}
|
|
799
934
|
}
|
|
800
|
-
return {
|
|
935
|
+
return {
|
|
936
|
+
[relationPrimaryKey]: fkValue
|
|
937
|
+
};
|
|
801
938
|
}
|
|
802
939
|
if (relationMeta.kind === "1:1") {
|
|
803
940
|
if (relationMeta.owner) {
|
|
@@ -815,25 +952,39 @@ var RelationQueryBuilder = class {
|
|
|
815
952
|
}
|
|
816
953
|
}
|
|
817
954
|
if (fkValue === void 0 && relationMeta.inversedBy) {
|
|
818
|
-
return {
|
|
955
|
+
return {
|
|
956
|
+
[relationMeta.inversedBy]: entityId
|
|
957
|
+
};
|
|
819
958
|
}
|
|
820
|
-
return {
|
|
959
|
+
return {
|
|
960
|
+
[relationPrimaryKey]: fkValue
|
|
961
|
+
};
|
|
821
962
|
} else {
|
|
822
|
-
return {
|
|
963
|
+
return {
|
|
964
|
+
[relationMeta.mappedBy]: entityId
|
|
965
|
+
};
|
|
823
966
|
}
|
|
824
967
|
}
|
|
825
968
|
if (relationMeta.kind === "1:m") {
|
|
826
969
|
const mappedBy = relationMeta.mappedBy;
|
|
827
|
-
return {
|
|
970
|
+
return {
|
|
971
|
+
[mappedBy]: entityId
|
|
972
|
+
};
|
|
828
973
|
}
|
|
829
974
|
if (relationMeta.kind === "m:n") {
|
|
830
975
|
if (relationMeta.owner) {
|
|
831
|
-
return {
|
|
976
|
+
return {
|
|
977
|
+
[relationMeta.inversedBy]: entityId
|
|
978
|
+
};
|
|
832
979
|
} else {
|
|
833
|
-
return {
|
|
980
|
+
return {
|
|
981
|
+
[relationMeta.mappedBy]: entityId
|
|
982
|
+
};
|
|
834
983
|
}
|
|
835
984
|
}
|
|
836
|
-
return {
|
|
985
|
+
return {
|
|
986
|
+
[entityPrimaryKey]: entityId
|
|
987
|
+
};
|
|
837
988
|
}
|
|
838
989
|
getRelationMeta() {
|
|
839
990
|
const em = this.repo.getEntityManager();
|
|
@@ -860,38 +1011,27 @@ var RelationQueryBuilder = class {
|
|
|
860
1011
|
});
|
|
861
1012
|
}
|
|
862
1013
|
};
|
|
863
|
-
|
|
864
|
-
// src/lib/services/relation-query.service.ts
|
|
865
|
-
var import_core3 = require("@mikro-orm/core");
|
|
866
|
-
var import_core4 = require("@nestjs-query/core");
|
|
867
1014
|
var RelationQueryService = class {
|
|
1015
|
+
static {
|
|
1016
|
+
__name(this, "RelationQueryService");
|
|
1017
|
+
}
|
|
868
1018
|
async queryRelations(RelationClass, relationName, dto, query) {
|
|
869
1019
|
if (Array.isArray(dto)) {
|
|
870
1020
|
return this.batchQueryRelations(RelationClass, relationName, dto, query);
|
|
871
1021
|
}
|
|
872
|
-
const assembler =
|
|
873
|
-
RelationClass,
|
|
874
|
-
this.getRelationEntity(relationName)
|
|
875
|
-
);
|
|
1022
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
876
1023
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
877
|
-
return assembler.convertAsyncToDTOs(
|
|
878
|
-
relationQueryBuilder.selectAndExecute(dto, assembler.convertQuery(query))
|
|
879
|
-
);
|
|
1024
|
+
return assembler.convertAsyncToDTOs(relationQueryBuilder.selectAndExecute(dto, assembler.convertQuery(query)));
|
|
880
1025
|
}
|
|
881
1026
|
async aggregateRelations(RelationClass, relationName, dto, filter, aggregate) {
|
|
882
1027
|
if (Array.isArray(dto)) {
|
|
883
1028
|
return this.batchAggregateRelations(RelationClass, relationName, dto, filter, aggregate);
|
|
884
1029
|
}
|
|
885
|
-
const assembler =
|
|
886
|
-
RelationClass,
|
|
887
|
-
this.getRelationEntity(relationName)
|
|
888
|
-
);
|
|
1030
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
889
1031
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
890
|
-
const rawResults = await relationQueryBuilder.aggregate(
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
assembler.convertAggregateQuery(aggregate)
|
|
894
|
-
);
|
|
1032
|
+
const rawResults = await relationQueryBuilder.aggregate(dto, assembler.convertQuery({
|
|
1033
|
+
filter
|
|
1034
|
+
}), assembler.convertAggregateQuery(aggregate));
|
|
895
1035
|
const aggResponse = AggregateBuilder.convertToAggregateResponse(rawResults);
|
|
896
1036
|
return aggResponse.map((agg) => {
|
|
897
1037
|
const res = assembler.convertAggregateResponse(agg);
|
|
@@ -902,43 +1042,37 @@ var RelationQueryService = class {
|
|
|
902
1042
|
if (Array.isArray(dto)) {
|
|
903
1043
|
return this.batchCountRelations(RelationClass, relationName, dto, filter);
|
|
904
1044
|
}
|
|
905
|
-
const assembler =
|
|
906
|
-
RelationClass,
|
|
907
|
-
this.getRelationEntity(relationName)
|
|
908
|
-
);
|
|
1045
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
909
1046
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
910
|
-
return relationQueryBuilder.count(dto, assembler.convertQuery({
|
|
1047
|
+
return relationQueryBuilder.count(dto, assembler.convertQuery({
|
|
1048
|
+
filter
|
|
1049
|
+
}));
|
|
911
1050
|
}
|
|
912
1051
|
async findRelation(RelationClass, relationName, dto, opts) {
|
|
913
1052
|
if (Array.isArray(dto)) {
|
|
914
1053
|
return this.batchFindRelations(RelationClass, relationName, dto, opts);
|
|
915
1054
|
}
|
|
916
|
-
const assembler =
|
|
917
|
-
RelationClass,
|
|
918
|
-
this.getRelationEntity(relationName)
|
|
919
|
-
);
|
|
1055
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
920
1056
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
921
1057
|
const relations = await relationQueryBuilder.selectAndExecute(dto, {
|
|
922
1058
|
filter: opts?.filter,
|
|
923
|
-
paging: {
|
|
1059
|
+
paging: {
|
|
1060
|
+
limit: 1
|
|
1061
|
+
}
|
|
924
1062
|
});
|
|
925
1063
|
const relationEntity = relations[0];
|
|
926
1064
|
return relationEntity ? assembler.convertToDTO(relationEntity) : void 0;
|
|
927
1065
|
}
|
|
928
1066
|
/**
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1067
|
+
* Add a single relation.
|
|
1068
|
+
* @param id - The id of the entity to add the relation to.
|
|
1069
|
+
* @param relationName - The name of the relation to query for.
|
|
1070
|
+
* @param relationIds - The ids of relations to add.
|
|
1071
|
+
* @param opts - Addition options
|
|
1072
|
+
*/
|
|
935
1073
|
async addRelations(relationName, id, relationIds, opts) {
|
|
936
1074
|
const entity = await this.getById(id, opts);
|
|
937
|
-
const relations = await this.getRelations(
|
|
938
|
-
relationName,
|
|
939
|
-
relationIds,
|
|
940
|
-
opts?.relationFilter
|
|
941
|
-
);
|
|
1075
|
+
const relations = await this.getRelations(relationName, relationIds, opts?.relationFilter);
|
|
942
1076
|
if (!this.foundAllRelations(relationIds, relations)) {
|
|
943
1077
|
throw new Error(`Unable to find all ${relationName} to add to ${this.EntityClass.name}`);
|
|
944
1078
|
}
|
|
@@ -952,21 +1086,17 @@ var RelationQueryService = class {
|
|
|
952
1086
|
return entity;
|
|
953
1087
|
}
|
|
954
1088
|
/**
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1089
|
+
* Set the relations on the entity.
|
|
1090
|
+
*
|
|
1091
|
+
* @param id - The id of the entity to set the relation on.
|
|
1092
|
+
* @param relationName - The name of the relation to query for.
|
|
1093
|
+
* @param relationIds - The ids of the relation to set on the entity. If the relationIds is empty all relations
|
|
1094
|
+
* will be removed.
|
|
1095
|
+
* @param opts - Additional options
|
|
1096
|
+
*/
|
|
963
1097
|
async setRelations(relationName, id, relationIds, opts) {
|
|
964
1098
|
const entity = await this.getById(id, opts);
|
|
965
|
-
const relations = await this.getRelations(
|
|
966
|
-
relationName,
|
|
967
|
-
relationIds,
|
|
968
|
-
opts?.relationFilter
|
|
969
|
-
);
|
|
1099
|
+
const relations = await this.getRelations(relationName, relationIds, opts?.relationFilter);
|
|
970
1100
|
if (relationIds.length) {
|
|
971
1101
|
if (!this.foundAllRelations(relationIds, relations)) {
|
|
972
1102
|
throw new Error(`Unable to find all ${relationName} to set on ${this.EntityClass.name}`);
|
|
@@ -981,37 +1111,37 @@ var RelationQueryService = class {
|
|
|
981
1111
|
return entity;
|
|
982
1112
|
}
|
|
983
1113
|
/**
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1114
|
+
* Set the relation on the entity.
|
|
1115
|
+
*
|
|
1116
|
+
* @param id - The id of the entity to set the relation on.
|
|
1117
|
+
* @param relationName - The name of the relation to query for.
|
|
1118
|
+
* @param relationId - The id of the relation to set on the entity.
|
|
1119
|
+
* @param opts - Additional options
|
|
1120
|
+
*/
|
|
991
1121
|
async setRelation(relationName, id, relationId, opts) {
|
|
992
1122
|
const entity = await this.getById(id, opts);
|
|
993
|
-
const relation = (await this.getRelations(relationName, [
|
|
1123
|
+
const relation = (await this.getRelations(relationName, [
|
|
1124
|
+
relationId
|
|
1125
|
+
], opts?.relationFilter))[0];
|
|
994
1126
|
if (!relation) {
|
|
995
1127
|
throw new Error(`Unable to find ${relationName} to set on ${this.EntityClass.name}`);
|
|
996
1128
|
}
|
|
997
|
-
|
|
1129
|
+
core.wrap(entity).assign({
|
|
1130
|
+
[relationName]: relation
|
|
1131
|
+
});
|
|
998
1132
|
await this.repo.getEntityManager().flush();
|
|
999
1133
|
return entity;
|
|
1000
1134
|
}
|
|
1001
1135
|
/**
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1136
|
+
* Removes multiple relations.
|
|
1137
|
+
* @param id - The id of the entity to add the relation to.
|
|
1138
|
+
* @param relationName - The name of the relation to query for.
|
|
1139
|
+
* @param relationIds - The ids of the relations to add.
|
|
1140
|
+
* @param opts - Additional options
|
|
1141
|
+
*/
|
|
1008
1142
|
async removeRelations(relationName, id, relationIds, opts) {
|
|
1009
1143
|
const entity = await this.getById(id, opts);
|
|
1010
|
-
const relations = await this.getRelations(
|
|
1011
|
-
relationName,
|
|
1012
|
-
relationIds,
|
|
1013
|
-
opts?.relationFilter
|
|
1014
|
-
);
|
|
1144
|
+
const relations = await this.getRelations(relationName, relationIds, opts?.relationFilter);
|
|
1015
1145
|
if (!this.foundAllRelations(relationIds, relations)) {
|
|
1016
1146
|
throw new Error(`Unable to find all ${relationName} to remove from ${this.EntityClass.name}`);
|
|
1017
1147
|
}
|
|
@@ -1026,26 +1156,30 @@ var RelationQueryService = class {
|
|
|
1026
1156
|
return entity;
|
|
1027
1157
|
}
|
|
1028
1158
|
/**
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1159
|
+
* Remove the relation on the entity.
|
|
1160
|
+
*
|
|
1161
|
+
* @param id - The id of the entity to set the relation on.
|
|
1162
|
+
* @param relationName - The name of the relation to query for.
|
|
1163
|
+
* @param relationId - The id of the relation to set on the entity.
|
|
1164
|
+
*/
|
|
1035
1165
|
async removeRelation(relationName, id, relationId, opts) {
|
|
1036
1166
|
const entity = await this.getById(id, opts);
|
|
1037
|
-
const relation = (await this.getRelations(relationName, [
|
|
1167
|
+
const relation = (await this.getRelations(relationName, [
|
|
1168
|
+
relationId
|
|
1169
|
+
], opts?.relationFilter))[0];
|
|
1038
1170
|
if (!relation) {
|
|
1039
1171
|
throw new Error(`Unable to find ${relationName} to remove from ${this.EntityClass.name}`);
|
|
1040
1172
|
}
|
|
1041
1173
|
const meta = this.getRelationMeta(relationName);
|
|
1042
1174
|
if (meta.kind === "1:1" || meta.kind === "m:1") {
|
|
1043
1175
|
const fkFieldName = `${relationName}Id`;
|
|
1044
|
-
const assignData = {
|
|
1176
|
+
const assignData = {
|
|
1177
|
+
[relationName]: null
|
|
1178
|
+
};
|
|
1045
1179
|
if (fkFieldName in entity) {
|
|
1046
1180
|
assignData[fkFieldName] = null;
|
|
1047
1181
|
}
|
|
1048
|
-
|
|
1182
|
+
core.wrap(entity).assign(assignData);
|
|
1049
1183
|
} else {
|
|
1050
1184
|
const collection = entity[relationName];
|
|
1051
1185
|
if (collection && typeof collection.remove === "function") {
|
|
@@ -1060,95 +1194,79 @@ var RelationQueryService = class {
|
|
|
1060
1194
|
return new RelationQueryBuilder(this.repo, name);
|
|
1061
1195
|
}
|
|
1062
1196
|
/**
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1197
|
+
* Query for an array of relations for multiple dtos.
|
|
1198
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
1199
|
+
* @param entities - The entities to query relations for.
|
|
1200
|
+
* @param relationName - The name of relation to query for.
|
|
1201
|
+
* @param query - A query to filter, page or sort relations.
|
|
1202
|
+
*/
|
|
1069
1203
|
async batchQueryRelations(RelationClass, relationName, entities, query) {
|
|
1070
|
-
const assembler =
|
|
1071
|
-
RelationClass,
|
|
1072
|
-
this.getRelationEntity(relationName)
|
|
1073
|
-
);
|
|
1204
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
1074
1205
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
1075
1206
|
const convertedQuery = assembler.convertQuery(query);
|
|
1076
1207
|
const results = /* @__PURE__ */ new Map();
|
|
1077
|
-
await Promise.all(
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
})
|
|
1085
|
-
);
|
|
1208
|
+
await Promise.all(entities.map(async (entity) => {
|
|
1209
|
+
const relations = await relationQueryBuilder.selectAndExecute(entity, convertedQuery);
|
|
1210
|
+
const relationDtos = assembler.convertToDTOs(relations);
|
|
1211
|
+
if (relationDtos.length > 0) {
|
|
1212
|
+
results.set(entity, relationDtos);
|
|
1213
|
+
}
|
|
1214
|
+
}));
|
|
1086
1215
|
return results;
|
|
1087
1216
|
}
|
|
1088
1217
|
/**
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1218
|
+
* Query for an array of relations for multiple dtos.
|
|
1219
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
1220
|
+
* @param entities - The entities to query relations for.
|
|
1221
|
+
* @param relationName - The name of relation to query for.
|
|
1222
|
+
* @param query - A query to filter, page or sort relations.
|
|
1223
|
+
*/
|
|
1095
1224
|
async batchAggregateRelations(RelationClass, relationName, entities, filter, aggregate) {
|
|
1096
|
-
const assembler =
|
|
1097
|
-
RelationClass,
|
|
1098
|
-
this.getRelationEntity(relationName)
|
|
1099
|
-
);
|
|
1225
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
1100
1226
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
1101
|
-
const convertedQuery = assembler.convertQuery({
|
|
1227
|
+
const convertedQuery = assembler.convertQuery({
|
|
1228
|
+
filter
|
|
1229
|
+
});
|
|
1102
1230
|
const results = /* @__PURE__ */ new Map();
|
|
1103
|
-
await Promise.all(
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
assembler.convertAggregateQuery(aggregate)
|
|
1109
|
-
);
|
|
1110
|
-
const aggResponse = AggregateBuilder.convertToAggregateResponse(rawAggregates);
|
|
1111
|
-
results.set(
|
|
1112
|
-
entity,
|
|
1113
|
-
aggResponse.map((agg) => assembler.convertAggregateResponse(agg))
|
|
1114
|
-
);
|
|
1115
|
-
})
|
|
1116
|
-
);
|
|
1231
|
+
await Promise.all(entities.map(async (entity) => {
|
|
1232
|
+
const rawAggregates = await relationQueryBuilder.aggregate(entity, convertedQuery, assembler.convertAggregateQuery(aggregate));
|
|
1233
|
+
const aggResponse = AggregateBuilder.convertToAggregateResponse(rawAggregates);
|
|
1234
|
+
results.set(entity, aggResponse.map((agg) => assembler.convertAggregateResponse(agg)));
|
|
1235
|
+
}));
|
|
1117
1236
|
return results;
|
|
1118
1237
|
}
|
|
1119
1238
|
/**
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1239
|
+
* Count the number of relations for multiple dtos.
|
|
1240
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
1241
|
+
* @param entities - The entities to query relations for.
|
|
1242
|
+
* @param relationName - The name of relation to query for.
|
|
1243
|
+
* @param filter - The filter to apply to the relation query.
|
|
1244
|
+
*/
|
|
1126
1245
|
async batchCountRelations(RelationClass, relationName, entities, filter) {
|
|
1127
|
-
const assembler =
|
|
1128
|
-
RelationClass,
|
|
1129
|
-
this.getRelationEntity(relationName)
|
|
1130
|
-
);
|
|
1246
|
+
const assembler = core$1.AssemblerFactory.getAssembler(RelationClass, this.getRelationEntity(relationName));
|
|
1131
1247
|
const relationQueryBuilder = this.getRelationQueryBuilder(relationName);
|
|
1132
|
-
const convertedQuery = assembler.convertQuery({
|
|
1248
|
+
const convertedQuery = assembler.convertQuery({
|
|
1249
|
+
filter
|
|
1250
|
+
});
|
|
1133
1251
|
const results = /* @__PURE__ */ new Map();
|
|
1134
|
-
await Promise.all(
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
})
|
|
1139
|
-
);
|
|
1252
|
+
await Promise.all(entities.map(async (entity) => {
|
|
1253
|
+
const count = await relationQueryBuilder.count(entity, convertedQuery);
|
|
1254
|
+
results.set(entity, count);
|
|
1255
|
+
}));
|
|
1140
1256
|
return results;
|
|
1141
1257
|
}
|
|
1142
1258
|
/**
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1259
|
+
* Query for a relation for multiple dtos.
|
|
1260
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
1261
|
+
* @param dtos - The dto to query relations for.
|
|
1262
|
+
* @param relationName - The name of relation to query for.
|
|
1263
|
+
* @param query - A query to filter, page or sort relations.
|
|
1264
|
+
*/
|
|
1149
1265
|
async batchFindRelations(RelationClass, relationName, dtos, opts) {
|
|
1150
1266
|
const batchResults = await this.batchQueryRelations(RelationClass, relationName, dtos, {
|
|
1151
|
-
paging: {
|
|
1267
|
+
paging: {
|
|
1268
|
+
limit: 1
|
|
1269
|
+
},
|
|
1152
1270
|
filter: opts?.filter
|
|
1153
1271
|
});
|
|
1154
1272
|
const results = /* @__PURE__ */ new Map();
|
|
@@ -1182,44 +1300,52 @@ var RelationQueryService = class {
|
|
|
1182
1300
|
const RelationEntity = relationMeta.entity();
|
|
1183
1301
|
const relationMetadata = em.getMetadata().get(RelationEntity);
|
|
1184
1302
|
const primaryKey = relationMetadata.primaryKeys[0];
|
|
1185
|
-
const idFilter = {
|
|
1303
|
+
const idFilter = {
|
|
1304
|
+
[primaryKey]: {
|
|
1305
|
+
$in: ids
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1186
1308
|
if (filter) {
|
|
1187
1309
|
const whereBuilder = this.filterQueryBuilder.whereBuilder;
|
|
1188
|
-
const additionalFilter = whereBuilder.build(
|
|
1189
|
-
filter
|
|
1190
|
-
);
|
|
1310
|
+
const additionalFilter = whereBuilder.build(filter);
|
|
1191
1311
|
return em.find(RelationEntity, {
|
|
1192
|
-
$and: [
|
|
1312
|
+
$and: [
|
|
1313
|
+
idFilter,
|
|
1314
|
+
additionalFilter
|
|
1315
|
+
]
|
|
1193
1316
|
});
|
|
1194
1317
|
}
|
|
1195
1318
|
return em.find(RelationEntity, idFilter);
|
|
1196
1319
|
}
|
|
1197
1320
|
foundAllRelations(relationIds, relations) {
|
|
1198
|
-
return (/* @__PURE__ */ new Set([
|
|
1321
|
+
return (/* @__PURE__ */ new Set([
|
|
1322
|
+
...relationIds
|
|
1323
|
+
])).size === relations.length;
|
|
1199
1324
|
}
|
|
1200
1325
|
};
|
|
1201
1326
|
|
|
1202
1327
|
// src/lib/services/mikro-orm-query.service.ts
|
|
1203
1328
|
var MikroOrmQueryService = class extends RelationQueryService {
|
|
1329
|
+
static {
|
|
1330
|
+
__name(this, "MikroOrmQueryService");
|
|
1331
|
+
}
|
|
1332
|
+
repo;
|
|
1333
|
+
filterQueryBuilder;
|
|
1334
|
+
useSoftDelete;
|
|
1204
1335
|
constructor(repo, opts) {
|
|
1205
|
-
super();
|
|
1206
|
-
this.repo = repo;
|
|
1336
|
+
super(), this.repo = repo;
|
|
1207
1337
|
this.filterQueryBuilder = opts?.filterQueryBuilder ?? new FilterQueryBuilder(this.repo);
|
|
1208
1338
|
this.useSoftDelete = opts?.useSoftDelete ?? false;
|
|
1209
|
-
const serializer =
|
|
1339
|
+
const serializer = assembler_serializer.getAssemblerSerializer(this.EntityClass);
|
|
1210
1340
|
if (!serializer) {
|
|
1211
|
-
|
|
1212
|
-
const json =
|
|
1341
|
+
core$1.AssemblerSerializer((e) => {
|
|
1342
|
+
const json = classTransformer.instanceToPlain(e, {
|
|
1213
1343
|
enableImplicitConversion: true,
|
|
1214
1344
|
excludeExtraneousValues: true,
|
|
1215
1345
|
exposeDefaultValues: true
|
|
1216
1346
|
});
|
|
1217
|
-
const jsonWithRemovedEmptyObjects = Object.fromEntries(
|
|
1218
|
-
|
|
1219
|
-
([, value]) => !(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0)
|
|
1220
|
-
)
|
|
1221
|
-
);
|
|
1222
|
-
const wrapped = (0, import_core5.wrap)(e, true);
|
|
1347
|
+
const jsonWithRemovedEmptyObjects = Object.fromEntries(Object.entries(json).filter(([, value]) => !(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0)));
|
|
1348
|
+
const wrapped = core.wrap(e, true);
|
|
1223
1349
|
const ormJson = "toObject" in wrapped ? wrapped.toObject() : {};
|
|
1224
1350
|
const data = {
|
|
1225
1351
|
...ormJson,
|
|
@@ -1227,57 +1353,59 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1227
1353
|
};
|
|
1228
1354
|
return data;
|
|
1229
1355
|
})(this.EntityClass);
|
|
1230
|
-
|
|
1231
|
-
const entity = this.repo.getEntityManager().create(this.EntityClass,
|
|
1356
|
+
core$1.AssemblerDeserializer((d) => {
|
|
1357
|
+
const entity = this.repo.getEntityManager().create(this.EntityClass, classTransformer.instanceToPlain(d));
|
|
1232
1358
|
return entity;
|
|
1233
1359
|
})(this.EntityClass);
|
|
1234
1360
|
}
|
|
1235
1361
|
}
|
|
1236
|
-
filterQueryBuilder;
|
|
1237
|
-
useSoftDelete;
|
|
1238
1362
|
get EntityClass() {
|
|
1239
1363
|
const em = this.repo.getEntityManager();
|
|
1240
1364
|
const metadata = em.getMetadata().get(this.repo.getEntityName());
|
|
1241
1365
|
return metadata.class;
|
|
1242
1366
|
}
|
|
1243
1367
|
/**
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1368
|
+
* Query for multiple entities, using a Query from `@nestjs-query/core`.
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* ```ts
|
|
1372
|
+
* const todoItems = await this.service.query({
|
|
1373
|
+
* filter: { title: { eq: 'Foo' } },
|
|
1374
|
+
* paging: { limit: 10 },
|
|
1375
|
+
* sorting: [{ field: "create", direction: SortDirection.DESC }],
|
|
1376
|
+
* });
|
|
1377
|
+
* ```
|
|
1378
|
+
* @param query - The Query used to filter, page, and sort rows.
|
|
1379
|
+
*/
|
|
1256
1380
|
async query(query) {
|
|
1257
1381
|
const qb = this.filterQueryBuilder.select(query);
|
|
1258
1382
|
await qb.applyFilters();
|
|
1259
1383
|
return qb.getResultList();
|
|
1260
1384
|
}
|
|
1261
1385
|
async aggregate(filter, aggregate) {
|
|
1262
|
-
const qb = this.filterQueryBuilder.aggregate({
|
|
1386
|
+
const qb = this.filterQueryBuilder.aggregate({
|
|
1387
|
+
filter
|
|
1388
|
+
}, aggregate);
|
|
1263
1389
|
await qb.applyFilters();
|
|
1264
1390
|
const rawResults = await qb.execute();
|
|
1265
1391
|
return AggregateBuilder.convertToAggregateResponse(rawResults);
|
|
1266
1392
|
}
|
|
1267
1393
|
async count(filter) {
|
|
1268
|
-
const qb = this.filterQueryBuilder.select({
|
|
1394
|
+
const qb = this.filterQueryBuilder.select({
|
|
1395
|
+
filter
|
|
1396
|
+
});
|
|
1269
1397
|
await qb.applyFilters();
|
|
1270
1398
|
return qb.getCount();
|
|
1271
1399
|
}
|
|
1272
1400
|
/**
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1401
|
+
* Find an entity by it's `id`.
|
|
1402
|
+
*
|
|
1403
|
+
* @example
|
|
1404
|
+
* ```ts
|
|
1405
|
+
* const todoItem = await this.service.findById(1);
|
|
1406
|
+
* ```
|
|
1407
|
+
* @param id - The id of the record to find.
|
|
1408
|
+
*/
|
|
1281
1409
|
async findById(id, opts) {
|
|
1282
1410
|
const qb = this.filterQueryBuilder.selectById(id, opts ?? {});
|
|
1283
1411
|
await qb.applyFilters();
|
|
@@ -1285,113 +1413,119 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1285
1413
|
return result ?? void 0;
|
|
1286
1414
|
}
|
|
1287
1415
|
/**
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1416
|
+
* Gets an entity by it's `id`. If the entity is not found a rejected promise is returned.
|
|
1417
|
+
*
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```ts
|
|
1420
|
+
* try {
|
|
1421
|
+
* const todoItem = await this.service.getById(1);
|
|
1422
|
+
* } catch(e) {
|
|
1423
|
+
* console.error('Unable to find entity with id = 1');
|
|
1424
|
+
* }
|
|
1425
|
+
* ```
|
|
1426
|
+
* @param id - The id of the record to find.
|
|
1427
|
+
*/
|
|
1300
1428
|
async getById(id, opts) {
|
|
1301
1429
|
const entity = await this.findById(id, opts);
|
|
1302
1430
|
if (!entity) {
|
|
1303
|
-
throw new
|
|
1431
|
+
throw new common.NotFoundException(`Unable to find ${this.EntityClass.name} with id: ${id}`);
|
|
1304
1432
|
}
|
|
1305
1433
|
return entity;
|
|
1306
1434
|
}
|
|
1307
1435
|
/**
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1436
|
+
* Creates a single entity.
|
|
1437
|
+
*
|
|
1438
|
+
* @example
|
|
1439
|
+
* ```ts
|
|
1440
|
+
* const todoItem = await this.service.createOne({title: 'Todo Item', completed: false });
|
|
1441
|
+
* ```
|
|
1442
|
+
* @param record - The entity to create.
|
|
1443
|
+
*/
|
|
1316
1444
|
async createOne(record) {
|
|
1317
1445
|
const entity = await this.ensureIsEntityAndDoesNotExist(record);
|
|
1318
1446
|
await this.repo.getEntityManager().persist(entity).flush();
|
|
1319
1447
|
return entity;
|
|
1320
1448
|
}
|
|
1321
1449
|
/**
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1450
|
+
* Create multiple entities.
|
|
1451
|
+
*
|
|
1452
|
+
* @example
|
|
1453
|
+
* ```ts
|
|
1454
|
+
* const todoItem = await this.service.createMany([
|
|
1455
|
+
* {title: 'Todo Item 1', completed: false },
|
|
1456
|
+
* {title: 'Todo Item 2', completed: true },
|
|
1457
|
+
* ]);
|
|
1458
|
+
* ```
|
|
1459
|
+
* @param records - The entities to create.
|
|
1460
|
+
*/
|
|
1333
1461
|
async createMany(records) {
|
|
1334
1462
|
const entities = await Promise.all(records.map((r) => this.ensureIsEntityAndDoesNotExist(r)));
|
|
1335
1463
|
await this.repo.getEntityManager().persist(entities).flush();
|
|
1336
1464
|
return entities;
|
|
1337
1465
|
}
|
|
1338
1466
|
/**
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1467
|
+
* Update an entity.
|
|
1468
|
+
*
|
|
1469
|
+
* @example
|
|
1470
|
+
* ```ts
|
|
1471
|
+
* const updatedEntity = await this.service.updateOne(1, { completed: true });
|
|
1472
|
+
* ```
|
|
1473
|
+
* @param id - The `id` of the record.
|
|
1474
|
+
* @param update - A `Partial` of the entity with fields to update.
|
|
1475
|
+
* @param opts - Additional options.
|
|
1476
|
+
*/
|
|
1349
1477
|
async updateOne(id, update, opts) {
|
|
1350
1478
|
this.ensureIdIsNotPresent(update);
|
|
1351
1479
|
const entity = await this.getById(id, opts);
|
|
1352
|
-
|
|
1480
|
+
core.wrap(entity).assign(update);
|
|
1353
1481
|
await this.repo.getEntityManager().flush();
|
|
1354
1482
|
return entity;
|
|
1355
1483
|
}
|
|
1356
1484
|
/**
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1485
|
+
* Update multiple entities with a `@nestjs-query/core` Filter.
|
|
1486
|
+
*
|
|
1487
|
+
* @example
|
|
1488
|
+
* ```ts
|
|
1489
|
+
* const { updatedCount } = await this.service.updateMany(
|
|
1490
|
+
* { completed: true }, // the update to apply
|
|
1491
|
+
* { title: { eq: 'Foo Title' } } // Filter to find records to update
|
|
1492
|
+
* );
|
|
1493
|
+
* ```
|
|
1494
|
+
* @param update - A `Partial` of entity with the fields to update
|
|
1495
|
+
* @param filter - A Filter used to find the records to update
|
|
1496
|
+
*/
|
|
1369
1497
|
async updateMany(update, filter) {
|
|
1370
1498
|
this.ensureIdIsNotPresent(update);
|
|
1371
|
-
const entities = await this.query({
|
|
1499
|
+
const entities = await this.query({
|
|
1500
|
+
filter
|
|
1501
|
+
});
|
|
1372
1502
|
for (const entity of entities) {
|
|
1373
|
-
|
|
1503
|
+
core.wrap(entity).assign(update);
|
|
1374
1504
|
}
|
|
1375
1505
|
await this.repo.getEntityManager().flush();
|
|
1376
|
-
return {
|
|
1506
|
+
return {
|
|
1507
|
+
updatedCount: entities.length
|
|
1508
|
+
};
|
|
1377
1509
|
}
|
|
1378
1510
|
/**
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1511
|
+
* Delete an entity by `id`.
|
|
1512
|
+
*
|
|
1513
|
+
* @example
|
|
1514
|
+
*
|
|
1515
|
+
* ```ts
|
|
1516
|
+
* const deletedTodo = await this.service.deleteOne(1);
|
|
1517
|
+
* ```
|
|
1518
|
+
*
|
|
1519
|
+
* @param id - The `id` of the entity to delete.
|
|
1520
|
+
* @param filter Additional filter to use when finding the entity to delete.
|
|
1521
|
+
*/
|
|
1390
1522
|
async deleteOne(id, opts) {
|
|
1391
1523
|
const entity = await this.getById(id, opts);
|
|
1392
1524
|
const em = this.repo.getEntityManager();
|
|
1393
1525
|
if (this.useSoftDelete) {
|
|
1394
|
-
|
|
1526
|
+
core.wrap(entity).assign({
|
|
1527
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
1528
|
+
});
|
|
1395
1529
|
await em.flush();
|
|
1396
1530
|
} else {
|
|
1397
1531
|
await em.remove(entity).flush();
|
|
@@ -1402,24 +1536,28 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1402
1536
|
return entity;
|
|
1403
1537
|
}
|
|
1404
1538
|
/**
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1539
|
+
* Delete multiple records with a `@nestjs-query/core` `Filter`.
|
|
1540
|
+
*
|
|
1541
|
+
* @example
|
|
1542
|
+
*
|
|
1543
|
+
* ```ts
|
|
1544
|
+
* const { deletedCount } = this.service.deleteMany({
|
|
1545
|
+
* created: { lte: new Date('2020-1-1') }
|
|
1546
|
+
* });
|
|
1547
|
+
* ```
|
|
1548
|
+
*
|
|
1549
|
+
* @param filter - A `Filter` to find records to delete.
|
|
1550
|
+
*/
|
|
1417
1551
|
async deleteMany(filter) {
|
|
1418
|
-
const entities = await this.query({
|
|
1552
|
+
const entities = await this.query({
|
|
1553
|
+
filter
|
|
1554
|
+
});
|
|
1419
1555
|
const em = this.repo.getEntityManager();
|
|
1420
1556
|
if (this.useSoftDelete) {
|
|
1421
1557
|
for (const entity of entities) {
|
|
1422
|
-
|
|
1558
|
+
core.wrap(entity).assign({
|
|
1559
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
1560
|
+
});
|
|
1423
1561
|
}
|
|
1424
1562
|
} else {
|
|
1425
1563
|
for (const entity of entities) {
|
|
@@ -1427,20 +1565,22 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1427
1565
|
}
|
|
1428
1566
|
}
|
|
1429
1567
|
await em.flush();
|
|
1430
|
-
return {
|
|
1568
|
+
return {
|
|
1569
|
+
deletedCount: entities.length
|
|
1570
|
+
};
|
|
1431
1571
|
}
|
|
1432
1572
|
/**
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1573
|
+
* Restore an entity by `id`.
|
|
1574
|
+
*
|
|
1575
|
+
* @example
|
|
1576
|
+
*
|
|
1577
|
+
* ```ts
|
|
1578
|
+
* const restoredTodo = await this.service.restoreOne(1);
|
|
1579
|
+
* ```
|
|
1580
|
+
*
|
|
1581
|
+
* @param id - The `id` of the entity to restore.
|
|
1582
|
+
* @param opts Additional filter to use when finding the entity to restore.
|
|
1583
|
+
*/
|
|
1444
1584
|
async restoreOne(id, opts) {
|
|
1445
1585
|
this.ensureSoftDeleteEnabled();
|
|
1446
1586
|
const em = this.repo.getEntityManager();
|
|
@@ -1453,32 +1593,37 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1453
1593
|
const whereBuilder = new WhereBuilder();
|
|
1454
1594
|
const additionalWhere = whereBuilder.build(opts.filter);
|
|
1455
1595
|
whereClause = {
|
|
1456
|
-
$and: [
|
|
1596
|
+
$and: [
|
|
1597
|
+
whereClause,
|
|
1598
|
+
additionalWhere
|
|
1599
|
+
]
|
|
1457
1600
|
};
|
|
1458
1601
|
}
|
|
1459
1602
|
const entity = await em.findOne(this.EntityClass, whereClause, {
|
|
1460
1603
|
filters: false
|
|
1461
1604
|
});
|
|
1462
1605
|
if (!entity) {
|
|
1463
|
-
throw new
|
|
1606
|
+
throw new common.NotFoundException(`Unable to find ${this.EntityClass.name} with id: ${id}`);
|
|
1464
1607
|
}
|
|
1465
|
-
|
|
1608
|
+
core.wrap(entity).assign({
|
|
1609
|
+
deletedAt: null
|
|
1610
|
+
});
|
|
1466
1611
|
await em.flush();
|
|
1467
1612
|
return entity;
|
|
1468
1613
|
}
|
|
1469
1614
|
/**
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1615
|
+
* Restores multiple records with a `@nestjs-query/core` `Filter`.
|
|
1616
|
+
*
|
|
1617
|
+
* @example
|
|
1618
|
+
*
|
|
1619
|
+
* ```ts
|
|
1620
|
+
* const { updatedCount } = this.service.restoreMany({
|
|
1621
|
+
* created: { lte: new Date('2020-1-1') }
|
|
1622
|
+
* });
|
|
1623
|
+
* ```
|
|
1624
|
+
*
|
|
1625
|
+
* @param filter - A `Filter` to find records to restore.
|
|
1626
|
+
*/
|
|
1482
1627
|
async restoreMany(filter) {
|
|
1483
1628
|
this.ensureSoftDeleteEnabled();
|
|
1484
1629
|
const em = this.repo.getEntityManager();
|
|
@@ -1488,10 +1633,14 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1488
1633
|
filters: false
|
|
1489
1634
|
});
|
|
1490
1635
|
for (const entity of entities) {
|
|
1491
|
-
|
|
1636
|
+
core.wrap(entity).assign({
|
|
1637
|
+
deletedAt: null
|
|
1638
|
+
});
|
|
1492
1639
|
}
|
|
1493
1640
|
await em.flush();
|
|
1494
|
-
return {
|
|
1641
|
+
return {
|
|
1642
|
+
updatedCount: entities.length
|
|
1643
|
+
};
|
|
1495
1644
|
}
|
|
1496
1645
|
get em() {
|
|
1497
1646
|
return this.repo.getEntityManager();
|
|
@@ -1527,9 +1676,7 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1527
1676
|
}
|
|
1528
1677
|
ensureSoftDeleteEnabled() {
|
|
1529
1678
|
if (!this.useSoftDelete) {
|
|
1530
|
-
throw new
|
|
1531
|
-
`Restore not allowed for non soft deleted entity ${this.EntityClass.name}.`
|
|
1532
|
-
);
|
|
1679
|
+
throw new common.MethodNotAllowedException(`Restore not allowed for non soft deleted entity ${this.EntityClass.name}.`);
|
|
1533
1680
|
}
|
|
1534
1681
|
}
|
|
1535
1682
|
};
|
|
@@ -1538,38 +1685,50 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1538
1685
|
function createMikroOrmQueryServiceProvider(EntityClass, contextName) {
|
|
1539
1686
|
return {
|
|
1540
1687
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1541
|
-
provide:
|
|
1688
|
+
provide: core$1.getQueryServiceToken(EntityClass),
|
|
1542
1689
|
useFactory(repo) {
|
|
1543
1690
|
return new MikroOrmQueryService(repo);
|
|
1544
1691
|
},
|
|
1545
|
-
inject: [
|
|
1692
|
+
inject: [
|
|
1693
|
+
nestjs.getRepositoryToken(EntityClass, contextName)
|
|
1694
|
+
]
|
|
1546
1695
|
};
|
|
1547
1696
|
}
|
|
1548
|
-
|
|
1697
|
+
__name(createMikroOrmQueryServiceProvider, "createMikroOrmQueryServiceProvider");
|
|
1698
|
+
var createMikroOrmQueryServiceProviders = /* @__PURE__ */ __name((entities, contextName) => entities.map((entity) => createMikroOrmQueryServiceProvider(entity, contextName)), "createMikroOrmQueryServiceProviders");
|
|
1549
1699
|
|
|
1550
1700
|
// src/lib/nest-query-mikro-orm.module.ts
|
|
1551
1701
|
var NestjsQueryMikroOrmModule = class _NestjsQueryMikroOrmModule {
|
|
1702
|
+
static {
|
|
1703
|
+
__name(this, "NestjsQueryMikroOrmModule");
|
|
1704
|
+
}
|
|
1552
1705
|
static forFeature(entities, contextName) {
|
|
1553
1706
|
const queryServiceProviders = createMikroOrmQueryServiceProviders(entities, contextName);
|
|
1554
|
-
const mikroOrmModule =
|
|
1707
|
+
const mikroOrmModule = nestjs.MikroOrmModule.forFeature(entities, contextName);
|
|
1555
1708
|
return {
|
|
1556
|
-
imports: [
|
|
1709
|
+
imports: [
|
|
1710
|
+
mikroOrmModule
|
|
1711
|
+
],
|
|
1557
1712
|
module: _NestjsQueryMikroOrmModule,
|
|
1558
|
-
providers: [
|
|
1559
|
-
|
|
1713
|
+
providers: [
|
|
1714
|
+
...queryServiceProviders
|
|
1715
|
+
],
|
|
1716
|
+
exports: [
|
|
1717
|
+
...queryServiceProviders,
|
|
1718
|
+
mikroOrmModule
|
|
1719
|
+
]
|
|
1560
1720
|
};
|
|
1561
1721
|
}
|
|
1562
1722
|
};
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
createMikroOrmQueryServiceProviders
|
|
1574
|
-
});
|
|
1723
|
+
|
|
1724
|
+
exports.AggregateBuilder = AggregateBuilder;
|
|
1725
|
+
exports.FilterQueryBuilder = FilterQueryBuilder;
|
|
1726
|
+
exports.MikroOrmQueryService = MikroOrmQueryService;
|
|
1727
|
+
exports.NestjsQueryMikroOrmModule = NestjsQueryMikroOrmModule;
|
|
1728
|
+
exports.RelationQueryBuilder = RelationQueryBuilder;
|
|
1729
|
+
exports.RelationQueryService = RelationQueryService;
|
|
1730
|
+
exports.SQLComparisonBuilder = SQLComparisonBuilder;
|
|
1731
|
+
exports.WhereBuilder = WhereBuilder;
|
|
1732
|
+
exports.createMikroOrmQueryServiceProviders = createMikroOrmQueryServiceProviders;
|
|
1575
1733
|
//# sourceMappingURL=index.cjs.map
|
|
1734
|
+
//# sourceMappingURL=index.cjs.map
|