@mikro-orm/core 7.0.0-dev.33 → 7.0.0-dev.331
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/EntityManager.d.ts +70 -75
- package/EntityManager.js +487 -402
- package/MikroORM.d.ts +45 -38
- package/MikroORM.js +123 -156
- package/README.md +7 -4
- package/cache/FileCacheAdapter.d.ts +2 -7
- package/cache/FileCacheAdapter.js +35 -30
- package/cache/GeneratedCacheAdapter.d.ts +1 -2
- package/cache/GeneratedCacheAdapter.js +6 -8
- package/cache/MemoryCacheAdapter.d.ts +1 -2
- package/cache/MemoryCacheAdapter.js +8 -8
- package/cache/index.d.ts +1 -2
- package/cache/index.js +0 -2
- package/connections/Connection.d.ts +12 -5
- package/connections/Connection.js +37 -15
- package/drivers/DatabaseDriver.d.ts +25 -18
- package/drivers/DatabaseDriver.js +144 -45
- package/drivers/IDatabaseDriver.d.ts +118 -23
- package/entity/BaseEntity.d.ts +63 -4
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +95 -31
- package/entity/Collection.js +487 -139
- package/entity/EntityAssigner.js +37 -25
- package/entity/EntityFactory.d.ts +8 -9
- package/entity/EntityFactory.js +152 -100
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +69 -27
- package/entity/EntityLoader.d.ts +12 -13
- package/entity/EntityLoader.js +286 -125
- package/entity/EntityRepository.d.ts +28 -8
- package/entity/EntityRepository.js +8 -2
- package/entity/PolymorphicRef.d.ts +12 -0
- package/entity/PolymorphicRef.js +18 -0
- package/entity/Reference.d.ts +3 -8
- package/entity/Reference.js +62 -29
- package/entity/WrappedEntity.d.ts +7 -10
- package/entity/WrappedEntity.js +6 -7
- package/entity/defineEntity.d.ts +472 -313
- package/entity/defineEntity.js +134 -290
- package/entity/index.d.ts +2 -2
- package/entity/index.js +2 -2
- package/entity/utils.d.ts +6 -1
- package/entity/utils.js +46 -11
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +66 -0
- package/enums.d.ts +8 -6
- package/enums.js +13 -17
- package/errors.d.ts +26 -16
- package/errors.js +63 -31
- package/events/EventManager.d.ts +3 -5
- package/events/EventManager.js +37 -26
- package/events/index.d.ts +1 -1
- package/events/index.js +0 -1
- package/exceptions.js +9 -2
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +5 -6
- package/hydration/ObjectHydrator.js +109 -50
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +3 -4
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +4 -6
- package/logging/index.d.ts +2 -1
- package/logging/index.js +1 -1
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +47 -23
- package/metadata/EntitySchema.js +103 -34
- package/metadata/MetadataDiscovery.d.ts +65 -18
- package/metadata/MetadataDiscovery.js +940 -424
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +71 -2
- package/metadata/MetadataStorage.d.ts +11 -13
- package/metadata/MetadataStorage.js +79 -48
- package/metadata/MetadataValidator.d.ts +32 -9
- package/metadata/MetadataValidator.js +214 -44
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +1 -1
- package/metadata/index.js +0 -1
- package/metadata/types.d.ts +577 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
- package/naming-strategy/AbstractNamingStrategy.js +26 -5
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +7 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
- package/naming-strategy/MongoNamingStrategy.js +6 -6
- package/naming-strategy/NamingStrategy.d.ts +28 -4
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
- package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
- package/naming-strategy/index.d.ts +1 -1
- package/naming-strategy/index.js +0 -1
- package/not-supported.d.ts +2 -0
- package/not-supported.js +8 -0
- package/package.json +47 -36
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +33 -15
- package/platforms/Platform.js +125 -69
- package/serialization/EntitySerializer.d.ts +6 -3
- package/serialization/EntitySerializer.js +54 -30
- package/serialization/EntityTransformer.js +37 -22
- package/serialization/SerializationContext.d.ts +10 -14
- package/serialization/SerializationContext.js +24 -19
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.js +2 -2
- package/types/DoubleType.js +1 -1
- package/types/EnumArrayType.js +1 -2
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/TinyIntType.js +1 -1
- package/types/Type.d.ts +2 -4
- package/types/Type.js +3 -3
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +1 -4
- package/types/UuidType.d.ts +2 -0
- package/types/UuidType.js +14 -2
- package/types/index.d.ts +3 -2
- package/typings.d.ts +427 -170
- package/typings.js +100 -45
- package/unit-of-work/ChangeSet.d.ts +4 -6
- package/unit-of-work/ChangeSet.js +8 -9
- package/unit-of-work/ChangeSetComputer.d.ts +2 -12
- package/unit-of-work/ChangeSetComputer.js +61 -38
- package/unit-of-work/ChangeSetPersister.d.ts +10 -17
- package/unit-of-work/ChangeSetPersister.js +136 -73
- package/unit-of-work/CommitOrderCalculator.d.ts +13 -14
- package/unit-of-work/CommitOrderCalculator.js +22 -20
- package/unit-of-work/IdentityMap.d.ts +12 -3
- package/unit-of-work/IdentityMap.js +51 -13
- package/unit-of-work/UnitOfWork.d.ts +39 -23
- package/unit-of-work/UnitOfWork.js +441 -246
- package/utils/AbstractMigrator.d.ts +101 -0
- package/utils/AbstractMigrator.js +303 -0
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +30 -18
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +647 -185
- package/utils/Configuration.js +215 -252
- package/utils/ConfigurationLoader.d.ts +1 -52
- package/utils/ConfigurationLoader.js +1 -330
- package/utils/Cursor.d.ts +3 -6
- package/utils/Cursor.js +32 -17
- package/utils/DataloaderUtils.d.ts +10 -5
- package/utils/DataloaderUtils.js +42 -22
- package/utils/EntityComparator.d.ts +21 -21
- package/utils/EntityComparator.js +224 -118
- package/utils/QueryHelper.d.ts +34 -7
- package/utils/QueryHelper.js +183 -72
- package/utils/RawQueryFragment.d.ts +28 -34
- package/utils/RawQueryFragment.js +37 -72
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.js +11 -8
- package/utils/Utils.d.ts +16 -127
- package/utils/Utils.js +104 -402
- package/utils/clone.js +13 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +98 -0
- package/utils/fs-utils.d.ts +20 -0
- package/utils/fs-utils.js +193 -0
- package/utils/index.d.ts +1 -3
- package/utils/index.js +1 -3
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +51 -5
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -13
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -32
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -11
- package/decorators/Embedded.d.ts +0 -12
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -33
- package/decorators/Entity.js +0 -12
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -16
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -8
- package/decorators/Formula.d.ts +0 -4
- package/decorators/Formula.js +0 -15
- package/decorators/Indexed.d.ts +0 -19
- package/decorators/Indexed.js +0 -20
- package/decorators/ManyToMany.d.ts +0 -42
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -34
- package/decorators/ManyToOne.js +0 -14
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -17
- package/decorators/OneToOne.d.ts +0 -28
- package/decorators/OneToOne.js +0 -7
- package/decorators/PrimaryKey.d.ts +0 -8
- package/decorators/PrimaryKey.js +0 -20
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -32
- package/decorators/Transactional.d.ts +0 -14
- package/decorators/Transactional.js +0 -28
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -47
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -17
- package/entity/ArrayCollection.d.ts +0 -118
- package/entity/ArrayCollection.js +0 -407
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -150
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -44
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -28
|
@@ -8,7 +8,9 @@ import { EntityManager } from '../EntityManager.js';
|
|
|
8
8
|
import { CursorError, ValidationError } from '../errors.js';
|
|
9
9
|
import { DriverException } from '../exceptions.js';
|
|
10
10
|
import { helper } from '../entity/wrap.js';
|
|
11
|
+
import { PolymorphicRef } from '../entity/PolymorphicRef.js';
|
|
11
12
|
import { JsonType } from '../types/JsonType.js';
|
|
13
|
+
import { MikroORM } from '../MikroORM.js';
|
|
12
14
|
export class DatabaseDriver {
|
|
13
15
|
config;
|
|
14
16
|
dependencies;
|
|
@@ -16,13 +18,11 @@ export class DatabaseDriver {
|
|
|
16
18
|
connection;
|
|
17
19
|
replicas = [];
|
|
18
20
|
platform;
|
|
19
|
-
logger;
|
|
20
21
|
comparator;
|
|
21
22
|
metadata;
|
|
22
23
|
constructor(config, dependencies) {
|
|
23
24
|
this.config = config;
|
|
24
25
|
this.dependencies = dependencies;
|
|
25
|
-
this.logger = this.config.getLogger();
|
|
26
26
|
}
|
|
27
27
|
async nativeUpdateMany(entityName, where, data, options) {
|
|
28
28
|
throw new Error(`Batch updates are not supported by ${this.constructor.name} driver`);
|
|
@@ -31,11 +31,11 @@ export class DatabaseDriver {
|
|
|
31
31
|
const EntityManagerClass = this.config.get('entityManager', EntityManager);
|
|
32
32
|
return new EntityManagerClass(this.config, this, this.metadata, useContext);
|
|
33
33
|
}
|
|
34
|
-
/* v8 ignore next
|
|
34
|
+
/* v8 ignore next */
|
|
35
35
|
async findVirtual(entityName, where, options) {
|
|
36
36
|
throw new Error(`Virtual entities are not supported by ${this.constructor.name} driver.`);
|
|
37
37
|
}
|
|
38
|
-
/* v8 ignore next
|
|
38
|
+
/* v8 ignore next */
|
|
39
39
|
async countVirtual(entityName, where, options) {
|
|
40
40
|
throw new Error(`Counting virtual entities is not supported by ${this.constructor.name} driver.`);
|
|
41
41
|
}
|
|
@@ -47,32 +47,35 @@ export class DatabaseDriver {
|
|
|
47
47
|
}
|
|
48
48
|
async syncCollections(collections, options) {
|
|
49
49
|
for (const coll of collections) {
|
|
50
|
+
/* v8 ignore else */
|
|
50
51
|
if (!coll.property.owner) {
|
|
51
52
|
if (coll.getSnapshot() === undefined) {
|
|
52
53
|
throw ValidationError.cannotModifyInverseCollection(coll.owner, coll.property);
|
|
53
54
|
}
|
|
54
55
|
continue;
|
|
55
56
|
}
|
|
56
|
-
/* v8 ignore next
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
/* v8 ignore next */
|
|
58
|
+
{
|
|
59
|
+
const pk = coll.property.targetMeta.primaryKeys[0];
|
|
60
|
+
const data = { [coll.property.name]: coll.getIdentifiers(pk) };
|
|
61
|
+
await this.nativeUpdate(coll.owner.constructor, helper(coll.owner).getPrimaryKey(), data, options);
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
mapResult(result, meta, populate = []) {
|
|
63
66
|
if (!result || !meta) {
|
|
64
67
|
return result ?? null;
|
|
65
68
|
}
|
|
66
|
-
return this.comparator.mapResult(meta
|
|
69
|
+
return this.comparator.mapResult(meta, result);
|
|
67
70
|
}
|
|
68
|
-
async connect() {
|
|
69
|
-
await this.connection.connect();
|
|
71
|
+
async connect(options) {
|
|
72
|
+
await this.connection.connect(options);
|
|
70
73
|
await Promise.all(this.replicas.map(replica => replica.connect()));
|
|
71
74
|
return this.connection;
|
|
72
75
|
}
|
|
73
|
-
async reconnect() {
|
|
76
|
+
async reconnect(options) {
|
|
74
77
|
await this.close(true);
|
|
75
|
-
await this.connect();
|
|
78
|
+
await this.connect(options);
|
|
76
79
|
return this.connection;
|
|
77
80
|
}
|
|
78
81
|
getConnection(type = 'write') {
|
|
@@ -105,6 +108,15 @@ export class DatabaseDriver {
|
|
|
105
108
|
getDependencies() {
|
|
106
109
|
return this.dependencies;
|
|
107
110
|
}
|
|
111
|
+
isPopulated(meta, prop, hint, name) {
|
|
112
|
+
if (hint.field === prop.name || hint.field === name || hint.all) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (prop.embedded && hint.children && meta.properties[prop.embedded[0]].name === hint.field) {
|
|
116
|
+
return hint.children.some(c => this.isPopulated(meta, prop, c, prop.embedded[1]));
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
108
120
|
processCursorOptions(meta, options, orderBy) {
|
|
109
121
|
const { first, last, before, after, overfetch } = options;
|
|
110
122
|
const limit = first ?? last;
|
|
@@ -139,15 +151,15 @@ export class DatabaseDriver {
|
|
|
139
151
|
}
|
|
140
152
|
const createOrderBy = (prop, direction) => {
|
|
141
153
|
if (Utils.isPlainObject(direction)) {
|
|
142
|
-
const value = Utils.
|
|
154
|
+
const value = Utils.getObjectQueryKeys(direction).reduce((o, key) => {
|
|
143
155
|
Object.assign(o, createOrderBy(key, direction[key]));
|
|
144
156
|
return o;
|
|
145
157
|
}, {});
|
|
146
|
-
return
|
|
158
|
+
return { [prop]: value };
|
|
147
159
|
}
|
|
148
160
|
const desc = direction === QueryOrderNumeric.DESC || direction.toString().toLowerCase() === 'desc';
|
|
149
161
|
const dir = Utils.xor(desc, isLast) ? 'desc' : 'asc';
|
|
150
|
-
return
|
|
162
|
+
return { [prop]: dir };
|
|
151
163
|
};
|
|
152
164
|
return {
|
|
153
165
|
orderBy: definition.map(([prop, direction]) => createOrderBy(prop, direction)),
|
|
@@ -155,22 +167,51 @@ export class DatabaseDriver {
|
|
|
155
167
|
};
|
|
156
168
|
}
|
|
157
169
|
createCursorCondition(definition, offsets, inverse, meta) {
|
|
158
|
-
const createCondition = (prop, direction, offset, eq = false) => {
|
|
159
|
-
if (offset === null) {
|
|
160
|
-
throw CursorError.missingValue(meta.className, prop);
|
|
161
|
-
}
|
|
170
|
+
const createCondition = (prop, direction, offset, eq = false, path = prop) => {
|
|
162
171
|
if (Utils.isPlainObject(direction)) {
|
|
172
|
+
if (offset === undefined) {
|
|
173
|
+
throw CursorError.missingValue(meta.className, path);
|
|
174
|
+
}
|
|
163
175
|
const value = Utils.keys(direction).reduce((o, key) => {
|
|
164
|
-
|
|
165
|
-
throw CursorError.missingValue(meta.className, `${prop}.${key}`);
|
|
166
|
-
}
|
|
167
|
-
Object.assign(o, createCondition(key, direction[key], offset[key], eq));
|
|
176
|
+
Object.assign(o, createCondition(key, direction[key], offset?.[key], eq, `${path}.${key}`));
|
|
168
177
|
return o;
|
|
169
178
|
}, {});
|
|
170
|
-
return
|
|
179
|
+
return { [prop]: value };
|
|
171
180
|
}
|
|
172
|
-
const
|
|
173
|
-
const
|
|
181
|
+
const isDesc = direction === QueryOrderNumeric.DESC || direction.toString().toLowerCase() === 'desc';
|
|
182
|
+
const dirStr = direction.toString().toLowerCase();
|
|
183
|
+
let nullsFirst;
|
|
184
|
+
if (dirStr.includes('nulls first')) {
|
|
185
|
+
nullsFirst = true;
|
|
186
|
+
}
|
|
187
|
+
else if (dirStr.includes('nulls last')) {
|
|
188
|
+
nullsFirst = false;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// Default: NULLS LAST for ASC, NULLS FIRST for DESC (matches most databases)
|
|
192
|
+
nullsFirst = isDesc;
|
|
193
|
+
}
|
|
194
|
+
const operator = Utils.xor(isDesc, inverse) ? '$lt' : '$gt';
|
|
195
|
+
// For leaf-level properties, undefined means missing value
|
|
196
|
+
if (offset === undefined) {
|
|
197
|
+
throw CursorError.missingValue(meta.className, path);
|
|
198
|
+
}
|
|
199
|
+
// Handle null offset (intentional null cursor value)
|
|
200
|
+
if (offset === null) {
|
|
201
|
+
if (eq) {
|
|
202
|
+
// Equal to null
|
|
203
|
+
return { [prop]: null };
|
|
204
|
+
}
|
|
205
|
+
// Strict comparison with null cursor value
|
|
206
|
+
// hasItemsAfterNull: forward + nullsFirst, or backward + nullsLast
|
|
207
|
+
const hasItemsAfterNull = Utils.xor(nullsFirst, inverse);
|
|
208
|
+
if (hasItemsAfterNull) {
|
|
209
|
+
return { [prop]: { $ne: null } };
|
|
210
|
+
}
|
|
211
|
+
// No items after null in this direction, return impossible condition
|
|
212
|
+
return { [prop]: [] };
|
|
213
|
+
}
|
|
214
|
+
// Non-null offset
|
|
174
215
|
return { [prop]: { [operator + (eq ? 'e' : '')]: offset } };
|
|
175
216
|
};
|
|
176
217
|
const [order, ...otherOrders] = definition;
|
|
@@ -213,24 +254,68 @@ export class DatabaseDriver {
|
|
|
213
254
|
else {
|
|
214
255
|
data[prop.fieldNames[0]] = this.mapDataToFieldNames(copy, stringifyJsonArrays, prop.embeddedProps, convertCustomTypes, true);
|
|
215
256
|
}
|
|
216
|
-
if (stringifyJsonArrays && prop.array) {
|
|
257
|
+
if (stringifyJsonArrays && prop.array && !object) {
|
|
217
258
|
data[prop.fieldNames[0]] = this.platform.convertJsonToDatabaseValue(data[prop.fieldNames[0]]);
|
|
218
259
|
}
|
|
219
260
|
return;
|
|
220
261
|
}
|
|
262
|
+
// Handle polymorphic relations - convert tuple or PolymorphicRef to separate columns
|
|
263
|
+
// Tuple format: ['discriminator', id] or ['discriminator', id1, id2] for composite keys
|
|
264
|
+
// Must be checked BEFORE joinColumns array handling since polymorphic uses fieldNames (includes discriminator)
|
|
265
|
+
if (prop.polymorphic && prop.fieldNames && prop.fieldNames.length >= 2) {
|
|
266
|
+
let discriminator;
|
|
267
|
+
let ids;
|
|
268
|
+
if (Array.isArray(data[k]) && typeof data[k][0] === 'string' && prop.discriminatorMap?.[data[k][0]]) {
|
|
269
|
+
// Tuple format: ['discriminator', ...ids]
|
|
270
|
+
const [disc, ...rest] = data[k];
|
|
271
|
+
discriminator = disc;
|
|
272
|
+
ids = rest;
|
|
273
|
+
}
|
|
274
|
+
else if (data[k] instanceof PolymorphicRef) {
|
|
275
|
+
// PolymorphicRef wrapper (internal use)
|
|
276
|
+
discriminator = data[k].discriminator;
|
|
277
|
+
const polyId = data[k].id;
|
|
278
|
+
// Handle object-style composite key IDs like { tenantId: 1, orgId: 100 }
|
|
279
|
+
if (polyId && typeof polyId === 'object' && !Array.isArray(polyId)) {
|
|
280
|
+
const targetEntity = prop.discriminatorMap?.[discriminator];
|
|
281
|
+
const targetMeta = this.metadata.get(targetEntity);
|
|
282
|
+
ids = targetMeta.primaryKeys.map(pk => polyId[pk]);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
ids = Utils.asArray(polyId);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (discriminator) {
|
|
289
|
+
const discriminatorColumn = prop.fieldNames[0];
|
|
290
|
+
const idColumns = prop.fieldNames.slice(1);
|
|
291
|
+
delete data[k];
|
|
292
|
+
data[discriminatorColumn] = discriminator;
|
|
293
|
+
idColumns.forEach((col, idx) => {
|
|
294
|
+
data[col] = ids[idx];
|
|
295
|
+
});
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
221
299
|
if (prop.joinColumns && Array.isArray(data[k])) {
|
|
222
300
|
const copy = Utils.flatten(data[k]);
|
|
223
301
|
delete data[k];
|
|
224
|
-
prop.joinColumns.forEach((joinColumn, idx) => data[joinColumn] = copy[idx]);
|
|
302
|
+
prop.joinColumns.forEach((joinColumn, idx) => (data[joinColumn] = copy[idx]));
|
|
225
303
|
return;
|
|
226
304
|
}
|
|
227
305
|
if (prop.joinColumns?.length > 1 && data[k] == null) {
|
|
228
306
|
delete data[k];
|
|
229
|
-
prop.ownColumns.forEach(joinColumn => data[joinColumn] = null);
|
|
307
|
+
prop.ownColumns.forEach(joinColumn => (data[joinColumn] = null));
|
|
230
308
|
return;
|
|
231
309
|
}
|
|
232
|
-
if (prop.customType &&
|
|
233
|
-
|
|
310
|
+
if (prop.customType &&
|
|
311
|
+
convertCustomTypes &&
|
|
312
|
+
!(prop.customType instanceof JsonType && object) &&
|
|
313
|
+
!isRaw(data[k])) {
|
|
314
|
+
data[k] = prop.customType.convertToDatabaseValue(data[k], this.platform, {
|
|
315
|
+
fromQuery: true,
|
|
316
|
+
key: k,
|
|
317
|
+
mode: 'query-data',
|
|
318
|
+
});
|
|
234
319
|
}
|
|
235
320
|
if (prop.hasConvertToDatabaseValueSQL && !prop.object && !isRaw(data[k])) {
|
|
236
321
|
const quoted = this.platform.quoteValue(data[k]);
|
|
@@ -244,7 +329,7 @@ export class DatabaseDriver {
|
|
|
244
329
|
return data;
|
|
245
330
|
}
|
|
246
331
|
inlineEmbeddables(meta, data, where) {
|
|
247
|
-
/* v8 ignore next
|
|
332
|
+
/* v8 ignore next */
|
|
248
333
|
if (data == null) {
|
|
249
334
|
return;
|
|
250
335
|
}
|
|
@@ -264,38 +349,38 @@ export class DatabaseDriver {
|
|
|
264
349
|
// explicitly allow `$exists`, `$eq` and `$ne` operators here as they can't be misused this way
|
|
265
350
|
const operator = Object.keys(data[prop.name]).some(f => Utils.isOperator(f) && !['$exists', '$ne', '$eq'].includes(f));
|
|
266
351
|
if (operator) {
|
|
267
|
-
throw ValidationError.cannotUseOperatorsInsideEmbeddables(meta.
|
|
352
|
+
throw ValidationError.cannotUseOperatorsInsideEmbeddables(meta.class, prop.name, data);
|
|
268
353
|
}
|
|
269
354
|
if (prop.object && where) {
|
|
270
355
|
const inline = (payload, sub, path) => {
|
|
271
356
|
if (sub.kind === ReferenceKind.EMBEDDED && Utils.isObject(payload[sub.embedded[1]])) {
|
|
272
357
|
return Object.keys(payload[sub.embedded[1]]).forEach(kkk => {
|
|
273
358
|
if (!sub.embeddedProps[kkk]) {
|
|
274
|
-
throw ValidationError.invalidEmbeddableQuery(meta.
|
|
359
|
+
throw ValidationError.invalidEmbeddableQuery(meta.class, kkk, sub.type);
|
|
275
360
|
}
|
|
276
|
-
inline(payload[sub.embedded[1]], sub.embeddedProps[kkk], [...path, sub.
|
|
361
|
+
inline(payload[sub.embedded[1]], sub.embeddedProps[kkk], [...path, sub.fieldNames[0]]);
|
|
277
362
|
});
|
|
278
363
|
}
|
|
279
|
-
data[`${path.join('.')}.${sub.
|
|
364
|
+
data[`${path.join('.')}.${sub.fieldNames[0]}`] = payload[sub.embedded[1]];
|
|
280
365
|
};
|
|
281
366
|
const parentPropName = kk.substring(0, kk.indexOf('.'));
|
|
282
367
|
// we might be using some native JSON operator, e.g. with mongodb's `$geoWithin` or `$exists`
|
|
283
368
|
if (props[kk]) {
|
|
284
369
|
/* v8 ignore next */
|
|
285
|
-
inline(data[prop.name], props[kk] || props[parentPropName], [prop.
|
|
370
|
+
inline(data[prop.name], props[kk] || props[parentPropName], [prop.fieldNames[0]]);
|
|
286
371
|
}
|
|
287
372
|
else if (props[parentPropName]) {
|
|
288
|
-
data[`${prop.
|
|
373
|
+
data[`${prop.fieldNames[0]}.${kk}`] = data[prop.name][kk];
|
|
289
374
|
}
|
|
290
375
|
else {
|
|
291
376
|
unknownProp = true;
|
|
292
377
|
}
|
|
293
378
|
}
|
|
294
379
|
else if (props[kk]) {
|
|
295
|
-
data[props[kk].
|
|
380
|
+
data[props[kk].fieldNames[0]] = data[prop.name][props[kk].embedded[1]];
|
|
296
381
|
}
|
|
297
382
|
else {
|
|
298
|
-
throw ValidationError.invalidEmbeddableQuery(meta.
|
|
383
|
+
throw ValidationError.invalidEmbeddableQuery(meta.class, kk, prop.type);
|
|
299
384
|
}
|
|
300
385
|
});
|
|
301
386
|
if (!unknownProp) {
|
|
@@ -304,14 +389,24 @@ export class DatabaseDriver {
|
|
|
304
389
|
}
|
|
305
390
|
});
|
|
306
391
|
}
|
|
307
|
-
getPrimaryKeyFields(
|
|
308
|
-
|
|
309
|
-
return meta ? Utils.flatten(meta.getPrimaryProps().map(pk => pk.fieldNames)) : [this.config.getNamingStrategy().referenceColumnName()];
|
|
392
|
+
getPrimaryKeyFields(meta) {
|
|
393
|
+
return meta.getPrimaryProps().flatMap(pk => pk.fieldNames);
|
|
310
394
|
}
|
|
311
395
|
createReplicas(cb) {
|
|
312
396
|
const replicas = this.config.get('replicas', []);
|
|
313
397
|
const ret = [];
|
|
314
|
-
const props = [
|
|
398
|
+
const props = [
|
|
399
|
+
'dbName',
|
|
400
|
+
'clientUrl',
|
|
401
|
+
'host',
|
|
402
|
+
'port',
|
|
403
|
+
'user',
|
|
404
|
+
'password',
|
|
405
|
+
'multipleStatements',
|
|
406
|
+
'pool',
|
|
407
|
+
'name',
|
|
408
|
+
'driverOptions',
|
|
409
|
+
];
|
|
315
410
|
for (const conf of replicas) {
|
|
316
411
|
const replicaConfig = Utils.copy(conf);
|
|
317
412
|
for (const prop of props) {
|
|
@@ -372,4 +467,8 @@ export class DatabaseDriver {
|
|
|
372
467
|
const schemaName = meta?.schema === '*' ? this.config.getSchema() : meta?.schema;
|
|
373
468
|
return options?.schema ?? options?.parentSchema ?? schemaName ?? this.config.getSchema();
|
|
374
469
|
}
|
|
470
|
+
/** @internal */
|
|
471
|
+
getORMClass() {
|
|
472
|
+
return MikroORM;
|
|
473
|
+
}
|
|
375
474
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary,
|
|
1
|
+
import type { ConnectionType, Constructor, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes } from '../typings.js';
|
|
2
2
|
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
|
|
3
3
|
import type { FlushMode, LockMode, QueryOrderMap, QueryFlag, LoadStrategy, PopulateHint, PopulatePath } from '../enums.js';
|
|
4
4
|
import type { Platform } from '../platforms/Platform.js';
|
|
@@ -7,34 +7,40 @@ import type { Collection } from '../entity/Collection.js';
|
|
|
7
7
|
import type { EntityManager } from '../EntityManager.js';
|
|
8
8
|
import type { DriverException } from '../exceptions.js';
|
|
9
9
|
import type { Configuration } from '../utils/Configuration.js';
|
|
10
|
+
import type { MikroORM } from '../MikroORM.js';
|
|
10
11
|
import type { LoggingOptions, LogContext } from '../logging/Logger.js';
|
|
11
|
-
import type {
|
|
12
|
+
import type { Raw } from '../utils/RawQueryFragment.js';
|
|
12
13
|
export declare const EntityManagerType: unique symbol;
|
|
13
14
|
export interface IDatabaseDriver<C extends Connection = Connection> {
|
|
14
15
|
[EntityManagerType]: EntityManager<this>;
|
|
15
16
|
readonly config: Configuration;
|
|
16
17
|
createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
|
|
17
|
-
connect(
|
|
18
|
+
connect(options?: {
|
|
19
|
+
skipOnConnect?: boolean;
|
|
20
|
+
}): Promise<C>;
|
|
18
21
|
close(force?: boolean): Promise<void>;
|
|
19
|
-
reconnect(
|
|
22
|
+
reconnect(options?: {
|
|
23
|
+
skipOnConnect?: boolean;
|
|
24
|
+
}): Promise<C>;
|
|
20
25
|
getConnection(type?: ConnectionType): C;
|
|
21
26
|
/**
|
|
22
27
|
* Finds selection of entities
|
|
23
28
|
*/
|
|
24
|
-
find<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName:
|
|
29
|
+
find<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
|
|
25
30
|
/**
|
|
26
31
|
* Finds single entity (table row, document)
|
|
27
32
|
*/
|
|
28
|
-
findOne<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName:
|
|
29
|
-
findVirtual<T extends object>(entityName:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
findOne<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
|
|
34
|
+
findVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
|
|
35
|
+
stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T>): AsyncIterableIterator<T>;
|
|
36
|
+
nativeInsert<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
37
|
+
nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
|
|
38
|
+
nativeUpdate<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
39
|
+
nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
|
|
40
|
+
nativeDelete<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options?: NativeDeleteOptions<T>): Promise<QueryResult<T>>;
|
|
35
41
|
syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
|
|
36
|
-
count<T extends object, P extends string = never>(entityName:
|
|
37
|
-
aggregate(entityName:
|
|
42
|
+
count<T extends object, P extends string = never>(entityName: EntityName<T>, where: FilterQuery<T>, options?: CountOptions<T, P>): Promise<number>;
|
|
43
|
+
aggregate(entityName: EntityName, pipeline: any[]): Promise<any[]>;
|
|
38
44
|
mapResult<T extends object>(result: EntityDictionary<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[]): EntityData<T> | null;
|
|
39
45
|
/**
|
|
40
46
|
* When driver uses pivot tables for M:N, this method will load identifiers for given collections from them
|
|
@@ -60,6 +66,10 @@ export interface IDatabaseDriver<C extends Connection = Connection> {
|
|
|
60
66
|
schema?: string;
|
|
61
67
|
parentSchema?: string;
|
|
62
68
|
}): string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
getORMClass(): Constructor<MikroORM>;
|
|
63
73
|
}
|
|
64
74
|
export type EntityField<T, P extends string = PopulatePath.ALL> = keyof T | PopulatePath.ALL | AutoPath<T, P, `${PopulatePath.ALL}`>;
|
|
65
75
|
export type OrderDefinition<T> = (QueryOrderMap<T> & {
|
|
@@ -68,6 +78,18 @@ export type OrderDefinition<T> = (QueryOrderMap<T> & {
|
|
|
68
78
|
export interface FindAllOptions<T, P extends string = never, F extends string = '*', E extends string = never> extends FindOptions<T, P, F, E> {
|
|
69
79
|
where?: FilterQuery<T>;
|
|
70
80
|
}
|
|
81
|
+
export interface StreamOptions<Entity, Populate extends string = never, Fields extends string = '*', Exclude extends string = never> extends Omit<FindAllOptions<Entity, Populate, Fields, Exclude>, 'cache' | 'before' | 'after' | 'first' | 'last' | 'overfetch' | 'strategy'> {
|
|
82
|
+
/**
|
|
83
|
+
* When populating to-many relations, the ORM streams fully merged entities instead of yielding every row.
|
|
84
|
+
* You can opt out of this behavior by specifying `mergeResults: false`. This will yield every row from
|
|
85
|
+
* the SQL result, but still mapped to entities, meaning that to-many collections will contain at most
|
|
86
|
+
* a single item, and you will get duplicate root entities when they have multiple items in the populated
|
|
87
|
+
* collection.
|
|
88
|
+
*
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
mergeResults?: boolean;
|
|
92
|
+
}
|
|
71
93
|
export type FilterOptions = Dictionary<boolean | Dictionary> | string[] | boolean;
|
|
72
94
|
export interface LoadHint<Entity, Hint extends string = never, Fields extends string = PopulatePath.ALL, Excludes extends string = never> {
|
|
73
95
|
populate?: Populate<Entity, Hint>;
|
|
@@ -88,8 +110,28 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
88
110
|
* when nesting the condition. This is used for implementation of joined filters.
|
|
89
111
|
*/
|
|
90
112
|
populateFilter?: ObjectQuery<Entity>;
|
|
113
|
+
/**
|
|
114
|
+
* Index-friendly alternative to `$or` for conditions that span joined relations.
|
|
115
|
+
* Each array element becomes an independent branch combined via `UNION ALL` subquery:
|
|
116
|
+
* `WHERE pk IN (branch_1 UNION ALL branch_2 ... branch_N)`.
|
|
117
|
+
* The database plans each branch independently, enabling per-table index usage
|
|
118
|
+
* (e.g. GIN trigram indexes for fuzzy search across related entities).
|
|
119
|
+
* sql only
|
|
120
|
+
*/
|
|
121
|
+
unionWhere?: ObjectQuery<Entity>[];
|
|
122
|
+
/**
|
|
123
|
+
* Strategy for combining `unionWhere` branches.
|
|
124
|
+
* - `'union-all'` (default) — skips deduplication, faster for most use cases.
|
|
125
|
+
* - `'union'` — deduplicates rows between branches; useful when branch overlap is very high.
|
|
126
|
+
* sql only
|
|
127
|
+
*/
|
|
128
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
91
129
|
/** Used for ordering of the populate queries. If not specified, the value of `options.orderBy` is used. */
|
|
92
130
|
populateOrderBy?: OrderDefinition<Entity>;
|
|
131
|
+
/** Per-relation overrides for populate loading behavior. Keys are populate paths (same as used in `populate`). */
|
|
132
|
+
populateHints?: [Hint] extends [never] ? never : {
|
|
133
|
+
[K in Prefixes<Hint>]?: PopulateHintOptions;
|
|
134
|
+
};
|
|
93
135
|
/** Ordering of the results.Can be an object or array of objects, keys are property names, values are ordering (asc/desc) */
|
|
94
136
|
orderBy?: OrderDefinition<Entity>;
|
|
95
137
|
/** Control result caching for this query. Result cache is by default disabled, not to be confused with the identity map. */
|
|
@@ -127,7 +169,7 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
127
169
|
flags?: QueryFlag[];
|
|
128
170
|
/** sql only */
|
|
129
171
|
groupBy?: string | string[];
|
|
130
|
-
having?:
|
|
172
|
+
having?: FilterQuery<Entity>;
|
|
131
173
|
/** sql only */
|
|
132
174
|
strategy?: LoadStrategy | `${LoadStrategy}`;
|
|
133
175
|
flushMode?: FlushMode | `${FlushMode}`;
|
|
@@ -138,21 +180,27 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
138
180
|
lockTableAliases?: string[];
|
|
139
181
|
ctx?: Transaction;
|
|
140
182
|
connectionType?: ConnectionType;
|
|
141
|
-
/**
|
|
142
|
-
indexHint?: string;
|
|
183
|
+
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
184
|
+
indexHint?: string | Dictionary;
|
|
143
185
|
/** sql only */
|
|
144
186
|
comments?: string | string[];
|
|
145
187
|
/** sql only */
|
|
146
188
|
hintComments?: string | string[];
|
|
189
|
+
/** SQL: collation name string applied as COLLATE to ORDER BY; MongoDB: CollationOptions object. */
|
|
190
|
+
collation?: CollationOptions | string;
|
|
191
|
+
/** mongodb only */
|
|
192
|
+
maxTimeMS?: number;
|
|
193
|
+
/** mongodb only */
|
|
194
|
+
allowDiskUse?: boolean;
|
|
147
195
|
loggerContext?: LogContext;
|
|
148
196
|
logging?: LoggingOptions;
|
|
149
197
|
/** @internal used to apply filters to the auto-joined relations */
|
|
150
198
|
em?: EntityManager;
|
|
151
199
|
}
|
|
152
|
-
export interface FindByCursorOptions<T extends object, P extends string = never, F extends string = '*', E extends string = never, I extends boolean = true> extends Omit<
|
|
200
|
+
export interface FindByCursorOptions<T extends object, P extends string = never, F extends string = '*', E extends string = never, I extends boolean = true> extends Omit<FindAllOptions<T, P, F, E>, 'limit' | 'offset'> {
|
|
153
201
|
includeCount?: I;
|
|
154
202
|
}
|
|
155
|
-
export interface FindOneOptions<T
|
|
203
|
+
export interface FindOneOptions<T, P extends string = never, F extends string = '*', E extends string = never> extends Omit<FindOptions<T, P, F, E>, 'limit' | 'lockMode'> {
|
|
156
204
|
lockMode?: LockMode;
|
|
157
205
|
lockVersion?: number | Date;
|
|
158
206
|
}
|
|
@@ -167,15 +215,23 @@ export interface NativeInsertUpdateOptions<T> {
|
|
|
167
215
|
/** `nativeUpdate()` only option */
|
|
168
216
|
upsert?: boolean;
|
|
169
217
|
loggerContext?: LogContext;
|
|
218
|
+
/** sql only */
|
|
219
|
+
unionWhere?: ObjectQuery<T>[];
|
|
220
|
+
/** sql only */
|
|
221
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
222
|
+
filters?: FilterOptions;
|
|
223
|
+
/** @internal */
|
|
224
|
+
em?: EntityManager;
|
|
170
225
|
}
|
|
171
226
|
export interface NativeInsertUpdateManyOptions<T> extends NativeInsertUpdateOptions<T> {
|
|
172
227
|
processCollections?: boolean;
|
|
173
228
|
}
|
|
174
229
|
export interface UpsertOptions<Entity, Fields extends string = never> extends Omit<NativeInsertUpdateOptions<Entity>, 'upsert'> {
|
|
175
|
-
onConflictFields?: (keyof Entity)[] |
|
|
230
|
+
onConflictFields?: (keyof Entity)[] | Raw;
|
|
176
231
|
onConflictAction?: 'ignore' | 'merge';
|
|
177
232
|
onConflictMergeFields?: AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
|
|
178
233
|
onConflictExcludeFields?: AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
|
|
234
|
+
onConflictWhere?: FilterQuery<Entity>;
|
|
179
235
|
disableIdentityMap?: boolean;
|
|
180
236
|
}
|
|
181
237
|
export interface UpsertManyOptions<Entity, Fields extends string = never> extends UpsertOptions<Entity, Fields> {
|
|
@@ -185,20 +241,28 @@ export interface CountOptions<T extends object, P extends string = never> {
|
|
|
185
241
|
filters?: FilterOptions;
|
|
186
242
|
schema?: string;
|
|
187
243
|
groupBy?: string | readonly string[];
|
|
188
|
-
having?:
|
|
244
|
+
having?: FilterQuery<T>;
|
|
189
245
|
cache?: boolean | number | [string, number];
|
|
190
246
|
populate?: Populate<T, P>;
|
|
191
247
|
populateWhere?: ObjectQuery<T> | PopulateHint | `${PopulateHint}`;
|
|
192
248
|
populateFilter?: ObjectQuery<T>;
|
|
249
|
+
/** @see FindOptions.unionWhere */
|
|
250
|
+
unionWhere?: ObjectQuery<T>[];
|
|
251
|
+
/** @see FindOptions.unionWhereStrategy */
|
|
252
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
193
253
|
ctx?: Transaction;
|
|
194
254
|
connectionType?: ConnectionType;
|
|
195
255
|
flushMode?: FlushMode | `${FlushMode}`;
|
|
196
|
-
/**
|
|
197
|
-
indexHint?: string;
|
|
256
|
+
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
257
|
+
indexHint?: string | Dictionary;
|
|
198
258
|
/** sql only */
|
|
199
259
|
comments?: string | string[];
|
|
200
260
|
/** sql only */
|
|
201
261
|
hintComments?: string | string[];
|
|
262
|
+
/** SQL: collation name string applied as COLLATE; MongoDB: CollationOptions object. */
|
|
263
|
+
collation?: CollationOptions | string;
|
|
264
|
+
/** mongodb only */
|
|
265
|
+
maxTimeMS?: number;
|
|
202
266
|
loggerContext?: LogContext;
|
|
203
267
|
logging?: LoggingOptions;
|
|
204
268
|
/** @internal used to apply filters to the auto-joined relations */
|
|
@@ -208,12 +272,28 @@ export interface UpdateOptions<T> {
|
|
|
208
272
|
filters?: FilterOptions;
|
|
209
273
|
schema?: string;
|
|
210
274
|
ctx?: Transaction;
|
|
275
|
+
/** sql only */
|
|
276
|
+
unionWhere?: ObjectQuery<T>[];
|
|
277
|
+
/** sql only */
|
|
278
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
211
279
|
}
|
|
212
280
|
export interface DeleteOptions<T> extends DriverMethodOptions {
|
|
213
281
|
filters?: FilterOptions;
|
|
282
|
+
/** sql only */
|
|
283
|
+
unionWhere?: ObjectQuery<T>[];
|
|
284
|
+
/** sql only */
|
|
285
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
286
|
+
/** @internal */
|
|
287
|
+
em?: EntityManager;
|
|
214
288
|
}
|
|
215
289
|
export interface NativeDeleteOptions<T> extends DriverMethodOptions {
|
|
216
290
|
filters?: FilterOptions;
|
|
291
|
+
/** sql only */
|
|
292
|
+
unionWhere?: ObjectQuery<T>[];
|
|
293
|
+
/** sql only */
|
|
294
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
295
|
+
/** @internal */
|
|
296
|
+
em?: EntityManager;
|
|
217
297
|
}
|
|
218
298
|
export interface LockOptions extends DriverMethodOptions {
|
|
219
299
|
lockMode?: LockMode;
|
|
@@ -226,8 +306,23 @@ export interface DriverMethodOptions {
|
|
|
226
306
|
schema?: string;
|
|
227
307
|
loggerContext?: LogContext;
|
|
228
308
|
}
|
|
309
|
+
export interface CollationOptions {
|
|
310
|
+
locale: string;
|
|
311
|
+
caseLevel?: boolean;
|
|
312
|
+
caseFirst?: string;
|
|
313
|
+
strength?: number;
|
|
314
|
+
numericOrdering?: boolean;
|
|
315
|
+
alternate?: string;
|
|
316
|
+
maxVariable?: string;
|
|
317
|
+
backwards?: boolean;
|
|
318
|
+
}
|
|
229
319
|
export interface GetReferenceOptions {
|
|
230
320
|
wrapped?: boolean;
|
|
231
321
|
convertCustomTypes?: boolean;
|
|
232
322
|
schema?: string;
|
|
323
|
+
/**
|
|
324
|
+
* Property name to use for identity map lookup instead of the primary key.
|
|
325
|
+
* This is useful for creating references by unique non-PK properties.
|
|
326
|
+
*/
|
|
327
|
+
key?: string;
|
|
233
328
|
}
|