Version: 4.3

Class: MongoEntityManager<D>

inheritdoc

Type parameters

NameTypeDefault
DMongoDriverMongoDriver

Hierarchy

  • EntityManager<D>

    MongoEntityManager

Constructors

constructor

+ new MongoEntityManager(config: Configuration, driver: D, metadata: MetadataStorage, useContext?: boolean, eventManager?: EventManager): MongoEntityManager

Inherited from SqlEntityManager.constructor

Defined in packages/core/dist/EntityManager.d.ts:35

Parameters:

NameType
configConfiguration
driverD
metadataMetadataStorage
useContext?boolean
eventManager?EventManager

Returns: MongoEntityManager

Properties

config

Readonly config: Configuration

Inherited from SqlEntityManager.config

Defined in packages/core/dist/EntityManager.d.ts:18


id

Readonly id: number

Inherited from SqlEntityManager.id

Defined in packages/core/dist/EntityManager.d.ts:24


name

Readonly name: string

Inherited from SqlEntityManager.name

Defined in packages/core/dist/EntityManager.d.ts:25

Methods

[inspect.custom]

[inspect.custom](): string

Inherited from SqlEntityManager.[inspect.custom]

Defined in packages/core/dist/EntityManager.d.ts:312

Returns: string


addFilter

addFilter<T1>(name: string, cond: FilterQuery<T1> | (args: Dictionary) => FilterQuery<T1>, entityName?: EntityName<T1> | [EntityName<T1>], enabled?: boolean): void

Inherited from SqlEntityManager.addFilter

Defined in packages/core/dist/EntityManager.d.ts:69

Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).

Type parameters:

NameType
T1AnyEntity<T1>

Parameters:

NameType
namestring
condFilterQuery<T1> | (args: Dictionary) => FilterQuery<T1>
entityName?EntityName<T1> | [EntityName<T1>]
enabled?boolean

Returns: void

addFilter<T1, T2>(name: string, cond: FilterQuery<T1 | T2> | (args: Dictionary) => FilterQuery<T1 | T2>, entityName?: [EntityName<T1>, EntityName<T2>], enabled?: boolean): void

Inherited from SqlEntityManager.addFilter

Defined in packages/core/dist/EntityManager.d.ts:73

Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).

Type parameters:

NameType
T1AnyEntity<T1>
T2AnyEntity<T2>

Parameters:

NameType
namestring
condFilterQuery<T1 | T2> | (args: Dictionary) => FilterQuery<T1 | T2>
entityName?[EntityName<T1>, EntityName<T2>]
enabled?boolean

Returns: void

addFilter<T1, T2, T3>(name: string, cond: FilterQuery<T1 | T2 | T3> | (args: Dictionary) => FilterQuery<T1 | T2 | T3>, entityName?: [EntityName<T1>, EntityName<T2>, EntityName<T3>], enabled?: boolean): void

Inherited from SqlEntityManager.addFilter

Defined in packages/core/dist/EntityManager.d.ts:77

Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).

Type parameters:

NameType
T1AnyEntity<T1>
T2AnyEntity<T2>
T3AnyEntity<T3>

Parameters:

NameType
namestring
condFilterQuery<T1 | T2 | T3> | (args: Dictionary) => FilterQuery<T1 | T2 | T3>
entityName?[EntityName<T1>, EntityName<T2>, EntityName<T3>]
enabled?boolean

Returns: void


aggregate

aggregate(entityName: EntityName<any>, pipeline: any[]): Promise<any[]>

Defined in packages/mongodb/src/MongoEntityManager.ts:14

Shortcut to driver's aggregate method. Available in MongoDriver only.

Parameters:

NameType
entityNameEntityName<any>
pipelineany[]

Returns: Promise<any[]>


applyFilters

ProtectedapplyFilters<T>(entityName: string, where: FilterQuery<T>, options: Dictionary<boolean | Dictionary> | string[] | boolean, type: "read" | "update" | "delete"): Promise<FilterQuery<T>>

Inherited from SqlEntityManager.applyFilters

Defined in packages/core/dist/EntityManager.d.ts:87

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>
optionsDictionary<boolean | Dictionary> | string[] | boolean
type"read" | "update" | "delete"

Returns: Promise<FilterQuery<T>>


assign

assign<T>(entity: T, data: EntityData<T>, options?: AssignOptions): T

