@mikro-orm/core 7.0.0-dev.4 → 7.0.0-dev.41
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 +84 -18
- package/EntityManager.js +265 -172
- package/MikroORM.d.ts +7 -5
- package/MikroORM.js +0 -1
- package/README.md +3 -2
- package/cache/FileCacheAdapter.d.ts +2 -1
- package/cache/FileCacheAdapter.js +6 -4
- package/connections/Connection.d.ts +4 -2
- package/connections/Connection.js +2 -2
- package/decorators/Check.d.ts +2 -2
- package/decorators/Embeddable.d.ts +5 -5
- package/decorators/Embeddable.js +1 -1
- package/decorators/Embedded.d.ts +6 -12
- package/decorators/Entity.d.ts +18 -3
- package/decorators/Enum.d.ts +1 -1
- package/decorators/Formula.d.ts +1 -2
- package/decorators/Indexed.d.ts +2 -2
- package/decorators/ManyToMany.d.ts +4 -2
- package/decorators/ManyToOne.d.ts +6 -2
- package/decorators/OneToMany.d.ts +4 -4
- package/decorators/OneToOne.d.ts +5 -1
- package/decorators/PrimaryKey.d.ts +2 -3
- package/decorators/Property.d.ts +54 -4
- package/decorators/Transactional.d.ts +1 -0
- package/decorators/Transactional.js +3 -3
- package/decorators/index.d.ts +1 -1
- package/drivers/DatabaseDriver.d.ts +4 -3
- package/drivers/IDatabaseDriver.d.ts +22 -2
- package/entity/ArrayCollection.d.ts +4 -2
- package/entity/ArrayCollection.js +18 -6
- package/entity/Collection.d.ts +1 -2
- package/entity/Collection.js +19 -10
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +9 -1
- package/entity/EntityFactory.d.ts +7 -0
- package/entity/EntityFactory.js +29 -9
- package/entity/EntityHelper.js +25 -3
- package/entity/EntityLoader.d.ts +5 -4
- package/entity/EntityLoader.js +74 -37
- package/entity/EntityRepository.d.ts +1 -1
- package/entity/EntityValidator.js +1 -1
- package/entity/Reference.d.ts +9 -7
- package/entity/Reference.js +30 -3
- package/entity/WrappedEntity.js +1 -1
- package/entity/defineEntity.d.ts +561 -0
- package/entity/defineEntity.js +537 -0
- package/entity/index.d.ts +2 -0
- package/entity/index.js +2 -0
- package/entity/utils.d.ts +7 -0
- package/entity/utils.js +15 -3
- package/enums.d.ts +16 -3
- package/enums.js +13 -0
- package/errors.d.ts +6 -0
- package/errors.js +14 -0
- package/events/EventSubscriber.d.ts +3 -1
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +35 -24
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/SimpleLogger.d.ts +1 -1
- package/metadata/EntitySchema.d.ts +8 -4
- package/metadata/EntitySchema.js +39 -19
- package/metadata/MetadataDiscovery.d.ts +1 -1
- package/metadata/MetadataDiscovery.js +88 -32
- package/metadata/MetadataStorage.js +1 -1
- package/metadata/MetadataValidator.js +4 -3
- package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
- package/naming-strategy/AbstractNamingStrategy.js +7 -1
- package/naming-strategy/NamingStrategy.d.ts +11 -1
- package/package.json +5 -5
- package/platforms/Platform.d.ts +5 -3
- package/platforms/Platform.js +4 -8
- package/serialization/EntitySerializer.d.ts +2 -0
- package/serialization/EntitySerializer.js +2 -2
- package/serialization/EntityTransformer.js +1 -1
- package/serialization/SerializationContext.js +14 -11
- package/types/BigIntType.d.ts +9 -6
- package/types/BigIntType.js +3 -0
- package/types/BooleanType.d.ts +1 -1
- package/types/DecimalType.d.ts +6 -4
- package/types/DecimalType.js +1 -1
- package/types/DoubleType.js +1 -1
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/Type.d.ts +2 -1
- package/types/Type.js +1 -1
- package/types/index.d.ts +1 -1
- package/typings.d.ts +88 -39
- package/typings.js +24 -4
- package/unit-of-work/ChangeSetComputer.js +3 -1
- package/unit-of-work/ChangeSetPersister.d.ts +4 -2
- package/unit-of-work/ChangeSetPersister.js +37 -16
- package/unit-of-work/UnitOfWork.d.ts +8 -1
- package/unit-of-work/UnitOfWork.js +109 -41
- package/utils/Configuration.d.ts +23 -5
- package/utils/Configuration.js +17 -3
- package/utils/ConfigurationLoader.d.ts +0 -2
- package/utils/ConfigurationLoader.js +2 -24
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +3 -0
- package/utils/DataloaderUtils.d.ts +7 -2
- package/utils/DataloaderUtils.js +38 -7
- package/utils/EntityComparator.d.ts +6 -2
- package/utils/EntityComparator.js +104 -58
- package/utils/QueryHelper.d.ts +9 -1
- package/utils/QueryHelper.js +66 -5
- package/utils/RawQueryFragment.d.ts +36 -2
- package/utils/RawQueryFragment.js +35 -1
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +218 -0
- package/utils/Utils.d.ts +11 -5
- package/utils/Utils.js +76 -33
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/upsert-utils.d.ts +7 -2
- package/utils/upsert-utils.js +52 -1
package/EntityManager.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ import { EntityFactory } from './entity/EntityFactory.js';
|
|
|
6
6
|
import { type AssignOptions } from './entity/EntityAssigner.js';
|
|
7
7
|
import { EntityValidator } from './entity/EntityValidator.js';
|
|
8
8
|
import { type EntityRepository } from './entity/EntityRepository.js';
|
|
9
|
-
import { type EntityLoaderOptions } from './entity/EntityLoader.js';
|
|
9
|
+
import { EntityLoader, type EntityLoaderOptions } from './entity/EntityLoader.js';
|
|
10
10
|
import { Reference } from './entity/Reference.js';
|
|
11
11
|
import { UnitOfWork } from './unit-of-work/UnitOfWork.js';
|
|
12
|
-
import type { CountOptions, DeleteOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
|
|
13
|
-
import type { AnyEntity, AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MaybePromise, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
|
|
12
|
+
import type { CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, StreamOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
|
|
13
|
+
import type { AnyEntity, AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MaybePromise, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
|
|
14
14
|
import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
|
|
15
15
|
import type { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
16
16
|
import type { Transaction } from './connections/Connection.js';
|
|
@@ -27,12 +27,15 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
27
27
|
protected readonly metadata: MetadataStorage;
|
|
28
28
|
protected readonly useContext: boolean;
|
|
29
29
|
protected readonly eventManager: EventManager;
|
|
30
|
+
/** @internal */
|
|
31
|
+
readonly '~entities'?: unknown;
|
|
30
32
|
private static counter;
|
|
31
33
|
readonly _id: number;
|
|
32
34
|
readonly global = false;
|
|
33
35
|
readonly name: string;
|
|
34
36
|
protected readonly refLoader: DataLoader<[Reference<any>, (Omit<import("./entity/Reference.js").LoadReferenceOptions<any, any, "*", never>, "dataloader"> | undefined)?], any, [Reference<any>, (Omit<import("./entity/Reference.js").LoadReferenceOptions<any, any, "*", never>, "dataloader"> | undefined)?]>;
|
|
35
37
|
protected readonly colLoader: DataLoader<[import("./index.js").Collection<any, object>, (Omit<import("./index.js").InitCollectionOptions<any, any, "*", never>, "dataloader"> | undefined)?], any, [import("./index.js").Collection<any, object>, (Omit<import("./index.js").InitCollectionOptions<any, any, "*", never>, "dataloader"> | undefined)?]>;
|
|
38
|
+
protected readonly colLoaderMtoN: DataLoader<[import("./index.js").Collection<any, object>, (Omit<import("./index.js").InitCollectionOptions<any, any, "*", never>, "dataloader"> | undefined)?], any, [import("./index.js").Collection<any, object>, (Omit<import("./index.js").InitCollectionOptions<any, any, "*", never>, "dataloader"> | undefined)?]>;
|
|
36
39
|
private readonly validator;
|
|
37
40
|
private readonly repositoryMap;
|
|
38
41
|
private readonly entityLoader;
|
|
@@ -80,6 +83,24 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
80
83
|
* Finds all entities matching your `where` query. You can pass additional options via the `options` parameter.
|
|
81
84
|
*/
|
|
82
85
|
find<Entity extends object, Hint extends string = never, Fields extends string = PopulatePath.ALL, Excludes extends string = never>(entityName: EntityName<Entity>, where: FilterQuery<NoInfer<Entity>>, options?: FindOptions<Entity, Hint, Fields, Excludes>): Promise<Loaded<Entity, Hint, Fields, Excludes>[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Finds all entities and returns an async iterable (async generator) that yields results one by one.
|
|
88
|
+
* The results are merged and mapped to entity instances, without adding them to the identity map.
|
|
89
|
+
* You can disable merging by passing the options `{ mergeResults: false }`.
|
|
90
|
+
* With `mergeResults` disabled, to-many collections will contain at most one item, and you will get duplicate
|
|
91
|
+
* root entities when there are multiple items in the populated collection.
|
|
92
|
+
* This is useful for processing large datasets without loading everything into memory at once.
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const stream = em.stream(Book, { populate: ['author'] });
|
|
96
|
+
*
|
|
97
|
+
* for await (const book of stream) {
|
|
98
|
+
* // book is an instance of Book entity
|
|
99
|
+
* console.log(book.title, book.author.name);
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
stream<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entityName: EntityName<Entity>, options?: StreamOptions<NoInfer<Entity>, Hint, Fields, Excludes>): AsyncIterableIterator<Loaded<Entity, Hint, Fields, Excludes>>;
|
|
83
104
|
/**
|
|
84
105
|
* Finds all entities of given type, optionally matching the `where` condition provided in the `options` parameter.
|
|
85
106
|
*/
|
|
@@ -88,19 +109,19 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
88
109
|
/**
|
|
89
110
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
90
111
|
*/
|
|
91
|
-
addFilter<T1>(name: string, cond: FilterQuery<T1> | ((args: Dictionary) => MaybePromise<FilterQuery<T1>>), entityName?: EntityName<T1> | [EntityName<T1>],
|
|
112
|
+
addFilter<T1>(name: string, cond: FilterQuery<T1> | ((args: Dictionary) => MaybePromise<FilterQuery<T1>>), entityName?: EntityName<T1> | [EntityName<T1>], options?: boolean | Partial<FilterDef>): void;
|
|
92
113
|
/**
|
|
93
114
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
94
115
|
*/
|
|
95
|
-
addFilter<T1, T2>(name: string, cond: FilterQuery<T1 | T2> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2>>), entityName?: [EntityName<T1>, EntityName<T2>],
|
|
116
|
+
addFilter<T1, T2>(name: string, cond: FilterQuery<T1 | T2> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2>>), entityName?: [EntityName<T1>, EntityName<T2>], options?: boolean | Partial<FilterDef>): void;
|
|
96
117
|
/**
|
|
97
118
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
98
119
|
*/
|
|
99
|
-
addFilter<T1, T2, T3>(name: string, cond: FilterQuery<T1 | T2 | T3> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2 | T3>>), entityName?: [EntityName<T1>, EntityName<T2>, EntityName<T3>],
|
|
120
|
+
addFilter<T1, T2, T3>(name: string, cond: FilterQuery<T1 | T2 | T3> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2 | T3>>), entityName?: [EntityName<T1>, EntityName<T2>, EntityName<T3>], options?: boolean | Partial<FilterDef>): void;
|
|
100
121
|
/**
|
|
101
122
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
102
123
|
*/
|
|
103
|
-
addFilter(name: string, cond: Dictionary | ((args: Dictionary) => MaybePromise<FilterQuery<AnyEntity>>), entityName?: EntityName<AnyEntity> | EntityName<AnyEntity>[],
|
|
124
|
+
addFilter(name: string, cond: Dictionary | ((args: Dictionary) => MaybePromise<FilterQuery<AnyEntity>>), entityName?: EntityName<AnyEntity> | EntityName<AnyEntity>[], options?: boolean | Partial<FilterDef>): void;
|
|
104
125
|
/**
|
|
105
126
|
* Sets filter parameter values globally inside context defined by this entity manager.
|
|
106
127
|
* If you want to set shared value for all contexts, be sure to use the root entity manager.
|
|
@@ -117,20 +138,25 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
117
138
|
/**
|
|
118
139
|
* Gets logger context for this entity manager.
|
|
119
140
|
*/
|
|
120
|
-
getLoggerContext<T extends Dictionary = Dictionary>(
|
|
141
|
+
getLoggerContext<T extends Dictionary = Dictionary>(options?: {
|
|
142
|
+
disableContextResolution?: boolean;
|
|
143
|
+
}): T;
|
|
121
144
|
setFlushMode(flushMode?: FlushMode): void;
|
|
122
145
|
protected processWhere<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entityName: string, where: FilterQuery<Entity>, options: FindOptions<Entity, Hint, Fields, Excludes> | FindOneOptions<Entity, Hint, Fields, Excludes>, type: 'read' | 'update' | 'delete'): Promise<FilterQuery<Entity>>;
|
|
123
146
|
protected applyDiscriminatorCondition<Entity extends object>(entityName: string, where: FilterQuery<Entity>): FilterQuery<Entity>;
|
|
124
147
|
protected createPopulateWhere<Entity extends object>(cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any> | CountOptions<Entity, any>): ObjectQuery<Entity>;
|
|
125
|
-
protected getJoinedFilters<Entity extends object>(meta: EntityMetadata<Entity>,
|
|
148
|
+
protected getJoinedFilters<Entity extends object>(meta: EntityMetadata<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any>): Promise<ObjectQuery<Entity> | undefined>;
|
|
126
149
|
/**
|
|
127
150
|
* When filters are active on M:1 or 1:1 relations, we need to ref join them eagerly as they might affect the FK value.
|
|
128
151
|
*/
|
|
129
|
-
protected autoJoinRefsForFilters<T extends object>(meta: EntityMetadata<T>, options: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any
|
|
152
|
+
protected autoJoinRefsForFilters<T extends object>(meta: EntityMetadata<T>, options: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, parent?: {
|
|
153
|
+
className: string;
|
|
154
|
+
propName: string;
|
|
155
|
+
}): Promise<void>;
|
|
130
156
|
/**
|
|
131
157
|
* @internal
|
|
132
158
|
*/
|
|
133
|
-
applyFilters<Entity extends object>(entityName: string, where: FilterQuery<Entity> | undefined, options:
|
|
159
|
+
applyFilters<Entity extends object>(entityName: string, where: FilterQuery<Entity> | undefined, options: FilterOptions | undefined, type: 'read' | 'update' | 'delete', findOptions?: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>): Promise<FilterQuery<Entity> | undefined>;
|
|
134
160
|
/**
|
|
135
161
|
* Calls `em.find()` and `em.count()` with the same arguments (where applicable) and returns the results as tuple
|
|
136
162
|
* where the first element is the array of entities, and the second is the count.
|
|
@@ -171,6 +197,10 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
171
197
|
* });
|
|
172
198
|
* ```
|
|
173
199
|
*
|
|
200
|
+
* The options also support an `includeCount` (true by default) option. If set to false, the `totalCount` is not
|
|
201
|
+
* returned as part of the cursor. This is useful for performance reason, when you don't care about the total number
|
|
202
|
+
* of pages.
|
|
203
|
+
*
|
|
174
204
|
* The `Cursor` object provides the following interface:
|
|
175
205
|
*
|
|
176
206
|
* ```ts
|
|
@@ -180,7 +210,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
180
210
|
* User { ... },
|
|
181
211
|
* User { ... },
|
|
182
212
|
* ],
|
|
183
|
-
* totalCount: 50,
|
|
213
|
+
* totalCount: 50, // not included if `includeCount: false`
|
|
184
214
|
* startCursor: 'WzRd',
|
|
185
215
|
* endCursor: 'WzZd',
|
|
186
216
|
* hasPrevPage: true,
|
|
@@ -188,7 +218,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
188
218
|
* }
|
|
189
219
|
* ```
|
|
190
220
|
*/
|
|
191
|
-
findByCursor<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entityName: EntityName<Entity>, where: FilterQuery<NoInfer<Entity>>, options: FindByCursorOptions<Entity, Hint, Fields, Excludes>): Promise<Cursor<Entity, Hint, Fields, Excludes>>;
|
|
221
|
+
findByCursor<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never, IncludeCount extends boolean = true>(entityName: EntityName<Entity>, where: FilterQuery<NoInfer<Entity>>, options: FindByCursorOptions<Entity, Hint, Fields, Excludes, IncludeCount>): Promise<Cursor<Entity, Hint, Fields, Excludes, IncludeCount>>;
|
|
192
222
|
/**
|
|
193
223
|
* Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been
|
|
194
224
|
* persisted. Returns the same entity instance (same object reference), but re-hydrated. If the entity is no longer
|
|
@@ -263,6 +293,29 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
263
293
|
upsertMany<Entity extends object, Fields extends string = any>(entityNameOrEntity: EntityName<Entity> | Entity[], data?: (EntityData<Entity> | NoInfer<Entity>)[], options?: UpsertManyOptions<Entity, Fields>): Promise<Entity[]>;
|
|
264
294
|
/**
|
|
265
295
|
* Runs your callback wrapped inside a database transaction.
|
|
296
|
+
*
|
|
297
|
+
* If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
|
|
298
|
+
* can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
|
|
299
|
+
* should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
|
|
300
|
+
* method automatically creates an async context for the transaction.
|
|
301
|
+
*
|
|
302
|
+
* **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
|
|
303
|
+
* `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
|
|
304
|
+
* between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
|
|
305
|
+
* the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
|
|
306
|
+
*
|
|
307
|
+
* **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
|
|
308
|
+
* parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
|
|
309
|
+
* and then call this method on the fork.
|
|
310
|
+
*
|
|
311
|
+
* **Example:**
|
|
312
|
+
* ```ts
|
|
313
|
+
* await em.transactional(async (em) => {
|
|
314
|
+
* const author = new Author('Jon');
|
|
315
|
+
* em.persist(author);
|
|
316
|
+
* // flush is called automatically at the end of the callback
|
|
317
|
+
* });
|
|
318
|
+
* ```
|
|
266
319
|
*/
|
|
267
320
|
transactional<T>(cb: (em: this) => T | Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
268
321
|
/**
|
|
@@ -419,7 +472,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
419
472
|
/**
|
|
420
473
|
* Loads specified relations in batch. This will execute one query for each relation, that will populate it on all the specified entities.
|
|
421
474
|
*/
|
|
422
|
-
populate<Entity extends object, Naked extends FromEntityType<UnboxArray<Entity>> = FromEntityType<UnboxArray<Entity>>, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entities: Entity, populate: AutoPath<Naked, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Naked, Fields, Excludes>): Promise<Entity extends object[] ? MergeLoaded<ArrayElement<Entity>, Naked, Hint, Fields, Excludes>[] : MergeLoaded<Entity, Naked, Hint, Fields, Excludes>>;
|
|
475
|
+
populate<Entity extends object, Naked extends FromEntityType<UnboxArray<Entity>> = FromEntityType<UnboxArray<Entity>>, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entities: Entity, populate: readonly AutoPath<Naked, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Naked, Fields, Excludes>): Promise<Entity extends object[] ? MergeLoaded<ArrayElement<Entity>, Naked, Hint, Fields, Excludes>[] : MergeLoaded<Entity, Naked, Hint, Fields, Excludes>>;
|
|
423
476
|
/**
|
|
424
477
|
* Returns new EntityManager instance with its own identity map
|
|
425
478
|
*/
|
|
@@ -432,6 +485,10 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
432
485
|
* Gets the EntityFactory used by the EntityManager.
|
|
433
486
|
*/
|
|
434
487
|
getEntityFactory(): EntityFactory;
|
|
488
|
+
/**
|
|
489
|
+
* @internal use `em.populate()` as the user facing API, this is exposed only for internal usage
|
|
490
|
+
*/
|
|
491
|
+
getEntityLoader(): EntityLoader;
|
|
435
492
|
/**
|
|
436
493
|
* Gets the Hydrator used by the EntityManager.
|
|
437
494
|
*/
|
|
@@ -479,7 +536,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
479
536
|
* some additional lazy properties, if so, we reload and merge the data from database
|
|
480
537
|
*/
|
|
481
538
|
protected shouldRefresh<T extends object, P extends string = never, F extends string = '*', E extends string = never>(meta: EntityMetadata<T>, entity: T, options: FindOneOptions<T, P, F, E>): boolean;
|
|
482
|
-
protected prepareOptions(options: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>): void;
|
|
539
|
+
protected prepareOptions(options: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any> | CountOptions<any, any>): void;
|
|
483
540
|
/**
|
|
484
541
|
* @internal
|
|
485
542
|
*/
|
|
@@ -488,15 +545,15 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
488
545
|
* @internal
|
|
489
546
|
*/
|
|
490
547
|
tryCache<T extends object, R>(entityName: string, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean): Promise<{
|
|
491
|
-
data?: R;
|
|
548
|
+
data?: R | null;
|
|
492
549
|
key: string;
|
|
493
550
|
} | undefined>;
|
|
494
551
|
/**
|
|
495
552
|
* @internal
|
|
496
553
|
*/
|
|
497
|
-
storeCache(config: boolean | number | [string, number] | undefined, key: {
|
|
554
|
+
storeCache<T>(config: boolean | number | [string, number] | undefined, key: {
|
|
498
555
|
key: string;
|
|
499
|
-
}, data:
|
|
556
|
+
}, data: T | (() => T)): Promise<void>;
|
|
500
557
|
/**
|
|
501
558
|
* Clears result cache for given cache key. If we want to be able to call this method,
|
|
502
559
|
* we need to set the cache key explicitly when storing the cache.
|
|
@@ -539,11 +596,20 @@ export interface CreateOptions<Convert extends boolean> {
|
|
|
539
596
|
partial?: boolean;
|
|
540
597
|
/** convert raw database values based on mapped types (by default, already converted values are expected) */
|
|
541
598
|
convertCustomTypes?: Convert;
|
|
599
|
+
/**
|
|
600
|
+
* Property `onCreate` hooks are normally executed during `flush` operation.
|
|
601
|
+
* With this option, they will be processed early inside `em.create()` method.
|
|
602
|
+
*/
|
|
603
|
+
processOnCreateHooksEarly?: boolean;
|
|
542
604
|
}
|
|
543
605
|
export interface MergeOptions {
|
|
544
606
|
refresh?: boolean;
|
|
545
607
|
convertCustomTypes?: boolean;
|
|
546
608
|
schema?: string;
|
|
609
|
+
disableContextResolution?: boolean;
|
|
610
|
+
keepIdentity?: boolean;
|
|
611
|
+
validate?: boolean;
|
|
612
|
+
cascade?: boolean; /** @default true */
|
|
547
613
|
}
|
|
548
614
|
export interface ForkOptions {
|
|
549
615
|
/** do we want a clear identity map? defaults to true */
|