@mikro-orm/core 7.0.0-dev.6 → 7.0.0-dev.61

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.
Files changed (123) hide show
  1. package/EntityManager.d.ts +85 -32
  2. package/EntityManager.js +281 -178
  3. package/MikroORM.d.ts +8 -8
  4. package/MikroORM.js +31 -74
  5. package/README.md +3 -2
  6. package/cache/FileCacheAdapter.d.ts +2 -1
  7. package/cache/FileCacheAdapter.js +5 -4
  8. package/connections/Connection.d.ts +11 -7
  9. package/connections/Connection.js +16 -13
  10. package/decorators/Embeddable.d.ts +2 -0
  11. package/decorators/Embedded.d.ts +5 -11
  12. package/decorators/Entity.d.ts +20 -3
  13. package/decorators/Indexed.d.ts +2 -2
  14. package/decorators/ManyToMany.d.ts +2 -0
  15. package/decorators/ManyToOne.d.ts +4 -0
  16. package/decorators/OneToOne.d.ts +4 -0
  17. package/decorators/Property.d.ts +53 -9
  18. package/decorators/Transactional.d.ts +3 -1
  19. package/decorators/Transactional.js +6 -3
  20. package/decorators/index.d.ts +1 -1
  21. package/drivers/DatabaseDriver.d.ts +11 -5
  22. package/drivers/DatabaseDriver.js +13 -4
  23. package/drivers/IDatabaseDriver.d.ts +29 -5
  24. package/entity/ArrayCollection.d.ts +6 -4
  25. package/entity/ArrayCollection.js +27 -12
  26. package/entity/BaseEntity.d.ts +0 -1
  27. package/entity/BaseEntity.js +0 -3
  28. package/entity/Collection.d.ts +3 -4
  29. package/entity/Collection.js +34 -17
  30. package/entity/EntityAssigner.d.ts +1 -1
  31. package/entity/EntityAssigner.js +9 -1
  32. package/entity/EntityFactory.d.ts +7 -0
  33. package/entity/EntityFactory.js +63 -40
  34. package/entity/EntityHelper.js +26 -9
  35. package/entity/EntityLoader.d.ts +5 -4
  36. package/entity/EntityLoader.js +69 -36
  37. package/entity/EntityRepository.d.ts +1 -1
  38. package/entity/EntityValidator.js +2 -2
  39. package/entity/Reference.d.ts +9 -7
  40. package/entity/Reference.js +32 -5
  41. package/entity/WrappedEntity.d.ts +0 -2
  42. package/entity/WrappedEntity.js +1 -5
  43. package/entity/defineEntity.d.ts +555 -0
  44. package/entity/defineEntity.js +529 -0
  45. package/entity/index.d.ts +2 -0
  46. package/entity/index.js +2 -0
  47. package/entity/utils.d.ts +7 -0
  48. package/entity/utils.js +15 -3
  49. package/enums.d.ts +18 -5
  50. package/enums.js +13 -0
  51. package/errors.d.ts +6 -1
  52. package/errors.js +14 -4
  53. package/events/EventSubscriber.d.ts +3 -1
  54. package/hydration/ObjectHydrator.d.ts +4 -4
  55. package/hydration/ObjectHydrator.js +35 -24
  56. package/index.d.ts +2 -1
  57. package/index.js +1 -1
  58. package/logging/DefaultLogger.d.ts +1 -1
  59. package/logging/SimpleLogger.d.ts +1 -1
  60. package/metadata/EntitySchema.d.ts +8 -4
  61. package/metadata/EntitySchema.js +41 -23
  62. package/metadata/MetadataDiscovery.d.ts +5 -7
  63. package/metadata/MetadataDiscovery.js +151 -159
  64. package/metadata/MetadataStorage.js +1 -1
  65. package/metadata/MetadataValidator.js +4 -3
  66. package/metadata/discover-entities.d.ts +5 -0
  67. package/metadata/discover-entities.js +39 -0
  68. package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
  69. package/naming-strategy/AbstractNamingStrategy.js +7 -1
  70. package/naming-strategy/NamingStrategy.d.ts +11 -1
  71. package/package.json +14 -8
  72. package/platforms/Platform.d.ts +5 -8
  73. package/platforms/Platform.js +4 -17
  74. package/serialization/EntitySerializer.d.ts +2 -0
  75. package/serialization/EntitySerializer.js +29 -11
  76. package/serialization/EntityTransformer.js +22 -12
  77. package/serialization/SerializationContext.js +14 -11
  78. package/types/BigIntType.d.ts +9 -6
  79. package/types/BigIntType.js +3 -0
  80. package/types/BlobType.d.ts +0 -1
  81. package/types/BlobType.js +0 -3
  82. package/types/BooleanType.d.ts +2 -1
  83. package/types/BooleanType.js +3 -0
  84. package/types/DecimalType.d.ts +6 -4
  85. package/types/DecimalType.js +1 -1
  86. package/types/DoubleType.js +1 -1
  87. package/types/JsonType.d.ts +1 -1
  88. package/types/JsonType.js +7 -2
  89. package/types/Type.d.ts +2 -1
  90. package/types/Type.js +1 -1
  91. package/types/Uint8ArrayType.d.ts +0 -1
  92. package/types/Uint8ArrayType.js +0 -3
  93. package/types/index.d.ts +1 -1
  94. package/typings.d.ts +95 -52
  95. package/typings.js +31 -31
  96. package/unit-of-work/ChangeSetComputer.js +8 -3
  97. package/unit-of-work/ChangeSetPersister.d.ts +4 -2
  98. package/unit-of-work/ChangeSetPersister.js +37 -16
  99. package/unit-of-work/UnitOfWork.d.ts +8 -1
  100. package/unit-of-work/UnitOfWork.js +110 -53
  101. package/utils/AbstractSchemaGenerator.js +3 -1
  102. package/utils/Configuration.d.ts +201 -184
  103. package/utils/Configuration.js +143 -151
  104. package/utils/ConfigurationLoader.d.ts +9 -22
  105. package/utils/ConfigurationLoader.js +53 -76
  106. package/utils/Cursor.d.ts +3 -3
  107. package/utils/Cursor.js +3 -0
  108. package/utils/DataloaderUtils.d.ts +15 -5
  109. package/utils/DataloaderUtils.js +53 -7
  110. package/utils/EntityComparator.d.ts +8 -4
  111. package/utils/EntityComparator.js +105 -58
  112. package/utils/QueryHelper.d.ts +9 -1
  113. package/utils/QueryHelper.js +66 -5
  114. package/utils/RawQueryFragment.d.ts +36 -4
  115. package/utils/RawQueryFragment.js +34 -13
  116. package/utils/TransactionManager.d.ts +65 -0
  117. package/utils/TransactionManager.js +223 -0
  118. package/utils/Utils.d.ts +16 -31
  119. package/utils/Utils.js +129 -107
  120. package/utils/index.d.ts +1 -0
  121. package/utils/index.js +1 -0
  122. package/utils/upsert-utils.d.ts +7 -2
  123. package/utils/upsert-utils.js +52 -1