Inherited from SqlEntityManager.assign

Defined in packages/core/dist/EntityManager.d.ts:177

Shortcut for wrap(entity).assign(data, { em })

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityT
dataEntityData<T>
options?AssignOptions

Returns: T


begin

begin(ctx?: Transaction): Promise<void>

Inherited from SqlEntityManager.begin

Defined in packages/core/dist/EntityManager.d.ts:125

Starts new transaction bound to this EntityManager. Use ctx parameter to provide the parent when nesting transactions.

Parameters:

NameType
ctx?Transaction

Returns: Promise<void>


canPopulate

canPopulate<T>(entityName: EntityName<T>, property: string): boolean

Inherited from SqlEntityManager.canPopulate

Defined in packages/core/dist/EntityManager.d.ts:246

Checks whether given property can be populated on the entity.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
propertystring

Returns: boolean


clear

clear(): void

Inherited from SqlEntityManager.clear

Defined in packages/core/dist/EntityManager.d.ts:242

Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.

Returns: void


commit

commit(): Promise<void>

Inherited from SqlEntityManager.commit

Defined in packages/core/dist/EntityManager.d.ts:129

Commits the transaction bound to this EntityManager. Flushes before doing the actual commit query.

Returns: Promise<void>


count

count<T>(entityName: EntityName<T>, where?: FilterQuery<T>, options?: CountOptions<T>): Promise<number>

Inherited from SqlEntityManager.count

Defined in packages/core/dist/EntityManager.d.ts:197

Returns total number of entities matching your where query.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
where?FilterQuery<T>
options?CountOptions<T>

Returns: Promise<number>


create

create<T, P>(entityName: EntityName<T>, data: EntityData<T>, options?: { managed?: boolean }): New<T, P>

Inherited from SqlEntityManager.create

Defined in packages/core/dist/EntityManager.d.ts:171

Creates new instance of given entity and populates it with given data

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
dataEntityData<T>
options?{ managed?: boolean }

Returns: New<T, P>


find

find<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOptions<T, P>): Promise<Loaded<T, P>[]>

Inherited from SqlEntityManager.find

Defined in packages/core/dist/EntityManager.d.ts:61

Finds all entities matching your where query. You can pass additional options via the options parameter.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
options?FindOptions<T, P>

Returns: Promise<Loaded<T, P>[]>

find<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, populate?: P, orderBy?: QueryOrderMap, limit?: number, offset?: number): Promise<Loaded<T, P>[]>

Inherited from SqlEntityManager.find

Defined in packages/core/dist/EntityManager.d.ts:65

Finds all entities matching your where query.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
populate?P
orderBy?QueryOrderMap
limit?number
offset?number

Returns: Promise<Loaded<T, P>[]>


findAndCount

findAndCount<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOptions<T, P>): Promise<[Loaded<T, P>[], number]>

Inherited from SqlEntityManager.findAndCount

Defined in packages/core/dist/EntityManager.d.ts:92

Calls em.find() and em.count() with the same arguments (where applicable) and returns the results as tuple where first element is the array of entities and the second is the count.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
options?FindOptions<T, P>

Returns: Promise<[Loaded<T, P>[], number]>

findAndCount<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, populate?: P, orderBy?: QueryOrderMap, limit?: number, offset?: number): Promise<[Loaded<T, P>[], number]>

Inherited from SqlEntityManager.findAndCount

Defined in packages/core/dist/EntityManager.d.ts:97

Calls em.find() and em.count() with the same arguments (where applicable) and returns the results as tuple where first element is the array of entities and the second is the count.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
populate?P
orderBy?QueryOrderMap
limit?number
offset?number

Returns: Promise<[Loaded<T, P>[], number]>


findOne

findOne<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOneOptions<T, P>): Promise<Loaded<T, P> | null>

Inherited from SqlEntityManager.findOne

Defined in packages/core/dist/EntityManager.d.ts:101

Finds first entity matching your where query.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
options?FindOneOptions<T, P>

Returns: Promise<Loaded<T, P> | null>

findOne<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, populate?: P, orderBy?: QueryOrderMap): Promise<Loaded<T, P> | null>

Inherited from SqlEntityManager.findOne

Defined in packages/core/dist/EntityManager.d.ts:105

Finds first entity matching your where query.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
populate?P
orderBy?QueryOrderMap

Returns: Promise<Loaded<T, P> | null>


