@mikro-orm/core 7.0.0-dev.9 → 7.0.0-dev.90
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 +77 -48
- package/EntityManager.js +288 -225
- package/MikroORM.d.ts +40 -31
- package/MikroORM.js +98 -137
- package/README.md +3 -2
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +6 -5
- package/cache/GeneratedCacheAdapter.d.ts +0 -1
- package/cache/GeneratedCacheAdapter.js +0 -2
- package/cache/index.d.ts +0 -1
- package/cache/index.js +0 -1
- package/connections/Connection.d.ts +11 -7
- package/connections/Connection.js +16 -14
- package/drivers/DatabaseDriver.d.ts +11 -5
- package/drivers/DatabaseDriver.js +23 -11
- package/drivers/IDatabaseDriver.d.ts +25 -4
- package/entity/BaseEntity.d.ts +0 -1
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +95 -30
- package/entity/Collection.js +432 -93
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +17 -9
- package/entity/EntityFactory.d.ts +7 -0
- package/entity/EntityFactory.js +63 -41
- package/entity/EntityHelper.js +26 -12
- package/entity/EntityLoader.d.ts +5 -4
- package/entity/EntityLoader.js +63 -38
- package/entity/EntityRepository.d.ts +1 -1
- package/entity/Reference.d.ts +6 -5
- package/entity/Reference.js +34 -9
- package/entity/WrappedEntity.d.ts +2 -7
- package/entity/WrappedEntity.js +2 -7
- package/entity/defineEntity.d.ts +568 -0
- package/entity/defineEntity.js +529 -0
- package/entity/index.d.ts +3 -2
- package/entity/index.js +3 -2
- package/entity/utils.d.ts +7 -0
- package/entity/utils.js +16 -4
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/enums.d.ts +21 -6
- package/enums.js +14 -1
- package/errors.d.ts +10 -2
- package/errors.js +29 -10
- package/events/EventManager.d.ts +2 -1
- package/events/EventManager.js +19 -11
- package/events/EventSubscriber.d.ts +3 -1
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +35 -25
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +1 -0
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/index.d.ts +1 -0
- package/logging/index.js +1 -0
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +16 -0
- package/metadata/EntitySchema.d.ts +9 -13
- package/metadata/EntitySchema.js +44 -26
- package/metadata/MetadataDiscovery.d.ts +6 -9
- package/metadata/MetadataDiscovery.js +165 -205
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +44 -2
- package/metadata/MetadataStorage.d.ts +1 -6
- package/metadata/MetadataStorage.js +6 -18
- package/metadata/MetadataValidator.d.ts +0 -7
- package/metadata/MetadataValidator.js +0 -10
- 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 +1 -1
- package/metadata/types.d.ts +480 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
- package/naming-strategy/AbstractNamingStrategy.js +8 -2
- package/naming-strategy/NamingStrategy.d.ts +11 -1
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +18 -10
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +6 -13
- package/platforms/Platform.js +15 -41
- package/serialization/EntitySerializer.d.ts +2 -0
- package/serialization/EntitySerializer.js +32 -14
- package/serialization/EntityTransformer.js +22 -12
- package/serialization/SerializationContext.js +16 -13
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.d.ts +8 -6
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +2 -1
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.d.ts +6 -4
- package/types/DecimalType.js +3 -3
- package/types/DoubleType.js +2 -2
- 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/index.d.ts +1 -1
- package/typings.d.ts +109 -73
- package/typings.js +38 -35
- package/unit-of-work/ChangeSet.d.ts +0 -3
- package/unit-of-work/ChangeSet.js +2 -2
- package/unit-of-work/ChangeSetComputer.d.ts +1 -3
- package/unit-of-work/ChangeSetComputer.js +11 -9
- package/unit-of-work/ChangeSetPersister.d.ts +5 -4
- package/unit-of-work/ChangeSetPersister.js +51 -19
- package/unit-of-work/UnitOfWork.d.ts +8 -1
- package/unit-of-work/UnitOfWork.js +91 -49
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +11 -9
- package/utils/Configuration.d.ts +757 -206
- package/utils/Configuration.js +140 -188
- package/utils/ConfigurationLoader.d.ts +1 -54
- package/utils/ConfigurationLoader.js +1 -352
- package/utils/Cursor.d.ts +0 -3
- package/utils/Cursor.js +6 -3
- package/utils/DataloaderUtils.d.ts +15 -5
- package/utils/DataloaderUtils.js +54 -8
- package/utils/EntityComparator.d.ts +8 -4
- package/utils/EntityComparator.js +52 -17
- package/utils/QueryHelper.d.ts +9 -1
- package/utils/QueryHelper.js +70 -9
- package/utils/RawQueryFragment.d.ts +36 -13
- package/utils/RawQueryFragment.js +36 -16
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +223 -0
- package/utils/Utils.d.ts +8 -97
- package/utils/Utils.js +82 -302
- package/utils/clone.js +2 -3
- package/utils/env-vars.d.ts +3 -0
- package/utils/env-vars.js +87 -0
- package/utils/fs-utils.d.ts +12 -0
- package/utils/fs-utils.js +97 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -1
- package/utils/upsert-utils.d.ts +7 -2
- package/utils/upsert-utils.js +55 -4
- 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 -18
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -18
- 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 -40
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -30
- 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 -24
- 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 -13
- 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 -116
- package/entity/ArrayCollection.js +0 -402
- 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
package/EntityManager.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
|
-
import DataLoader from 'dataloader';
|
|
3
1
|
import { type Configuration } from './utils/Configuration.js';
|
|
4
2
|
import { Cursor } from './utils/Cursor.js';
|
|
5
3
|
import { EntityFactory } from './entity/EntityFactory.js';
|
|
6
4
|
import { type AssignOptions } from './entity/EntityAssigner.js';
|
|
7
|
-
import { EntityValidator } from './entity/EntityValidator.js';
|
|
8
5
|
import { type EntityRepository } from './entity/EntityRepository.js';
|
|
9
|
-
import { type EntityLoaderOptions } from './entity/EntityLoader.js';
|
|
6
|
+
import { EntityLoader, type EntityLoaderOptions } from './entity/EntityLoader.js';
|
|
10
7
|
import { Reference } from './entity/Reference.js';
|
|
11
8
|
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 {
|
|
9
|
+
import type { CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, StreamOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
|
|
10
|
+
import type { 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
11
|
import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
|
|
15
12
|
import type { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
16
13
|
import type { Transaction } from './connections/Connection.js';
|
|
@@ -27,13 +24,13 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
27
24
|
protected readonly metadata: MetadataStorage;
|
|
28
25
|
protected readonly useContext: boolean;
|
|
29
26
|
protected readonly eventManager: EventManager;
|
|
27
|
+
/** @internal */
|
|
28
|
+
readonly '~entities'?: unknown;
|
|
30
29
|
private static counter;
|
|
31
30
|
readonly _id: number;
|
|
32
31
|
readonly global = false;
|
|
33
32
|
readonly name: string;
|
|
34
|
-
|
|
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)?]>;
|
|
36
|
-
private readonly validator;
|
|
33
|
+
private readonly loaders;
|
|
37
34
|
private readonly repositoryMap;
|
|
38
35
|
private readonly entityLoader;
|
|
39
36
|
protected readonly comparator: EntityComparator;
|
|
@@ -72,14 +69,28 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
72
69
|
* Shortcut for `em.getRepository()`.
|
|
73
70
|
*/
|
|
74
71
|
repo<Entity extends object, Repository extends EntityRepository<Entity> = EntityRepository<Entity>>(entityName: EntityName<Entity>): GetRepository<Entity, Repository>;
|
|
75
|
-
/**
|
|
76
|
-
* Gets EntityValidator instance
|
|
77
|
-
*/
|
|
78
|
-
getValidator(): EntityValidator;
|
|
79
72
|
/**
|
|
80
73
|
* Finds all entities matching your `where` query. You can pass additional options via the `options` parameter.
|
|
81
74
|
*/
|
|
82
75
|
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>[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Finds all entities and returns an async iterable (async generator) that yields results one by one.
|
|
78
|
+
* The results are merged and mapped to entity instances, without adding them to the identity map.
|
|
79
|
+
* You can disable merging by passing the options `{ mergeResults: false }`.
|
|
80
|
+
* With `mergeResults` disabled, to-many collections will contain at most one item, and you will get duplicate
|
|
81
|
+
* root entities when there are multiple items in the populated collection.
|
|
82
|
+
* This is useful for processing large datasets without loading everything into memory at once.
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* const stream = em.stream(Book, { populate: ['author'] });
|
|
86
|
+
*
|
|
87
|
+
* for await (const book of stream) {
|
|
88
|
+
* // book is an instance of Book entity
|
|
89
|
+
* console.log(book.title, book.author.name);
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
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
94
|
/**
|
|
84
95
|
* Finds all entities of given type, optionally matching the `where` condition provided in the `options` parameter.
|
|
85
96
|
*/
|
|
@@ -88,19 +99,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
88
99
|
/**
|
|
89
100
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
90
101
|
*/
|
|
91
|
-
addFilter<
|
|
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;
|
|
102
|
+
addFilter<T extends EntityName<any> | readonly EntityName<any>[]>(options: FilterDef<T>): void;
|
|
104
103
|
/**
|
|
105
104
|
* Sets filter parameter values globally inside context defined by this entity manager.
|
|
106
105
|
* If you want to set shared value for all contexts, be sure to use the root entity manager.
|
|
@@ -117,20 +116,25 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
117
116
|
/**
|
|
118
117
|
* Gets logger context for this entity manager.
|
|
119
118
|
*/
|
|
120
|
-
getLoggerContext<T extends Dictionary = Dictionary>(
|
|
121
|
-
|
|
119
|
+
getLoggerContext<T extends Dictionary = Dictionary>(options?: {
|
|
120
|
+
disableContextResolution?: boolean;
|
|
121
|
+
}): T;
|
|
122
|
+
setFlushMode(flushMode?: FlushMode | `${FlushMode}`): void;
|
|
122
123
|
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
124
|
protected applyDiscriminatorCondition<Entity extends object>(entityName: string, where: FilterQuery<Entity>): FilterQuery<Entity>;
|
|
124
125
|
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>,
|
|
126
|
+
protected getJoinedFilters<Entity extends object>(meta: EntityMetadata<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any>): Promise<ObjectQuery<Entity> | undefined>;
|
|
126
127
|
/**
|
|
127
128
|
* 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
129
|
*/
|
|
129
|
-
protected autoJoinRefsForFilters<T extends object>(meta: EntityMetadata<T>, options: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any
|
|
130
|
+
protected autoJoinRefsForFilters<T extends object>(meta: EntityMetadata<T>, options: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, parent?: {
|
|
131
|
+
className: string;
|
|
132
|
+
propName: string;
|
|
133
|
+
}): Promise<void>;
|
|
130
134
|
/**
|
|
131
135
|
* @internal
|
|
132
136
|
*/
|
|
133
|
-
applyFilters<Entity extends object>(entityName: string, where: FilterQuery<Entity> | undefined, options:
|
|
137
|
+
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
138
|
/**
|
|
135
139
|
* Calls `em.find()` and `em.count()` with the same arguments (where applicable) and returns the results as tuple
|
|
136
140
|
* where the first element is the array of entities, and the second is the count.
|
|
@@ -267,6 +271,29 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
267
271
|
upsertMany<Entity extends object, Fields extends string = any>(entityNameOrEntity: EntityName<Entity> | Entity[], data?: (EntityData<Entity> | NoInfer<Entity>)[], options?: UpsertManyOptions<Entity, Fields>): Promise<Entity[]>;
|
|
268
272
|
/**
|
|
269
273
|
* Runs your callback wrapped inside a database transaction.
|
|
274
|
+
*
|
|
275
|
+
* If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
|
|
276
|
+
* can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
|
|
277
|
+
* should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
|
|
278
|
+
* method automatically creates an async context for the transaction.
|
|
279
|
+
*
|
|
280
|
+
* **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
|
|
281
|
+
* `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
|
|
282
|
+
* between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
|
|
283
|
+
* the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
|
|
284
|
+
*
|
|
285
|
+
* **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
|
|
286
|
+
* parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
|
|
287
|
+
* and then call this method on the fork.
|
|
288
|
+
*
|
|
289
|
+
* **Example:**
|
|
290
|
+
* ```ts
|
|
291
|
+
* await em.transactional(async (em) => {
|
|
292
|
+
* const author = new Author('Jon');
|
|
293
|
+
* em.persist(author);
|
|
294
|
+
* // flush is called automatically at the end of the callback
|
|
295
|
+
* });
|
|
296
|
+
* ```
|
|
270
297
|
*/
|
|
271
298
|
transactional<T>(cb: (em: this) => T | Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
272
299
|
/**
|
|
@@ -384,11 +411,6 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
384
411
|
* The entity will be entered into the database at or before transaction commit or as a result of the flush operation.
|
|
385
412
|
*/
|
|
386
413
|
persist<Entity extends object>(entity: Entity | Reference<Entity> | Iterable<Entity | Reference<Entity>>): this;
|
|
387
|
-
/**
|
|
388
|
-
* Persists your entity immediately, flushing all not yet persisted changes to the database too.
|
|
389
|
-
* Equivalent to `em.persist(e).flush()`.
|
|
390
|
-
*/
|
|
391
|
-
persistAndFlush(entity: AnyEntity | Reference<AnyEntity> | Iterable<AnyEntity | Reference<AnyEntity>>): Promise<void>;
|
|
392
414
|
/**
|
|
393
415
|
* Marks entity for removal.
|
|
394
416
|
* A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.
|
|
@@ -396,11 +418,6 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
396
418
|
* To remove entities by condition, use `em.nativeDelete()`.
|
|
397
419
|
*/
|
|
398
420
|
remove<Entity extends object>(entity: Entity | Reference<Entity> | Iterable<Entity | Reference<Entity>>): this;
|
|
399
|
-
/**
|
|
400
|
-
* Removes an entity instance immediately, flushing all not yet persisted changes to the database too.
|
|
401
|
-
* Equivalent to `em.remove(e).flush()`
|
|
402
|
-
*/
|
|
403
|
-
removeAndFlush(entity: AnyEntity | Reference<AnyEntity> | Iterable<AnyEntity | Reference<AnyEntity>>): Promise<void>;
|
|
404
421
|
/**
|
|
405
422
|
* Flushes all changes to objects that have been queued up to now to the database.
|
|
406
423
|
* This effectively synchronizes the in-memory state of managed objects with the database.
|
|
@@ -436,6 +453,10 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
436
453
|
* Gets the EntityFactory used by the EntityManager.
|
|
437
454
|
*/
|
|
438
455
|
getEntityFactory(): EntityFactory;
|
|
456
|
+
/**
|
|
457
|
+
* @internal use `em.populate()` as the user facing API, this is exposed only for internal usage
|
|
458
|
+
*/
|
|
459
|
+
getEntityLoader(): EntityLoader;
|
|
439
460
|
/**
|
|
440
461
|
* Gets the Hydrator used by the EntityManager.
|
|
441
462
|
*/
|
|
@@ -483,7 +504,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
483
504
|
* some additional lazy properties, if so, we reload and merge the data from database
|
|
484
505
|
*/
|
|
485
506
|
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;
|
|
486
|
-
protected prepareOptions(options: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>): void;
|
|
507
|
+
protected prepareOptions(options: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any> | CountOptions<any, any>): void;
|
|
487
508
|
/**
|
|
488
509
|
* @internal
|
|
489
510
|
*/
|
|
@@ -492,15 +513,15 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
492
513
|
* @internal
|
|
493
514
|
*/
|
|
494
515
|
tryCache<T extends object, R>(entityName: string, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean): Promise<{
|
|
495
|
-
data?: R;
|
|
516
|
+
data?: R | null;
|
|
496
517
|
key: string;
|
|
497
518
|
} | undefined>;
|
|
498
519
|
/**
|
|
499
520
|
* @internal
|
|
500
521
|
*/
|
|
501
|
-
storeCache(config: boolean | number | [string, number] | undefined, key: {
|
|
522
|
+
storeCache<T>(config: boolean | number | [string, number] | undefined, key: {
|
|
502
523
|
key: string;
|
|
503
|
-
}, data:
|
|
524
|
+
}, data: T | (() => T)): Promise<void>;
|
|
504
525
|
/**
|
|
505
526
|
* Clears result cache for given cache key. If we want to be able to call this method,
|
|
506
527
|
* we need to set the cache key explicitly when storing the cache.
|
|
@@ -524,13 +545,13 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
524
545
|
* if executed inside request context handler.
|
|
525
546
|
*/
|
|
526
547
|
set schema(schema: string | null | undefined);
|
|
548
|
+
/** @internal */
|
|
549
|
+
getDataLoader(type: 'ref' | '1:m' | 'm:n'): Promise<any>;
|
|
527
550
|
/**
|
|
528
551
|
* Returns the ID of this EntityManager. Respects the context, so global EM will give you the contextual ID
|
|
529
552
|
* if executed inside request context handler.
|
|
530
553
|
*/
|
|
531
554
|
get id(): number;
|
|
532
|
-
/** @ignore */
|
|
533
|
-
[inspect.custom](): string;
|
|
534
555
|
}
|
|
535
556
|
export interface CreateOptions<Convert extends boolean> {
|
|
536
557
|
/** creates a managed entity instance instead, bypassing the constructor call */
|
|
@@ -543,11 +564,19 @@ export interface CreateOptions<Convert extends boolean> {
|
|
|
543
564
|
partial?: boolean;
|
|
544
565
|
/** convert raw database values based on mapped types (by default, already converted values are expected) */
|
|
545
566
|
convertCustomTypes?: Convert;
|
|
567
|
+
/**
|
|
568
|
+
* Property `onCreate` hooks are normally executed during `flush` operation.
|
|
569
|
+
* With this option, they will be processed early inside `em.create()` method.
|
|
570
|
+
*/
|
|
571
|
+
processOnCreateHooksEarly?: boolean;
|
|
546
572
|
}
|
|
547
573
|
export interface MergeOptions {
|
|
548
574
|
refresh?: boolean;
|
|
549
575
|
convertCustomTypes?: boolean;
|
|
550
576
|
schema?: string;
|
|
577
|
+
disableContextResolution?: boolean;
|
|
578
|
+
validate?: boolean;
|
|
579
|
+
cascade?: boolean; /** @default true */
|
|
551
580
|
}
|
|
552
581
|
export interface ForkOptions {
|
|
553
582
|
/** do we want a clear identity map? defaults to true */
|
|
@@ -561,7 +590,7 @@ export interface ForkOptions {
|
|
|
561
590
|
/** use this flag to ignore the current async context - this is required if we want to call `em.fork()` inside the `getContext` handler */
|
|
562
591
|
disableContextResolution?: boolean;
|
|
563
592
|
/** set flush mode for this fork, overrides the global option can be overridden locally via FindOptions */
|
|
564
|
-
flushMode?: FlushMode
|
|
593
|
+
flushMode?: FlushMode | `${FlushMode}`;
|
|
565
594
|
/** disable transactions for this fork */
|
|
566
595
|
disableTransactions?: boolean;
|
|
567
596
|
/** should we keep the transaction context of the parent EM? */
|