@@ -1,16 +1,15 @@
1
1
  import { inspect } from 'node:util';
2
- import DataLoader from 'dataloader';
3
2
  import { type Configuration } from './utils/Configuration.js';
4
3
  import { Cursor } from './utils/Cursor.js';
5
4
  import { EntityFactory } from './entity/EntityFactory.js';
6
5
  import { type AssignOptions } from './entity/EntityAssigner.js';
7
6
  import { EntityValidator } from './entity/EntityValidator.js';
8
7
  import { type EntityRepository } from './entity/EntityRepository.js';
9
- import { type EntityLoaderOptions } from './entity/EntityLoader.js';
8
+ import { EntityLoader, type EntityLoaderOptions } from './entity/EntityLoader.js';
10
9
  import { Reference } from './entity/Reference.js';
11
10
  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';
11
+ import type { CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, StreamOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
12
+ import type { AnyEntity, AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
14
13
  import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
15
14
  import type { MetadataStorage } from './metadata/MetadataStorage.js';
16
15
  import type { Transaction } from './connections/Connection.js';
@@ -27,12 +26,13 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
27
26
  protected readonly metadata: MetadataStorage;
28
27
  protected readonly useContext: boolean;
29
28
  protected readonly eventManager: EventManager;
29
+ /** @internal */
30
+ readonly '~entities'?: unknown;
30
31
  private static counter;
31
32
  readonly _id: number;
32
33
  readonly global = false;
33
34
  readonly name: string;
34
- 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
- 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)?]>;
35
+ private readonly loaders;
36
36
  private readonly validator;
37
37
  private readonly repositoryMap;
38
38
  private readonly entityLoader;
@@ -80,6 +80,24 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
80
80
  * Finds all entities matching your `where` query. You can pass additional options via the `options` parameter.
81
81
  */
82
82
  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>[]>;
83
+ /**
84
+ * Finds all entities and returns an async iterable (async generator) that yields results one by one.
85
+ * The results are merged and mapped to entity instances, without adding them to the identity map.
86
+ * You can disable merging by passing the options `{ mergeResults: false }`.
87
+ * With `mergeResults` disabled, to-many collections will contain at most one item, and you will get duplicate
88
+ * root entities when there are multiple items in the populated collection.
89
+ * This is useful for processing large datasets without loading everything into memory at once.
90
+ *
91
+ * ```ts
92
+ * const stream = em.stream(Book, { populate: ['author'] });
93
+ *
94
+ * for await (const book of stream) {
95
+ * // book is an instance of Book entity
96
+ * console.log(book.title, book.author.name);
97
+ * }
98
+ * ```
99
+ */
100
+ 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
101
  /**
84
102
  * Finds all entities of given type, optionally matching the `where` condition provided in the `options` parameter.
85
103
  */