findOneOrFail

findOneOrFail<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOneOrFailOptions<T, P>): Promise<Loaded<T, P>>

Inherited from SqlEntityManager.findOneOrFail

Defined in packages/core/dist/EntityManager.d.ts:111

Finds first entity matching your where query. If nothing found, it will throw an error. You can override the factory for creating this method via options.failHandler locally or via Configuration.findOneOrFailHandler globally.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
options?FindOneOrFailOptions<T, P>

Returns: Promise<Loaded<T, P>>

findOneOrFail<T, P>(entityName: EntityName<T>, where: FilterQuery<T>, populate?: P, orderBy?: QueryOrderMap): Promise<Loaded<T, P>>

Inherited from SqlEntityManager.findOneOrFail

Defined in packages/core/dist/EntityManager.d.ts:117

Finds first entity matching your where query. If nothing found, it will throw an error. You can override the factory for creating this method via options.failHandler locally or via Configuration.findOneOrFailHandler globally.

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
populate?P
orderBy?QueryOrderMap

Returns: Promise<Loaded<T, P>>


flush

flush(): Promise<void>

Inherited from SqlEntityManager.flush

Defined in packages/core/dist/EntityManager.d.ts:238

Flushes all changes to objects that have been queued up to now to the database. This effectively synchronizes the in-memory state of managed objects with the database.

Returns: Promise<void>


fork

fork(clear?: boolean, useContext?: boolean): D[typeof EntityManagerType]

Inherited from SqlEntityManager.fork

Defined in packages/core/dist/EntityManager.d.ts:265

Returns new EntityManager instance with its own identity map

Parameters:

NameTypeDescription
clear?booleando we want clear identity map? defaults to true
useContext?booleanuse request context? should be used only for top level request scope EM, defaults to false

Returns: D[typeof EntityManagerType]


getCollection

getCollection(entityName: EntityName<any>): Collection

Defined in packages/mongodb/src/MongoEntityManager.ts:19

Parameters:

NameType
entityNameEntityName<any>

Returns: Collection


getComparator

getComparator(): EntityComparator

Inherited from SqlEntityManager.getComparator

Defined in packages/core/dist/EntityManager.d.ts:294

Gets the EntityComparator.

Returns: EntityComparator


getConnection

getConnection(type?: "read" | "write"): ReturnType<D["getConnection"]>

Inherited from SqlEntityManager.getConnection

Defined in packages/core/dist/EntityManager.d.ts:45

Gets the Connection instance, by default returns write connection

Parameters:

NameType
type?"read" | "write"

Returns: ReturnType<D["getConnection"]>


getContext

getContext(): EntityManager

Inherited from SqlEntityManager.getContext

Defined in packages/core/dist/EntityManager.d.ts:277

Gets the EntityManager based on current transaction/request context.

Returns: EntityManager


getDriver

getDriver(): D

Inherited from SqlEntityManager.getDriver

Defined in packages/core/dist/EntityManager.d.ts:41

Gets the Driver instance used by this EntityManager. Driver is singleton, for one MikroORM instance, only one driver is created.

Returns: D


getEntityFactory

getEntityFactory(): EntityFactory

Inherited from SqlEntityManager.getEntityFactory

Defined in packages/core/dist/EntityManager.d.ts:273

Gets the EntityFactory used by the EntityManager.

Returns: EntityFactory


getEventManager

getEventManager(): EventManager

Inherited from SqlEntityManager.getEventManager

Defined in packages/core/dist/EntityManager.d.ts:278

Returns: EventManager


getFilterParams

getFilterParams<T>(name: string): T

Inherited from SqlEntityManager.getFilterParams

Defined in packages/core/dist/EntityManager.d.ts:86

Returns filter parameters for given filter set in this context.

Type parameters:

NameTypeDefault
TDictionaryDictionary

Parameters:

NameType
namestring

Returns: T


getMetadata

getMetadata(): MetadataStorage

Inherited from SqlEntityManager.getMetadata

Defined in packages/core/dist/EntityManager.d.ts:290

Gets the MetadataStorage.

Returns: MetadataStorage


getPlatform

getPlatform(): ReturnType<D["getPlatform"]>

Inherited from SqlEntityManager.getPlatform

Defined in packages/core/dist/EntityManager.d.ts:49

Gets the platform instance. Just like the driver, platform is singleton, one for a MikroORM instance.

