Version: 4.3

Class: MongoDriver

Hierarchy#

Implements#

Constructors#

constructor#

+ new MongoDriver(config: Configuration): MongoDriver

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:15

Parameters:#

NameType
configConfiguration

Returns: MongoDriver

Properties#

[EntityManagerType]#

[EntityManagerType]: MongoEntityManager<this>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:12


comparator#

Protected comparator: EntityComparator

Inherited from AbstractSqlDriver.comparator

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:19


config#

Protected Readonly config: Configuration

Inherited from AbstractSqlDriver.config

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:12


connection#

Protected Readonly connection: MongoConnection = new MongoConnection(this.config)

Overrides void

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


dependencies#

Protected Readonly dependencies: string[]

Inherited from AbstractSqlDriver.dependencies

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:13


logger#

Protected Readonly logger: Logger

Inherited from AbstractSqlDriver.logger

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:18


metadata#

Protected metadata: MetadataStorage

Inherited from AbstractSqlDriver.metadata

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:20


platform#

Protected Readonly platform: MongoPlatform = new MongoPlatform()

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:15


replicas#

Protected Readonly replicas: MongoConnection[]

Inherited from MongoDriver.replicas

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:16

Methods#

aggregate#

aggregate(entityName: string, pipeline: any[], ctx?: Transaction<ClientSession>): Promise<any[]>

Overrides AbstractSqlDriver.aggregate

Defined in packages/mongodb/src/MongoDriver.ts:86

Parameters:#

NameType
entityNamestring
pipelineany[]
ctx?Transaction<ClientSession>

Returns: Promise<any[]>


buildFields#

PrivatebuildFields<T>(entityName: string, populate: PopulateOptions<T>[], fields?: string[]): string[] | undefined

Defined in packages/mongodb/src/MongoDriver.ts:273

Type parameters:#

Name
T

Parameters:#

NameType
entityNamestring
populatePopulateOptions<T>[]
fields?string[]

Returns: string[] | undefined


buildFilterById#

PrivatebuildFilterById<T>(entityName: string, id: string): FilterQuery<T>

Defined in packages/mongodb/src/MongoDriver.ts:263

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
idstring

Returns: FilterQuery<T>


close#

close(force?: boolean): Promise<void>

Inherited from AbstractSqlDriver.close

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:38

Parameters:#

NameType
force?boolean

Returns: Promise<void>


connect#

connect(): Promise<MongoConnection>

Inherited from AbstractSqlDriver.connect

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:35

Returns: Promise<MongoConnection>


convertException#

convertException(exception: Error): DriverException

Inherited from AbstractSqlDriver.convertException

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:56

inheritdoc

Parameters:#

NameType
exceptionError

Returns: DriverException


convertObjectIds#

PrivateconvertObjectIds<T>(data: T): T

Defined in packages/mongodb/src/MongoDriver.ts:241

Type parameters:#

NameType
TObjectId | Dictionary | any[]

Parameters:#

NameType
dataT

Returns: T


count#

count<T>(entityName: string, where: FilterQuery<T>, options?: CountOptions<T>, ctx?: Transaction<ClientSession>): Promise<number>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:45

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>-
optionsCountOptions<T>{}
ctx?Transaction<ClientSession>-

Returns: Promise<number>


createCollections#

createCollections(): Promise<void>

Defined in packages/mongodb/src/MongoDriver.ts:90

Returns: Promise<void>


createEntityManager#

createEntityManager<D>(useContext?: boolean): D[typeof EntityManagerType]

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:21

Type parameters:#

NameTypeDefault
DIDatabaseDriverIDatabaseDriver

Parameters:#

NameType
useContext?boolean

Returns: D[typeof EntityManagerType]


createIndexes#

PrivatecreateIndexes(meta: EntityMetadata): Promise<string>[]

Defined in packages/mongodb/src/MongoDriver.ts:132

Parameters:#

NameType
metaEntityMetadata

Returns: Promise<string>[]


createPropertyIndexes#

PrivatecreatePropertyIndexes(meta: EntityMetadata, prop: EntityProperty, type: "index" | "unique"): Promise<string>[]

Defined in packages/mongodb/src/MongoDriver.ts:176

Parameters:#

NameType
metaEntityMetadata
propEntityProperty
type"index" | "unique"

Returns: Promise<string>[]


createReplicas#

ProtectedcreateReplicas(cb: (c: ConnectionOptions) => MongoConnection): MongoConnection[]

Inherited from AbstractSqlDriver.createReplicas

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:47

Parameters:#

NameType
cb(c: ConnectionOptions) => MongoConnection

Returns: MongoConnection[]


createUniqueIndexes#

PrivatecreateUniqueIndexes(meta: EntityMetadata): Promise<string>[]

Defined in packages/mongodb/src/MongoDriver.ts:161

Parameters:#

NameType
metaEntityMetadata

Returns: Promise<string>[]


dropCollections#

dropCollections(): Promise<void>

Defined in packages/mongodb/src/MongoDriver.ts:104

Returns: Promise<void>


ensureIndexes#

ensureIndexes(): Promise<void>

Overrides AbstractSqlDriver.ensureIndexes

Defined in packages/mongodb/src/MongoDriver.ts:115

Returns: Promise<void>


find#

find<T>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T>, ctx?: Transaction<ClientSession>): Promise<EntityData<T>[]>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:25

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>-
optionsFindOptions<T>{}
ctx?Transaction<ClientSession>-

Returns: Promise<EntityData<T>[]>


findOne#

findOne<T>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T>, ctx?: Transaction<ClientSession>): Promise<EntityData<T> | null>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:33

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>-
optionsFindOneOptions<T>{ populate: [], orderBy: {} }
ctx?Transaction<ClientSession>-

