@mikro-orm/core 7.0.2-dev.9 → 7.0.2
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 +883 -579
- package/EntityManager.js +1897 -1865
- package/MikroORM.d.ts +103 -72
- package/MikroORM.js +178 -177
- package/README.md +128 -294
- package/cache/CacheAdapter.d.ts +38 -36
- package/cache/FileCacheAdapter.d.ts +30 -24
- package/cache/FileCacheAdapter.js +80 -78
- package/cache/GeneratedCacheAdapter.d.ts +19 -20
- package/cache/GeneratedCacheAdapter.js +31 -30
- package/cache/MemoryCacheAdapter.d.ts +19 -20
- package/cache/MemoryCacheAdapter.js +36 -36
- package/cache/NullCacheAdapter.d.ts +17 -16
- package/cache/NullCacheAdapter.js +25 -24
- package/connections/Connection.d.ts +99 -75
- package/connections/Connection.js +166 -160
- package/drivers/DatabaseDriver.d.ts +187 -69
- package/drivers/DatabaseDriver.js +451 -432
- package/drivers/IDatabaseDriver.d.ts +464 -281
- package/drivers/IDatabaseDriver.js +1 -0
- package/entity/BaseEntity.d.ts +121 -73
- package/entity/BaseEntity.js +44 -33
- package/entity/Collection.d.ts +216 -157
- package/entity/Collection.js +728 -707
- package/entity/EntityAssigner.d.ts +90 -76
- package/entity/EntityAssigner.js +232 -229
- package/entity/EntityFactory.d.ts +68 -40
- package/entity/EntityFactory.js +427 -366
- package/entity/EntityHelper.d.ts +34 -22
- package/entity/EntityHelper.js +280 -267
- package/entity/EntityIdentifier.d.ts +4 -4
- package/entity/EntityIdentifier.js +10 -10
- package/entity/EntityLoader.d.ts +105 -56
- package/entity/EntityLoader.js +754 -722
- package/entity/EntityRepository.d.ts +317 -200
- package/entity/EntityRepository.js +214 -212
- package/entity/PolymorphicRef.d.ts +5 -5
- package/entity/PolymorphicRef.js +10 -10
- package/entity/Reference.d.ts +130 -66
- package/entity/Reference.js +280 -260
- package/entity/WrappedEntity.d.ts +116 -53
- package/entity/WrappedEntity.js +169 -147
- package/entity/defineEntity.d.ts +1290 -614
- package/entity/defineEntity.js +521 -511
- package/entity/utils.d.ts +13 -3
- package/entity/utils.js +71 -73
- package/entity/validators.js +43 -43
- package/entity/wrap.js +8 -8
- package/enums.d.ts +275 -138
- package/enums.js +268 -137
- package/errors.d.ts +120 -72
- package/errors.js +356 -253
- package/events/EventManager.d.ts +27 -10
- package/events/EventManager.js +80 -73
- package/events/EventSubscriber.d.ts +33 -29
- package/events/TransactionEventBroadcaster.d.ts +16 -7
- package/events/TransactionEventBroadcaster.js +15 -13
- package/exceptions.d.ts +23 -40
- package/exceptions.js +35 -52
- package/hydration/Hydrator.d.ts +43 -16
- package/hydration/Hydrator.js +44 -42
- package/hydration/ObjectHydrator.d.ts +51 -17
- package/hydration/ObjectHydrator.js +480 -416
- package/index.d.ts +116 -2
- package/index.js +10 -1
- package/logging/DefaultLogger.d.ts +35 -30
- package/logging/DefaultLogger.js +87 -84
- package/logging/Logger.d.ts +45 -40
- package/logging/SimpleLogger.d.ts +13 -11
- package/logging/SimpleLogger.js +22 -22
- package/logging/colors.d.ts +6 -6
- package/logging/colors.js +11 -10
- package/logging/inspect.js +7 -7
- package/metadata/EntitySchema.d.ts +214 -108
- package/metadata/EntitySchema.js +398 -379
- package/metadata/MetadataDiscovery.d.ts +115 -111
- package/metadata/MetadataDiscovery.js +1948 -1857
- package/metadata/MetadataProvider.d.ts +25 -14
- package/metadata/MetadataProvider.js +83 -77
- package/metadata/MetadataStorage.d.ts +39 -19
- package/metadata/MetadataStorage.js +119 -106
- package/metadata/MetadataValidator.d.ts +39 -39
- package/metadata/MetadataValidator.js +381 -338
- package/metadata/discover-entities.d.ts +5 -2
- package/metadata/discover-entities.js +27 -27
- package/metadata/types.d.ts +615 -531
- package/naming-strategy/AbstractNamingStrategy.d.ts +55 -39
- package/naming-strategy/AbstractNamingStrategy.js +91 -85
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +6 -6
- package/naming-strategy/EntityCaseNamingStrategy.js +22 -22
- package/naming-strategy/MongoNamingStrategy.d.ts +7 -6
- package/naming-strategy/MongoNamingStrategy.js +19 -18
- package/naming-strategy/NamingStrategy.d.ts +109 -99
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +8 -7
- package/naming-strategy/UnderscoreNamingStrategy.js +22 -21
- package/not-supported.js +7 -4
- package/package.json +1 -1
- package/platforms/ExceptionConverter.d.ts +2 -1
- package/platforms/ExceptionConverter.js +5 -4
- package/platforms/Platform.d.ts +310 -236
- package/platforms/Platform.js +661 -573
- package/serialization/EntitySerializer.d.ts +49 -25
- package/serialization/EntitySerializer.js +224 -216
- package/serialization/EntityTransformer.d.ts +11 -5
- package/serialization/EntityTransformer.js +220 -216
- package/serialization/SerializationContext.d.ts +27 -18
- package/serialization/SerializationContext.js +105 -100
- package/types/ArrayType.d.ts +9 -8
- package/types/ArrayType.js +34 -33
- package/types/BigIntType.d.ts +17 -10
- package/types/BigIntType.js +37 -37
- package/types/BlobType.d.ts +4 -3
- package/types/BlobType.js +14 -13
- package/types/BooleanType.d.ts +5 -4
- package/types/BooleanType.js +13 -12
- package/types/CharacterType.d.ts +3 -2
- package/types/CharacterType.js +7 -6
- package/types/DateTimeType.d.ts +6 -5
- package/types/DateTimeType.js +16 -15
- package/types/DateType.d.ts +6 -5
- package/types/DateType.js +16 -15
- package/types/DecimalType.d.ts +7 -7
- package/types/DecimalType.js +26 -26
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +12 -12
- package/types/EnumArrayType.d.ts +6 -5
- package/types/EnumArrayType.js +25 -24
- package/types/EnumType.d.ts +4 -3
- package/types/EnumType.js +12 -11
- package/types/FloatType.d.ts +4 -3
- package/types/FloatType.js +10 -9
- package/types/IntegerType.d.ts +4 -3
- package/types/IntegerType.js +10 -9
- package/types/IntervalType.d.ts +5 -4
- package/types/IntervalType.js +13 -12
- package/types/JsonType.d.ts +9 -8
- package/types/JsonType.js +33 -32
- package/types/MediumIntType.d.ts +2 -1
- package/types/MediumIntType.js +4 -3
- package/types/SmallIntType.d.ts +4 -3
- package/types/SmallIntType.js +10 -9
- package/types/StringType.d.ts +5 -4
- package/types/StringType.js +13 -12
- package/types/TextType.d.ts +4 -3
- package/types/TextType.js +10 -9
- package/types/TimeType.d.ts +6 -5
- package/types/TimeType.js +18 -17
- package/types/TinyIntType.d.ts +4 -3
- package/types/TinyIntType.js +11 -10
- package/types/Type.d.ts +88 -73
- package/types/Type.js +85 -74
- package/types/Uint8ArrayType.d.ts +5 -4
- package/types/Uint8ArrayType.js +22 -21
- package/types/UnknownType.d.ts +5 -4
- package/types/UnknownType.js +13 -12
- package/types/UuidType.d.ts +6 -5
- package/types/UuidType.js +20 -19
- package/types/index.d.ts +77 -49
- package/types/index.js +64 -26
- package/typings.d.ts +1388 -729
- package/typings.js +255 -231
- package/unit-of-work/ChangeSet.d.ts +28 -24
- package/unit-of-work/ChangeSet.js +58 -54
- package/unit-of-work/ChangeSetComputer.d.ts +13 -11
- package/unit-of-work/ChangeSetComputer.js +180 -159
- package/unit-of-work/ChangeSetPersister.d.ts +64 -41
- package/unit-of-work/ChangeSetPersister.js +443 -418
- package/unit-of-work/CommitOrderCalculator.d.ts +40 -40
- package/unit-of-work/CommitOrderCalculator.js +89 -88
- package/unit-of-work/IdentityMap.d.ts +32 -25
- package/unit-of-work/IdentityMap.js +106 -99
- package/unit-of-work/UnitOfWork.d.ts +182 -127
- package/unit-of-work/UnitOfWork.js +1201 -1169
- package/utils/AbstractMigrator.d.ts +111 -91
- package/utils/AbstractMigrator.js +275 -275
- package/utils/AbstractSchemaGenerator.d.ts +43 -34
- package/utils/AbstractSchemaGenerator.js +121 -122
- package/utils/AsyncContext.d.ts +3 -3
- package/utils/AsyncContext.js +34 -35
- package/utils/Configuration.d.ts +853 -801
- package/utils/Configuration.js +360 -337
- package/utils/Cursor.d.ts +40 -22
- package/utils/Cursor.js +135 -127
- package/utils/DataloaderUtils.d.ts +58 -43
- package/utils/DataloaderUtils.js +203 -198
- package/utils/EntityComparator.d.ts +99 -80
- package/utils/EntityComparator.js +825 -727
- package/utils/NullHighlighter.d.ts +2 -1
- package/utils/NullHighlighter.js +4 -3
- package/utils/QueryHelper.d.ts +79 -51
- package/utils/QueryHelper.js +372 -361
- package/utils/RawQueryFragment.d.ts +54 -28
- package/utils/RawQueryFragment.js +110 -99
- package/utils/RequestContext.d.ts +33 -32
- package/utils/RequestContext.js +52 -53
- package/utils/TransactionContext.d.ts +17 -16
- package/utils/TransactionContext.js +28 -27
- package/utils/TransactionManager.d.ts +58 -58
- package/utils/TransactionManager.js +199 -197
- package/utils/Utils.d.ts +210 -145
- package/utils/Utils.js +820 -813
- package/utils/clone.js +104 -113
- package/utils/env-vars.js +90 -88
- package/utils/fs-utils.d.ts +15 -15
- package/utils/fs-utils.js +180 -181
- package/utils/upsert-utils.d.ts +20 -5
- package/utils/upsert-utils.js +114 -116
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ConnectionType,
|
|
3
|
+
Constructor,
|
|
4
|
+
EntityData,
|
|
5
|
+
EntityMetadata,
|
|
6
|
+
EntityProperty,
|
|
7
|
+
FilterQuery,
|
|
8
|
+
Primary,
|
|
9
|
+
Dictionary,
|
|
10
|
+
IPrimaryKey,
|
|
11
|
+
PopulateOptions,
|
|
12
|
+
EntityDictionary,
|
|
13
|
+
AutoPath,
|
|
14
|
+
ObjectQuery,
|
|
15
|
+
FilterObject,
|
|
16
|
+
Populate,
|
|
17
|
+
EntityName,
|
|
18
|
+
PopulateHintOptions,
|
|
19
|
+
Prefixes,
|
|
20
|
+
} from '../typings.js';
|
|
2
21
|
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
|
|
3
|
-
import type {
|
|
22
|
+
import type {
|
|
23
|
+
FlushMode,
|
|
24
|
+
LockMode,
|
|
25
|
+
QueryOrderMap,
|
|
26
|
+
QueryFlag,
|
|
27
|
+
LoadStrategy,
|
|
28
|
+
PopulateHint,
|
|
29
|
+
PopulatePath,
|
|
30
|
+
} from '../enums.js';
|
|
4
31
|
import type { Platform } from '../platforms/Platform.js';
|
|
5
32
|
import type { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
6
33
|
import type { Collection } from '../entity/Collection.js';
|
|
@@ -10,319 +37,475 @@ import type { Configuration } from '../utils/Configuration.js';
|
|
|
10
37
|
import type { MikroORM } from '../MikroORM.js';
|
|
11
38
|
import type { LoggingOptions, LogContext } from '../logging/Logger.js';
|
|
12
39
|
import type { Raw } from '../utils/RawQueryFragment.js';
|
|
40
|
+
/** Symbol used to extract the EntityManager type from a driver instance. */
|
|
13
41
|
export declare const EntityManagerType: unique symbol;
|
|
42
|
+
/** Interface defining the contract for all database drivers. */
|
|
14
43
|
export interface IDatabaseDriver<C extends Connection = Connection> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
44
|
+
[EntityManagerType]: EntityManager<this>;
|
|
45
|
+
readonly config: Configuration;
|
|
46
|
+
/** Creates a new EntityManager instance for this driver. */
|
|
47
|
+
createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
|
|
48
|
+
/** Opens a connection to the database. */
|
|
49
|
+
connect(options?: { skipOnConnect?: boolean }): Promise<C>;
|
|
50
|
+
/** Closes the database connection. */
|
|
51
|
+
close(force?: boolean): Promise<void>;
|
|
52
|
+
/** Closes and re-establishes the database connection. */
|
|
53
|
+
reconnect(options?: { skipOnConnect?: boolean }): Promise<C>;
|
|
54
|
+
/** Returns the underlying database connection (write or read replica). */
|
|
55
|
+
getConnection(type?: ConnectionType): C;
|
|
56
|
+
/**
|
|
57
|
+
* Finds selection of entities
|
|
58
|
+
*/
|
|
59
|
+
find<T extends object, P extends string = never, F extends string = '*', E extends string = never>(
|
|
60
|
+
entityName: EntityName<T>,
|
|
61
|
+
where: FilterQuery<T>,
|
|
62
|
+
options?: FindOptions<T, P, F, E>,
|
|
63
|
+
): Promise<EntityData<T>[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Finds single entity (table row, document)
|
|
66
|
+
*/
|
|
67
|
+
findOne<T extends object, P extends string = never, F extends string = '*', E extends string = never>(
|
|
68
|
+
entityName: EntityName<T>,
|
|
69
|
+
where: FilterQuery<T>,
|
|
70
|
+
options?: FindOneOptions<T, P, F, E>,
|
|
71
|
+
): Promise<EntityData<T> | null>;
|
|
72
|
+
/** Finds entities backed by a virtual (expression-based) definition. */
|
|
73
|
+
findVirtual<T extends object>(
|
|
74
|
+
entityName: EntityName<T>,
|
|
75
|
+
where: FilterQuery<T>,
|
|
76
|
+
options: FindOptions<T, any, any, any>,
|
|
77
|
+
): Promise<EntityData<T>[]>;
|
|
78
|
+
/** Returns an async iterator that streams query results one entity at a time. */
|
|
79
|
+
stream<T extends object>(
|
|
80
|
+
entityName: EntityName<T>,
|
|
81
|
+
where: FilterQuery<T>,
|
|
82
|
+
options: StreamOptions<T>,
|
|
83
|
+
): AsyncIterableIterator<T>;
|
|
84
|
+
/** Inserts a single row into the database. */
|
|
85
|
+
nativeInsert<T extends object>(
|
|
86
|
+
entityName: EntityName<T>,
|
|
87
|
+
data: EntityDictionary<T>,
|
|
88
|
+
options?: NativeInsertUpdateOptions<T>,
|
|
89
|
+
): Promise<QueryResult<T>>;
|
|
90
|
+
/** Inserts multiple rows into the database in a single batch operation. */
|
|
91
|
+
nativeInsertMany<T extends object>(
|
|
92
|
+
entityName: EntityName<T>,
|
|
93
|
+
data: EntityDictionary<T>[],
|
|
94
|
+
options?: NativeInsertUpdateManyOptions<T>,
|
|
95
|
+
transform?: (sql: string) => string,
|
|
96
|
+
): Promise<QueryResult<T>>;
|
|
97
|
+
/** Updates rows matching the given condition. */
|
|
98
|
+
nativeUpdate<T extends object>(
|
|
99
|
+
entityName: EntityName<T>,
|
|
100
|
+
where: FilterQuery<T>,
|
|
101
|
+
data: EntityDictionary<T>,
|
|
102
|
+
options?: NativeInsertUpdateOptions<T>,
|
|
103
|
+
): Promise<QueryResult<T>>;
|
|
104
|
+
/** Updates multiple rows with different payloads in a single batch operation. */
|
|
105
|
+
nativeUpdateMany<T extends object>(
|
|
106
|
+
entityName: EntityName<T>,
|
|
107
|
+
where: FilterQuery<T>[],
|
|
108
|
+
data: EntityDictionary<T>[],
|
|
109
|
+
options?: NativeInsertUpdateManyOptions<T>,
|
|
110
|
+
): Promise<QueryResult<T>>;
|
|
111
|
+
/** Deletes rows matching the given condition. */
|
|
112
|
+
nativeDelete<T extends object>(
|
|
113
|
+
entityName: EntityName<T>,
|
|
114
|
+
where: FilterQuery<T>,
|
|
115
|
+
options?: NativeDeleteOptions<T>,
|
|
116
|
+
): Promise<QueryResult<T>>;
|
|
117
|
+
/** Persists changes to M:N collections (inserts/deletes pivot table rows). */
|
|
118
|
+
syncCollections<T extends object, O extends object>(
|
|
119
|
+
collections: Iterable<Collection<T, O>>,
|
|
120
|
+
options?: DriverMethodOptions,
|
|
121
|
+
): Promise<void>;
|
|
122
|
+
/** Counts entities matching the given condition. */
|
|
123
|
+
count<T extends object, P extends string = never>(
|
|
124
|
+
entityName: EntityName<T>,
|
|
125
|
+
where: FilterQuery<T>,
|
|
126
|
+
options?: CountOptions<T, P>,
|
|
127
|
+
): Promise<number>;
|
|
128
|
+
/** Executes a MongoDB aggregation pipeline (MongoDB driver only). */
|
|
129
|
+
aggregate(entityName: EntityName, pipeline: any[]): Promise<any[]>;
|
|
130
|
+
/** Maps raw database result to entity data, converting column names to property names. */
|
|
131
|
+
mapResult<T extends object>(
|
|
132
|
+
result: EntityDictionary<T>,
|
|
133
|
+
meta: EntityMetadata<T>,
|
|
134
|
+
populate?: PopulateOptions<T>[],
|
|
135
|
+
): EntityData<T> | null;
|
|
136
|
+
/**
|
|
137
|
+
* When driver uses pivot tables for M:N, this method will load identifiers for given collections from them
|
|
138
|
+
*/
|
|
139
|
+
loadFromPivotTable<T extends object, O extends object>(
|
|
140
|
+
prop: EntityProperty,
|
|
141
|
+
owners: Primary<O>[][],
|
|
142
|
+
where?: FilterQuery<T>,
|
|
143
|
+
orderBy?: OrderDefinition<T>,
|
|
144
|
+
ctx?: Transaction,
|
|
145
|
+
options?: FindOptions<T, any, any, any>,
|
|
146
|
+
pivotJoin?: boolean,
|
|
147
|
+
): Promise<Dictionary<T[]>>;
|
|
148
|
+
/** Returns the database platform abstraction for this driver. */
|
|
149
|
+
getPlatform(): Platform;
|
|
150
|
+
/** Sets the metadata storage used by this driver. */
|
|
151
|
+
setMetadata(metadata: MetadataStorage): void;
|
|
152
|
+
/** Returns the metadata storage used by this driver. */
|
|
153
|
+
getMetadata(): MetadataStorage;
|
|
154
|
+
/**
|
|
155
|
+
* Returns name of the underlying database dependencies (e.g. `mongodb` or `mysql2`)
|
|
156
|
+
* for SQL drivers it also returns `knex` in the array as connectors are not used directly there
|
|
157
|
+
*/
|
|
158
|
+
getDependencies(): string[];
|
|
159
|
+
/** Acquires a pessimistic lock on the given entity. */
|
|
160
|
+
lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Converts native db errors to standardized driver exceptions
|
|
163
|
+
*/
|
|
164
|
+
convertException(exception: Error): DriverException;
|
|
165
|
+
/**
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
getSchemaName(
|
|
169
|
+
meta?: EntityMetadata,
|
|
170
|
+
options?: {
|
|
171
|
+
schema?: string;
|
|
172
|
+
parentSchema?: string;
|
|
173
|
+
},
|
|
174
|
+
): string | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
getORMClass(): Constructor<MikroORM>;
|
|
73
179
|
}
|
|
74
|
-
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
180
|
+
/** Represents a field selector for entity queries (property name or wildcard). */
|
|
181
|
+
export type EntityField<T, P extends string = PopulatePath.ALL> =
|
|
182
|
+
| keyof T
|
|
183
|
+
| PopulatePath.ALL
|
|
184
|
+
| AutoPath<T, P, `${PopulatePath.ALL}`>;
|
|
185
|
+
/** Defines the ordering for query results, either a single order map or an array of them. */
|
|
186
|
+
export type OrderDefinition<T> =
|
|
187
|
+
| (QueryOrderMap<T> & {
|
|
188
|
+
0?: never;
|
|
189
|
+
})
|
|
190
|
+
| QueryOrderMap<T>[];
|
|
191
|
+
/** Options for `em.findAll()`, extends FindOptions with an optional `where` clause. */
|
|
192
|
+
export interface FindAllOptions<
|
|
193
|
+
T,
|
|
194
|
+
P extends string = never,
|
|
195
|
+
F extends string = '*',
|
|
196
|
+
E extends string = never,
|
|
197
|
+
> extends FindOptions<T, P, F, E> {
|
|
198
|
+
where?: FilterQuery<T>;
|
|
80
199
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
200
|
+
/** Options for streaming query results via `em.stream()`. */
|
|
201
|
+
export interface StreamOptions<
|
|
202
|
+
Entity,
|
|
203
|
+
Populate extends string = never,
|
|
204
|
+
Fields extends string = '*',
|
|
205
|
+
Exclude extends string = never,
|
|
206
|
+
> extends Omit<
|
|
207
|
+
FindAllOptions<Entity, Populate, Fields, Exclude>,
|
|
208
|
+
'cache' | 'before' | 'after' | 'first' | 'last' | 'overfetch' | 'strategy'
|
|
209
|
+
> {
|
|
210
|
+
/**
|
|
211
|
+
* When populating to-many relations, the ORM streams fully merged entities instead of yielding every row.
|
|
212
|
+
* You can opt out of this behavior by specifying `mergeResults: false`. This will yield every row from
|
|
213
|
+
* the SQL result, but still mapped to entities, meaning that to-many collections will contain at most
|
|
214
|
+
* a single item, and you will get duplicate root entities when they have multiple items in the populated
|
|
215
|
+
* collection.
|
|
216
|
+
*
|
|
217
|
+
* @default true
|
|
218
|
+
*/
|
|
219
|
+
mergeResults?: boolean;
|
|
92
220
|
}
|
|
221
|
+
/** Configuration for enabling/disabling named filters on a query. */
|
|
93
222
|
export type FilterOptions = Dictionary<boolean | Dictionary> | string[] | boolean;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
223
|
+
/** Specifies which relations to populate and which fields to select or exclude. */
|
|
224
|
+
export interface LoadHint<
|
|
225
|
+
Entity,
|
|
226
|
+
Hint extends string = never,
|
|
227
|
+
Fields extends string = PopulatePath.ALL,
|
|
228
|
+
Excludes extends string = never,
|
|
229
|
+
> {
|
|
230
|
+
populate?: Populate<Entity, Hint>;
|
|
231
|
+
fields?: readonly AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
|
|
232
|
+
exclude?: readonly AutoPath<Entity, Excludes>[];
|
|
98
233
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
234
|
+
/** Options for `em.find()` queries, including population, ordering, pagination, and locking. */
|
|
235
|
+
export interface FindOptions<
|
|
236
|
+
Entity,
|
|
237
|
+
Hint extends string = never,
|
|
238
|
+
Fields extends string = PopulatePath.ALL,
|
|
239
|
+
Excludes extends string = never,
|
|
240
|
+
> extends LoadHint<Entity, Hint, Fields, Excludes> {
|
|
241
|
+
/**
|
|
242
|
+
* Where condition for populated relations. This will have no effect on the root entity.
|
|
243
|
+
* With `select-in` strategy, this is applied only to the populate queries.
|
|
244
|
+
* With `joined` strategy, those are applied as `join on` conditions.
|
|
245
|
+
* When you use a nested condition on a to-many relation, it will produce a nested inner join,
|
|
246
|
+
* discarding the collection items based on the child condition.
|
|
247
|
+
*/
|
|
248
|
+
populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
249
|
+
/**
|
|
250
|
+
* Filter condition for populated relations. This is similar to `populateWhere`, but will produce a `left join`
|
|
251
|
+
* when nesting the condition. This is used for implementation of joined filters.
|
|
252
|
+
*/
|
|
253
|
+
populateFilter?: ObjectQuery<Entity>;
|
|
254
|
+
/**
|
|
255
|
+
* Index-friendly alternative to `$or` for conditions that span joined relations.
|
|
256
|
+
* Each array element becomes an independent branch combined via `UNION ALL` subquery:
|
|
257
|
+
* `WHERE pk IN (branch_1 UNION ALL branch_2 ... branch_N)`.
|
|
258
|
+
* The database plans each branch independently, enabling per-table index usage
|
|
259
|
+
* (e.g. GIN trigram indexes for fuzzy search across related entities).
|
|
260
|
+
* sql only
|
|
261
|
+
*/
|
|
262
|
+
unionWhere?: ObjectQuery<Entity>[];
|
|
263
|
+
/**
|
|
264
|
+
* Strategy for combining `unionWhere` branches.
|
|
265
|
+
* - `'union-all'` (default) — skips deduplication, faster for most use cases.
|
|
266
|
+
* - `'union'` — deduplicates rows between branches; useful when branch overlap is very high.
|
|
267
|
+
* sql only
|
|
268
|
+
*/
|
|
269
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
270
|
+
/** Used for ordering of the populate queries. If not specified, the value of `options.orderBy` is used. */
|
|
271
|
+
populateOrderBy?: OrderDefinition<Entity>;
|
|
272
|
+
/** Per-relation overrides for populate loading behavior. Keys are populate paths (same as used in `populate`). */
|
|
273
|
+
populateHints?: [Hint] extends [never]
|
|
274
|
+
? never
|
|
275
|
+
: {
|
|
133
276
|
[K in Prefixes<Hint>]?: PopulateHintOptions;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
277
|
+
};
|
|
278
|
+
/** Ordering of the results.Can be an object or array of objects, keys are property names, values are ordering (asc/desc) */
|
|
279
|
+
orderBy?: OrderDefinition<Entity>;
|
|
280
|
+
/** Control result caching for this query. Result cache is by default disabled, not to be confused with the identity map. */
|
|
281
|
+
cache?: boolean | number | [string, number];
|
|
282
|
+
/**
|
|
283
|
+
* Limit the number of returned results. If you try to use limit/offset on a query that joins a to-many relation, pagination mechanism
|
|
284
|
+
* will be triggered, resulting in a subquery condition, to apply this limit only to the root entities
|
|
285
|
+
* instead of the cartesian product you get from a database in this case.
|
|
286
|
+
*/
|
|
287
|
+
limit?: number;
|
|
288
|
+
/**
|
|
289
|
+
* Sets the offset. If you try to use limit/offset on a query that joins a to-many relation, pagination mechanism
|
|
290
|
+
* will be triggered, resulting in a subquery condition, to apply this limit only to the root entities
|
|
291
|
+
* instead of the cartesian product you get from a database in this case.
|
|
292
|
+
*/
|
|
293
|
+
offset?: number;
|
|
294
|
+
/** Fetch items `before` this cursor. */
|
|
295
|
+
before?:
|
|
296
|
+
| string
|
|
297
|
+
| {
|
|
153
298
|
startCursor: string | null;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
299
|
+
}
|
|
300
|
+
| FilterObject<Entity>;
|
|
301
|
+
/** Fetch items `after` this cursor. */
|
|
302
|
+
after?:
|
|
303
|
+
| string
|
|
304
|
+
| {
|
|
157
305
|
endCursor: string | null;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
306
|
+
}
|
|
307
|
+
| FilterObject<Entity>;
|
|
308
|
+
/** Fetch `first` N items. */
|
|
309
|
+
first?: number;
|
|
310
|
+
/** Fetch `last` N items. */
|
|
311
|
+
last?: number;
|
|
312
|
+
/** Fetch one more item than `first`/`last`, enabled automatically in `em.findByCursor` to check if there is a next page. */
|
|
313
|
+
overfetch?: boolean;
|
|
314
|
+
refresh?: boolean;
|
|
315
|
+
convertCustomTypes?: boolean;
|
|
316
|
+
disableIdentityMap?: boolean;
|
|
317
|
+
schema?: string;
|
|
318
|
+
flags?: QueryFlag[];
|
|
319
|
+
/** sql only */
|
|
320
|
+
groupBy?: string | string[];
|
|
321
|
+
having?: FilterQuery<Entity>;
|
|
322
|
+
/** sql only */
|
|
323
|
+
strategy?: LoadStrategy | `${LoadStrategy}`;
|
|
324
|
+
flushMode?: FlushMode | `${FlushMode}`;
|
|
325
|
+
filters?: FilterOptions;
|
|
326
|
+
/** sql only */
|
|
327
|
+
lockMode?: Exclude<LockMode, LockMode.OPTIMISTIC>;
|
|
328
|
+
/** sql only */
|
|
329
|
+
lockTableAliases?: string[];
|
|
330
|
+
ctx?: Transaction;
|
|
331
|
+
connectionType?: ConnectionType;
|
|
332
|
+
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
333
|
+
indexHint?: string | Dictionary;
|
|
334
|
+
/** sql only */
|
|
335
|
+
comments?: string | string[];
|
|
336
|
+
/** sql only */
|
|
337
|
+
hintComments?: string | string[];
|
|
338
|
+
/** SQL: collation name string applied as COLLATE to ORDER BY; MongoDB: CollationOptions object. */
|
|
339
|
+
collation?: CollationOptions | string;
|
|
340
|
+
/** mongodb only */
|
|
341
|
+
maxTimeMS?: number;
|
|
342
|
+
/** mongodb only */
|
|
343
|
+
allowDiskUse?: boolean;
|
|
344
|
+
loggerContext?: LogContext;
|
|
345
|
+
logging?: LoggingOptions;
|
|
346
|
+
/** @internal used to apply filters to the auto-joined relations */
|
|
347
|
+
em?: EntityManager;
|
|
199
348
|
}
|
|
200
|
-
|
|
201
|
-
|
|
349
|
+
/** Options for cursor-based pagination via `em.findByCursor()`. */
|
|
350
|
+
export interface FindByCursorOptions<
|
|
351
|
+
T extends object,
|
|
352
|
+
P extends string = never,
|
|
353
|
+
F extends string = '*',
|
|
354
|
+
E extends string = never,
|
|
355
|
+
I extends boolean = true,
|
|
356
|
+
> extends Omit<FindAllOptions<T, P, F, E>, 'limit' | 'offset'> {
|
|
357
|
+
includeCount?: I;
|
|
202
358
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
359
|
+
/** Options for `em.findOne()`, extends FindOptions with optimistic lock version support. */
|
|
360
|
+
export interface FindOneOptions<
|
|
361
|
+
T,
|
|
362
|
+
P extends string = never,
|
|
363
|
+
F extends string = '*',
|
|
364
|
+
E extends string = never,
|
|
365
|
+
> extends Omit<FindOptions<T, P, F, E>, 'limit' | 'lockMode'> {
|
|
366
|
+
lockMode?: LockMode;
|
|
367
|
+
lockVersion?: number | Date;
|
|
206
368
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
369
|
+
/** Options for `em.findOneOrFail()`, adds a custom error handler for missing entities. */
|
|
370
|
+
export interface FindOneOrFailOptions<
|
|
371
|
+
T extends object,
|
|
372
|
+
P extends string = never,
|
|
373
|
+
F extends string = '*',
|
|
374
|
+
E extends string = never,
|
|
375
|
+
> extends FindOneOptions<T, P, F, E> {
|
|
376
|
+
failHandler?: (entityName: string, where: Dictionary | IPrimaryKey | any) => Error;
|
|
377
|
+
strict?: boolean;
|
|
210
378
|
}
|
|
379
|
+
/** Options for native insert and update operations. */
|
|
211
380
|
export interface NativeInsertUpdateOptions<T> {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
381
|
+
convertCustomTypes?: boolean;
|
|
382
|
+
ctx?: Transaction;
|
|
383
|
+
schema?: string;
|
|
384
|
+
/** `nativeUpdate()` only option */
|
|
385
|
+
upsert?: boolean;
|
|
386
|
+
loggerContext?: LogContext;
|
|
387
|
+
/** sql only */
|
|
388
|
+
unionWhere?: ObjectQuery<T>[];
|
|
389
|
+
/** sql only */
|
|
390
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
391
|
+
filters?: FilterOptions;
|
|
392
|
+
/** @internal */
|
|
393
|
+
em?: EntityManager;
|
|
225
394
|
}
|
|
395
|
+
/** Options for batch native insert and update operations. */
|
|
226
396
|
export interface NativeInsertUpdateManyOptions<T> extends NativeInsertUpdateOptions<T> {
|
|
227
|
-
|
|
397
|
+
processCollections?: boolean;
|
|
228
398
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
399
|
+
/** Options for `em.upsert()`, controlling conflict resolution behavior. */
|
|
400
|
+
export interface UpsertOptions<Entity, Fields extends string = never> extends Omit<
|
|
401
|
+
NativeInsertUpdateOptions<Entity>,
|
|
402
|
+
'upsert'
|
|
403
|
+
> {
|
|
404
|
+
onConflictFields?: (keyof Entity)[] | Raw;
|
|
405
|
+
onConflictAction?: 'ignore' | 'merge';
|
|
406
|
+
onConflictMergeFields?: AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
|
|
407
|
+
onConflictExcludeFields?: AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
|
|
408
|
+
onConflictWhere?: FilterQuery<Entity>;
|
|
409
|
+
disableIdentityMap?: boolean;
|
|
236
410
|
}
|
|
411
|
+
/** Options for `em.upsertMany()`, adds batch size control. */
|
|
237
412
|
export interface UpsertManyOptions<Entity, Fields extends string = never> extends UpsertOptions<Entity, Fields> {
|
|
238
|
-
|
|
413
|
+
batchSize?: number;
|
|
239
414
|
}
|
|
415
|
+
/** Options for `em.count()` queries. */
|
|
240
416
|
export interface CountOptions<T extends object, P extends string = never> {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
417
|
+
filters?: FilterOptions;
|
|
418
|
+
schema?: string;
|
|
419
|
+
groupBy?: string | readonly string[];
|
|
420
|
+
having?: FilterQuery<T>;
|
|
421
|
+
cache?: boolean | number | [string, number];
|
|
422
|
+
populate?: Populate<T, P>;
|
|
423
|
+
populateWhere?: ObjectQuery<T> | PopulateHint | `${PopulateHint}`;
|
|
424
|
+
populateFilter?: ObjectQuery<T>;
|
|
425
|
+
/** @see FindOptions.unionWhere */
|
|
426
|
+
unionWhere?: ObjectQuery<T>[];
|
|
427
|
+
/** @see FindOptions.unionWhereStrategy */
|
|
428
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
429
|
+
ctx?: Transaction;
|
|
430
|
+
connectionType?: ConnectionType;
|
|
431
|
+
flushMode?: FlushMode | `${FlushMode}`;
|
|
432
|
+
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
433
|
+
indexHint?: string | Dictionary;
|
|
434
|
+
/** sql only */
|
|
435
|
+
comments?: string | string[];
|
|
436
|
+
/** sql only */
|
|
437
|
+
hintComments?: string | string[];
|
|
438
|
+
/** SQL: collation name string applied as COLLATE; MongoDB: CollationOptions object. */
|
|
439
|
+
collation?: CollationOptions | string;
|
|
440
|
+
/** mongodb only */
|
|
441
|
+
maxTimeMS?: number;
|
|
442
|
+
loggerContext?: LogContext;
|
|
443
|
+
logging?: LoggingOptions;
|
|
444
|
+
/** @internal used to apply filters to the auto-joined relations */
|
|
445
|
+
em?: EntityManager;
|
|
270
446
|
}
|
|
447
|
+
/** Options for `em.qb().update()` operations. */
|
|
271
448
|
export interface UpdateOptions<T> {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
449
|
+
filters?: FilterOptions;
|
|
450
|
+
schema?: string;
|
|
451
|
+
ctx?: Transaction;
|
|
452
|
+
/** sql only */
|
|
453
|
+
unionWhere?: ObjectQuery<T>[];
|
|
454
|
+
/** sql only */
|
|
455
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
279
456
|
}
|
|
457
|
+
/** Options for `em.qb().delete()` operations. */
|
|
280
458
|
export interface DeleteOptions<T> extends DriverMethodOptions {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
459
|
+
filters?: FilterOptions;
|
|
460
|
+
/** sql only */
|
|
461
|
+
unionWhere?: ObjectQuery<T>[];
|
|
462
|
+
/** sql only */
|
|
463
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
464
|
+
/** @internal */
|
|
465
|
+
em?: EntityManager;
|
|
288
466
|
}
|
|
467
|
+
/** Options for `em.nativeDelete()` operations. */
|
|
289
468
|
export interface NativeDeleteOptions<T> extends DriverMethodOptions {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
469
|
+
filters?: FilterOptions;
|
|
470
|
+
/** sql only */
|
|
471
|
+
unionWhere?: ObjectQuery<T>[];
|
|
472
|
+
/** sql only */
|
|
473
|
+
unionWhereStrategy?: 'union-all' | 'union';
|
|
474
|
+
/** @internal */
|
|
475
|
+
em?: EntityManager;
|
|
297
476
|
}
|
|
477
|
+
/** Options for pessimistic and optimistic lock operations. */
|
|
298
478
|
export interface LockOptions extends DriverMethodOptions {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
479
|
+
lockMode?: LockMode;
|
|
480
|
+
lockVersion?: number | Date;
|
|
481
|
+
lockTableAliases?: string[];
|
|
482
|
+
logging?: LoggingOptions;
|
|
303
483
|
}
|
|
484
|
+
/** Base options shared by all driver methods (transaction context, schema, logging). */
|
|
304
485
|
export interface DriverMethodOptions {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
486
|
+
ctx?: Transaction;
|
|
487
|
+
schema?: string;
|
|
488
|
+
loggerContext?: LogContext;
|
|
308
489
|
}
|
|
490
|
+
/** MongoDB-style collation options for locale-aware string comparison. */
|
|
309
491
|
export interface CollationOptions {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
492
|
+
locale: string;
|
|
493
|
+
caseLevel?: boolean;
|
|
494
|
+
caseFirst?: string;
|
|
495
|
+
strength?: number;
|
|
496
|
+
numericOrdering?: boolean;
|
|
497
|
+
alternate?: string;
|
|
498
|
+
maxVariable?: string;
|
|
499
|
+
backwards?: boolean;
|
|
318
500
|
}
|
|
501
|
+
/** Options for `em.getReference()`, controlling wrapping and type conversion. */
|
|
319
502
|
export interface GetReferenceOptions {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
503
|
+
wrapped?: boolean;
|
|
504
|
+
convertCustomTypes?: boolean;
|
|
505
|
+
schema?: string;
|
|
506
|
+
/**
|
|
507
|
+
* Property name to use for identity map lookup instead of the primary key.
|
|
508
|
+
* This is useful for creating references by unique non-PK properties.
|
|
509
|
+
*/
|
|
510
|
+
key?: string;
|
|
328
511
|
}
|