Returns: ReturnType<D["getPlatform"]>


getReference

getReference<T, PK>(entityName: EntityName<T>, id: Primary<T>, wrapped: true, convertCustomTypes?: boolean): IdentifiedReference<T, PK>

Inherited from SqlEntityManager.getReference

Defined in packages/core/dist/EntityManager.d.ts:181

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded

Type parameters:

NameType
TAnyEntity<T>
PKkeyof T

Parameters:

NameType
entityNameEntityName<T>
idPrimary<T>
wrappedtrue
convertCustomTypes?boolean

Returns: IdentifiedReference<T, PK>

getReference<T>(entityName: EntityName<T>, id: Primary<T> | Primary<T>[]): T

Inherited from SqlEntityManager.getReference

Defined in packages/core/dist/EntityManager.d.ts:185

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
idPrimary<T> | Primary<T>[]

Returns: T

getReference<T>(entityName: EntityName<T>, id: Primary<T>, wrapped: false, convertCustomTypes?: boolean): T

Inherited from SqlEntityManager.getReference

Defined in packages/core/dist/EntityManager.d.ts:189

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
idPrimary<T>
wrappedfalse
convertCustomTypes?boolean

Returns: T

getReference<T>(entityName: EntityName<T>, id: Primary<T>, wrapped?: boolean, convertCustomTypes?: boolean): T | Reference<T>

Inherited from SqlEntityManager.getReference

Defined in packages/core/dist/EntityManager.d.ts:193

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
idPrimary<T>
wrapped?boolean
convertCustomTypes?boolean

Returns: T | Reference<T>


getRepository

getRepository<T, U>(entityName: EntityName<T>): GetRepository<T, U>

Overrides void

Defined in packages/mongodb/src/MongoEntityManager.ts:23

Type parameters:

NameTypeDefault
TAnyEntity<T>-
UEntityRepository<T>MongoEntityRepository\<T>

Parameters:

NameType
entityNameEntityName<T>

Returns: GetRepository<T, U>


getTransactionContext

getTransactionContext<T>(): T | undefined

Inherited from SqlEntityManager.getTransactionContext

Defined in packages/core/dist/EntityManager.d.ts:286

Gets the transaction context (driver dependent object used to make sure queries are executed on same connection).

Type parameters:

NameTypeDefault
TTransactionTransaction

Returns: T | undefined


getUnitOfWork

getUnitOfWork(): UnitOfWork

Inherited from SqlEntityManager.getUnitOfWork

Defined in packages/core/dist/EntityManager.d.ts:269

Gets the UnitOfWork used by the EntityManager to coordinate operations.

Returns: UnitOfWork


getValidator

getValidator(): EntityValidator

Inherited from SqlEntityManager.getValidator

Defined in packages/core/dist/EntityManager.d.ts:57

Gets EntityValidator instance

Returns: EntityValidator


isInTransaction

isInTransaction(): boolean

Inherited from SqlEntityManager.isInTransaction

Defined in packages/core/dist/EntityManager.d.ts:282

Checks whether this EntityManager is currently operating inside a database transaction.

Returns: boolean


lock

lock(entity: AnyEntity, lockMode: LockMode, lockVersion?: number | Date): Promise<void>

Inherited from SqlEntityManager.lock

Defined in packages/core/dist/EntityManager.d.ts:137

Runs your callback wrapped inside a database transaction.

Parameters:

NameType
entityAnyEntity
lockModeLockMode
lockVersion?number | Date

Returns: Promise<void>


map

map<T>(entityName: EntityName<T>, result: EntityData<T>): T

Inherited from SqlEntityManager.map

Defined in packages/core/dist/EntityManager.d.ts:157

Maps raw database result to an entity and merges it to this EntityManager.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
resultEntityData<T>

Returns: T


merge

merge<T>(entity: T, refresh?: boolean): T

Inherited from SqlEntityManager.merge

Defined in packages/core/dist/EntityManager.d.ts:162

Merges given entity to this EntityManager so it becomes managed. You can force refreshing of existing entities via second parameter. By default it will return already loaded entities without modifying them.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityT
refresh?boolean

Returns: T

merge<T>(entityName: EntityName<T>, data: EntityData<T>, refresh?: boolean, convertCustomTypes?: boolean): T

Inherited from SqlEntityManager.merge