@@ -88,19 +106,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
88
106
  /**
89
107
  * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
90
108
  */
91
- addFilter<T1>(name: string, cond: FilterQuery<T1> | ((args: Dictionary) => MaybePromise<FilterQuery<T1>>), entityName?: EntityName<T1> | [EntityName<T1>], enabled?: boolean): void;
92
- /**
93
- * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
94
- */
95
- addFilter<T1, T2>(name: string, cond: FilterQuery<T1 | T2> | ((args: Dictionary) => MaybePromise<FilterQuery<T1 | T2>>), entityName?: [EntityName<T1>, EntityName<T2>], enabled?: boolean): void;
96
- /**
97
- * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
98
- */
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>], enabled?: boolean): void;
100
- /**
101
- * Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
102
- */
103
- addFilter(name: string, cond: Dictionary | ((args: Dictionary) => MaybePromise<FilterQuery<AnyEntity>>), entityName?: EntityName<AnyEntity> | EntityName<AnyEntity>[], enabled?: boolean): void;
109
+ addFilter<T extends EntityName<any> | readonly EntityName<any>[]>(options: FilterDef<T>): void;
104
110
  /**
105
111
  * Sets filter parameter values globally inside context defined by this entity manager.
106
112
  * If you want to set shared value for all contexts, be sure to use the root entity manager.
@@ -117,20 +123,25 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
117
123
  /**
118
124
  * Gets logger context for this entity manager.
119
125
  */
120
- getLoggerContext<T extends Dictionary = Dictionary>(): T;
121
- setFlushMode(flushMode?: FlushMode): void;
126
+ getLoggerContext<T extends Dictionary = Dictionary>(options?: {
127
+ disableContextResolution?: boolean;
128
+ }): T;
129
+ setFlushMode(flushMode?: FlushMode | `${FlushMode}`): void;
122
130
  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
131
  protected applyDiscriminatorCondition<Entity extends object>(entityName: string, where: FilterQuery<Entity>): FilterQuery<Entity>;
124
132
  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>, cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any>): Promise<ObjectQuery<Entity>>;
133
+ protected getJoinedFilters<Entity extends object>(meta: EntityMetadata<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any>): Promise<ObjectQuery<Entity> | undefined>;
126
134
  /**
127
135
  * 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
136
  */
129
- protected autoJoinRefsForFilters<T extends object>(meta: EntityMetadata<T>, options: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>): Promise<void>;
137
+ protected autoJoinRefsForFilters<T extends object>(meta: EntityMetadata<T>, options: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, parent?: {
138
+ className: string;
139
+ propName: string;
140
+ }): Promise<void>;
130
141
  /**
131
142
  * @internal
132
143
  */
133
- applyFilters<Entity extends object>(entityName: string, where: FilterQuery<Entity> | undefined, options: Dictionary<boolean | Dictionary> | string[] | boolean, type: 'read' | 'update' | 'delete', findOptions?: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>): Promise<FilterQuery<Entity> | undefined>;
144
+ 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
145
  /**
135
146
  * Calls `em.find()` and `em.count()` with the same arguments (where applicable) and returns the results as tuple
136
147
  * where the first element is the array of entities, and the second is the count.
@@ -171,6 +182,10 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
171
182
  * });
172
183
  * ```
173
184
  *
185
+ * The options also support an `includeCount` (true by default) option. If set to false, the `totalCount` is not
186
+ * returned as part of the cursor. This is useful for performance reason, when you don't care about the total number
187
+ * of pages.
188
+ *
174
189
  * The `Cursor` object provides the following interface:
175
190
  *
176
191
  * ```ts
@@ -180,7 +195,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
180
195
  * User { ... },
181
196
  * User { ... },
182
197
  * ],
183
- * totalCount: 50,
198
+ * totalCount: 50, // not included if `includeCount: false`
184
199
  * startCursor: 'WzRd',
185
200
  * endCursor: 'WzZd',
186
201
  * hasPrevPage: true,
@@ -188,7 +203,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
188
203
  * }
189
204
  * ```
190
205
  */
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>>;
206
+ 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
207
  /**
193
208
  * Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been
194
209
  * persisted. Returns the same entity instance (same object reference), but re-hydrated. If the entity is no longer
@@ -263,6 +278,29 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
263
278
  upsertMany<Entity extends object, Fields extends string = any>(entityNameOrEntity: EntityName<Entity> | Entity[], data?: (EntityData<Entity> | NoInfer<Entity>)[], options?: UpsertManyOptions<Entity, Fields>): Promise<Entity[]>;
264
279
  /**
265
280
  * Runs your callback wrapped inside a database transaction.
281
+ *
282
+ * If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
283
+ * can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
284
+ * should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
285
+ * method automatically creates an async context for the transaction.
286
+ *
287
+ * **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
288
+ * `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
289
+ * between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
290
+ * the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
291
+ *
292
+ * **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
293
+ * parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
294
+ * and then call this method on the fork.
295
+ *
296
+ * **Example:**
297
+ * ```ts
298
+ * await em.transactional(async (em) => {
299
+ * const author = new Author('Jon');
300
+ * em.persist(author);
301
+ * // flush is called automatically at the end of the callback
302
+ * });
303
+ * ```
266
304
  */