Returns: Promise<EntityData<T> | null>


getConnection#

getConnection(type?: "read" | "write"): MongoConnection

Inherited from AbstractSqlDriver.getConnection

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:37

Parameters:#

NameType
type?"read" | "write"

Returns: MongoConnection


getDependencies#

getDependencies(): string[]

Inherited from AbstractSqlDriver.getDependencies

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:41

Returns: string[]


getPivotInverseProperty#

ProtectedgetPivotInverseProperty(prop: EntityProperty): EntityProperty

Inherited from AbstractSqlDriver.getPivotInverseProperty

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:46

Parameters:#

NameType
propEntityProperty

Returns: EntityProperty


getPivotOrderBy#

ProtectedgetPivotOrderBy(prop: EntityProperty, orderBy?: QueryOrderMap): QueryOrderMap

Inherited from AbstractSqlDriver.getPivotOrderBy

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:44

Parameters:#

NameType
propEntityProperty
orderBy?QueryOrderMap

Returns: QueryOrderMap


getPlatform#

getPlatform(): Platform

Inherited from MongoDriver.getPlatform

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:39

Returns: Platform


getPrimaryKeyFields#

ProtectedgetPrimaryKeyFields(entityName: string): string[]

Inherited from AbstractSqlDriver.getPrimaryKeyFields

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:45

Parameters:#

NameType
entityNamestring

Returns: string[]


inlineEmbeddables#

ProtectedinlineEmbeddables<T>(meta: EntityMetadata<T>, data: T, where?: boolean): void

Inherited from AbstractSqlDriver.inlineEmbeddables

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:43

Type parameters:#

Name
T

Parameters:#

NameType
metaEntityMetadata<T>
dataT
where?boolean

Returns: void


loadFromPivotTable#

loadFromPivotTable<T, O>(prop: EntityProperty, owners: Primary<O>[][], where?: FilterQuery<T>, orderBy?: QueryOrderMap, ctx?: Transaction): Promise<Dictionary<T[]>>

Inherited from MongoDriver.loadFromPivotTable

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:32

Type parameters:#

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:#

NameType
propEntityProperty
ownersPrimary<O>[][]
where?FilterQuery<T>
orderBy?QueryOrderMap
ctx?Transaction

Returns: Promise<Dictionary<T[]>>


lockPessimistic#

lockPessimistic<T>(entity: T, mode: LockMode, ctx?: Transaction): Promise<void>

Inherited from MongoDriver.lockPessimistic

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:48

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityT
modeLockMode
ctx?Transaction

Returns: Promise<void>


mapResult#

mapResult<T>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[]): EntityData<T> | null

Inherited from MongoDriver.mapResult

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:34

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
resultEntityData<T>
metaEntityMetadata<T>
populate?PopulateOptions<T>[]

Returns: EntityData<T> | null


nativeDelete#

nativeDelete<T>(entityName: string, where: FilterQuery<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:76

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
whereFilterQuery<T>
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>


nativeInsert#

nativeInsert<T>(entityName: string, data: EntityData<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:50

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
dataEntityData<T>
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>


nativeInsertMany#

nativeInsertMany<T>(entityName: string, data: EntityData<T>[], ctx?: Transaction<ClientSession>, processCollections?: boolean): Promise<QueryResult>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:55

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
dataEntityData<T>[]-
ctx?Transaction<ClientSession>-
processCollectionsbooleantrue

Returns: Promise<QueryResult>


nativeUpdate#

nativeUpdate<T>(entityName: string, where: FilterQuery<T>, data: EntityData<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:60

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
whereFilterQuery<T>
dataEntityData<T>
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>


nativeUpdateMany#

nativeUpdateMany<T>(entityName: string, where: FilterQuery<T>[], data: EntityData<T>[], ctx?: Transaction<ClientSession>, processCollections?: boolean): Promise<QueryResult>

Overrides void

Defined in packages/mongodb/src/MongoDriver.ts:71

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
whereFilterQuery<T>[]
dataEntityData<T>[]
ctx?Transaction<ClientSession>
processCollections?boolean

Returns: Promise<QueryResult>


reconnect#

reconnect(): Promise<MongoConnection>

Inherited from AbstractSqlDriver.reconnect

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:36

Returns: Promise<MongoConnection>


renameFields#

PrivaterenameFields<T>(entityName: string, data: T, where?: boolean): T

Defined in packages/mongodb/src/MongoDriver.ts:190

Type parameters:#

Name
T

Parameters:#

NameTypeDefault value
entityNamestring-
dataT-
wherebooleanfalse

Returns: T


rethrow#

Protectedrethrow<T>(promise: Promise<T>): Promise<T>

Inherited from AbstractSqlDriver.rethrow

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:57

Type parameters:#

Name
T

Parameters:#

NameType
promisePromise<T>

Returns: Promise<T>


setMetadata#

setMetadata(metadata: MetadataStorage): void

Inherited from AbstractSqlDriver.setMetadata

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:40

Parameters:#

NameType
metadataMetadataStorage

Returns: void


shouldHaveColumn#

shouldHaveColumn<T>(prop: EntityProperty<T>, populate: PopulateOptions<T>[]): boolean

Overrides AbstractSqlDriver.shouldHaveColumn

Defined in packages/mongodb/src/MongoDriver.ts:287

Type parameters:#

Name
T

Parameters:#

NameType
propEntityProperty<T>
populatePopulateOptions<T>[]

Returns: boolean


syncCollection#

syncCollection<T, O>(coll: Collection<T, O>, ctx?: Transaction): Promise<void>

Inherited from MongoDriver.syncCollection

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:33

Type parameters:#

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:#

NameType
collCollection<T, O>
ctx?Transaction

Returns: Promise<void>

Last updated on by Renovate Bot