Defined in packages/core/dist/EntityManager.d.ts:167

Merges given entity to this EntityManager so it becomes managed. You can force refreshing of existing entities via second parameter. By default it will return already loaded entities without modifying them.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
dataEntityData<T>
refresh?boolean
convertCustomTypes?boolean

Returns: T


nativeDelete

nativeDelete<T>(entityName: EntityName<T>, where: FilterQuery<T>, options?: DeleteOptions<T>): Promise<number>

Inherited from SqlEntityManager.nativeDelete

Defined in packages/core/dist/EntityManager.d.ts:153

Fires native delete query. Calling this has no side effects on the context (identity map).

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
options?DeleteOptions<T>

Returns: Promise<number>


nativeInsert

nativeInsert<T>(entity: T): Promise<Primary<T>>

Inherited from SqlEntityManager.nativeInsert

Defined in packages/core/dist/EntityManager.d.ts:141

Fires native insert query. Calling this has no side effects on the context (identity map).

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityT

Returns: Promise<Primary<T>>

nativeInsert<T>(entityName: EntityName<T>, data: EntityData<T>): Promise<Primary<T>>

Inherited from SqlEntityManager.nativeInsert

Defined in packages/core/dist/EntityManager.d.ts:145

Fires native insert query. Calling this has no side effects on the context (identity map).

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
dataEntityData<T>

Returns: Promise<Primary<T>>


nativeUpdate

nativeUpdate<T>(entityName: EntityName<T>, where: FilterQuery<T>, data: EntityData<T>, options?: UpdateOptions<T>): Promise<number>

Inherited from SqlEntityManager.nativeUpdate

Defined in packages/core/dist/EntityManager.d.ts:149

Fires native update query. Calling this has no side effects on the context (identity map).

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNameEntityName<T>
whereFilterQuery<T>
dataEntityData<T>
options?UpdateOptions<T>

Returns: Promise<number>


persist

persist(entity: AnyEntity | Reference<AnyEntity> | (AnyEntity | Reference<AnyEntity>)[]): this

Inherited from SqlEntityManager.persist

Defined in packages/core/dist/EntityManager.d.ts:202

Tells the EntityManager to make an instance managed and persistent. The entity will be entered into the database at or before transaction commit or as a result of the flush operation.

Parameters:

NameType
entityAnyEntity | Reference<AnyEntity> | (AnyEntity | Reference<AnyEntity>)[]

Returns: this


persistAndFlush

persistAndFlush(entity: AnyEntity | Reference<AnyEntity> | (AnyEntity | Reference<AnyEntity>)[]): Promise<void>

Inherited from SqlEntityManager.persistAndFlush

Defined in packages/core/dist/EntityManager.d.ts:207

Persists your entity immediately, flushing all not yet persisted changes to the database too. Equivalent to em.persist(e).flush().

Parameters:

NameType
entityAnyEntity | Reference<AnyEntity> | (AnyEntity | Reference<AnyEntity>)[]

Returns: Promise<void>


persistLater

persistLater(entity: AnyEntity | AnyEntity[]): void

Inherited from SqlEntityManager.persistLater

Defined in packages/core/dist/EntityManager.d.ts:214

Tells the EntityManager to make an instance managed and persistent. The entity will be entered into the database at or before transaction commit or as a result of the flush operation.

deprecated use persist()

Parameters:

NameType
entityAnyEntity | AnyEntity[]

Returns: void


populate

populate<T, P>(entities: T, populate: P, where?: FilterQuery<T>, orderBy?: QueryOrderMap, refresh?: boolean, validate?: boolean): Promise<Loaded<T, P>>

Inherited from SqlEntityManager.populate

Defined in packages/core/dist/EntityManager.d.ts:250

Loads specified relations in batch. This will execute one query for each relation, that will populate it on all of the specified entities.

Type parameters:

NameType
TAnyEntity<T>
Pstring | keyof T | Populate<T>

Parameters:

NameType
entitiesT
populateP
where?FilterQuery<T>
orderBy?QueryOrderMap
refresh?boolean
validate?boolean

Returns: Promise<Loaded<T, P>>

populate<T, P>(entities: T[], populate: P, where?: FilterQuery<T>, orderBy?: QueryOrderMap, refresh?: boolean, validate?: boolean): Promise<Loaded<T, P>[]>