267
305
  transactional<T>(cb: (em: this) => T | Promise<T>, options?: TransactionOptions): Promise<T>;
268
306
  /**
@@ -419,7 +457,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
419
457
  /**
420
458
  * Loads specified relations in batch. This will execute one query for each relation, that will populate it on all the specified entities.
421
459
  */
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>>;
460
+ 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
461
  /**
424
462
  * Returns new EntityManager instance with its own identity map
425
463
  */
@@ -432,6 +470,10 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
432
470
  * Gets the EntityFactory used by the EntityManager.
433
471
  */
434
472
  getEntityFactory(): EntityFactory;
473
+ /**
474
+ * @internal use `em.populate()` as the user facing API, this is exposed only for internal usage
475
+ */
476
+ getEntityLoader(): EntityLoader;
435
477
  /**
436
478
  * Gets the Hydrator used by the EntityManager.
437
479
  */
@@ -479,7 +521,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
479
521
  * some additional lazy properties, if so, we reload and merge the data from database
480
522
  */
481
523
  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;
524
+ protected prepareOptions(options: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any> | CountOptions<any, any>): void;
483
525
  /**
484
526
  * @internal
485
527
  */
@@ -488,15 +530,15 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
488
530
  * @internal
489
531
  */
490
532
  tryCache<T extends object, R>(entityName: string, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean): Promise<{
491
- data?: R;
533
+ data?: R | null;
492
534
  key: string;
493
535
  } | undefined>;
494
536
  /**
495
537
  * @internal
496
538
  */
497
- storeCache(config: boolean | number | [string, number] | undefined, key: {
539
+ storeCache<T>(config: boolean | number | [string, number] | undefined, key: {
498
540
  key: string;
499
- }, data: unknown | (() => unknown)): Promise<void>;
541
+ }, data: T | (() => T)): Promise<void>;
500
542
  /**
501
543
  * Clears result cache for given cache key. If we want to be able to call this method,
502
544
  * we need to set the cache key explicitly when storing the cache.
@@ -520,6 +562,8 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
520
562
  * if executed inside request context handler.
521
563
  */
522
564
  set schema(schema: string | null | undefined);
565
+ /** @internal */
566
+ getDataLoader(type: 'ref' | '1:m' | 'm:n'): Promise<any>;
523
567
  /**
524
568
  * Returns the ID of this EntityManager. Respects the context, so global EM will give you the contextual ID
525
569
  * if executed inside request context handler.
@@ -539,11 +583,20 @@ export interface CreateOptions<Convert extends boolean> {
539
583
  partial?: boolean;
540
584
  /** convert raw database values based on mapped types (by default, already converted values are expected) */
541
585
  convertCustomTypes?: Convert;
586
+ /**
587
+ * Property `onCreate` hooks are normally executed during `flush` operation.
588
+ * With this option, they will be processed early inside `em.create()` method.
589
+ */
590
+ processOnCreateHooksEarly?: boolean;
542
591
  }
543
592
  export interface MergeOptions {
544
593
  refresh?: boolean;
545
594
  convertCustomTypes?: boolean;
546
595
  schema?: string;
596
+ disableContextResolution?: boolean;
597
+ keepIdentity?: boolean;
598
+ validate?: boolean;
599
+ cascade?: boolean; /** @default true */
547
600
  }
548
601
  export interface ForkOptions {
549
602
  /** do we want a clear identity map? defaults to true */
@@ -557,7 +610,7 @@ export interface ForkOptions {
557
610
  /** use this flag to ignore the current async context - this is required if we want to call `em.fork()` inside the `getContext` handler */
558
611
  disableContextResolution?: boolean;
559
612
  /** set flush mode for this fork, overrides the global option can be overridden locally via FindOptions */
560
- flushMode?: FlushMode;
613
+ flushMode?: FlushMode | `${FlushMode}`;
561
614
  /** disable transactions for this fork */
562
615
  disableTransactions?: boolean;
563
616
  /** should we keep the transaction context of the parent EM? */