Inherited from SqlEntityManager.populate

Defined in packages/core/dist/EntityManager.d.ts:254

Loads specified relations in batch. This will execute one query for each relation, that will populate it on all of the specified entities.

Type parameters:

NameType
TAnyEntity<T>
Pstring | keyof T | Populate<T>

Parameters:

NameType
entitiesT[]
populateP
where?FilterQuery<T>
orderBy?QueryOrderMap
refresh?boolean
validate?boolean

Returns: Promise<Loaded<T, P>[]>

populate<T, P>(entities: T | T[], populate: P, where?: FilterQuery<T>, orderBy?: QueryOrderMap, refresh?: boolean, validate?: boolean): Promise<Loaded<T, P> | Loaded<T, P>[]>

Inherited from SqlEntityManager.populate

Defined in packages/core/dist/EntityManager.d.ts:258

Loads specified relations in batch. This will execute one query for each relation, that will populate it on all of the specified entities.

Type parameters:

NameType
TAnyEntity<T>
Pstring | keyof T | Populate<T>

Parameters:

NameType
entitiesT | T[]
populateP
where?FilterQuery<T>
orderBy?QueryOrderMap
refresh?boolean
validate?boolean

Returns: Promise<Loaded<T, P> | Loaded<T, P>[]>


remove

remove<T>(entity: T | Reference<T> | (T | Reference<T>)[]): this

Inherited from SqlEntityManager.remove

Defined in packages/core/dist/EntityManager.d.ts:221

Marks entity for removal. A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.

To remove entities by condition, use em.nativeDelete().

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityT | Reference<T> | (T | Reference<T>)[]

Returns: this


removeAndFlush

removeAndFlush(entity: AnyEntity | Reference<AnyEntity>): Promise<void>

Inherited from SqlEntityManager.removeAndFlush

Defined in packages/core/dist/EntityManager.d.ts:226

Removes an entity instance immediately, flushing all not yet persisted changes to the database too. Equivalent to em.remove(e).flush()

Parameters:

NameType
entityAnyEntity | Reference<AnyEntity>

Returns: Promise<void>


removeLater

removeLater(entity: AnyEntity): void

Inherited from SqlEntityManager.removeLater

Defined in packages/core/dist/EntityManager.d.ts:233

Marks entity for removal. A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.

deprecated use remove()

Parameters:

NameType
entityAnyEntity

Returns: void


rollback

rollback(): Promise<void>

Inherited from SqlEntityManager.rollback

Defined in packages/core/dist/EntityManager.d.ts:133

Rollbacks the transaction bound to this EntityManager.

Returns: Promise<void>


setFilterParams

setFilterParams(name: string, args: Dictionary): void

Inherited from SqlEntityManager.setFilterParams

Defined in packages/core/dist/EntityManager.d.ts:82

Sets filter parameter values globally inside context defined by this entity manager. If you want to set shared value for all contexts, be sure to use the root entity manager.

Parameters:

NameType
namestring
argsDictionary

Returns: void


storeCache

storeCache(config: boolean | number | [string, number] | undefined, key: { key: string }, data: unknown | () => unknown): Promise<void>

Inherited from SqlEntityManager.storeCache

Defined in packages/core/dist/EntityManager.d.ts:309

internal

Parameters:

NameType
configboolean | number | [string, number] | undefined
key{ key: string }
dataunknown | () => unknown

Returns: Promise<void>


transactional

transactional<T>(cb: (em: D[typeof EntityManagerType]) => Promise<T>, ctx?: any): Promise<T>

Inherited from SqlEntityManager.transactional

Defined in packages/core/dist/EntityManager.d.ts:121

Runs your callback wrapped inside a database transaction.

Type parameters:

Name
T

Parameters:

NameType
cb(em: D[typeof EntityManagerType]) => Promise<T>
ctx?any

Returns: Promise<T>


tryCache

tryCache<T, R>(entityName: string, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean): Promise<{ data?: R ; key: string } | undefined>

Inherited from SqlEntityManager.tryCache

Defined in packages/core/dist/EntityManager.d.ts:302

internal

Type parameters:

Name
T
R

Parameters:

NameType
entityNamestring
configboolean | number | [string, number] | undefined
keyunknown
refresh?boolean
merge?boolean

Returns: Promise<{ data?: R ; key: string } | undefined>

Last updated on by Martin Adámek