MongoDriver
Hierarchy
- DatabaseDriver<MongoConnection>
- MongoDriver
Index
Constructors
Properties
Methods
Constructors
constructor
Parameters
Returns MongoDriver
Properties
[EntityManagerType]
readonlyconfig
Methods
aggregate
Parameters
entityName: string
pipeline: any[]
optionalctx: ClientSession
Returns Promise<any[]>
close
Parameters
optionalforce: boolean
Returns Promise<void>
connect
Returns Promise<MongoConnection>
convertException
Parameters
exception: Error
Returns DriverException
count
Type parameters
- T: object
Parameters
entityName: string
where: FilterQuery<T>
options: CountOptions<T, never> = {}
optionalctx: ClientSession
Returns Promise<number>
countVirtual
Type parameters
- T: object
Parameters
entityName: string
where: FilterQuery<T>
options: CountOptions<T, any>
Returns Promise<number>
createEntityManager
Type parameters
Parameters
optionaluseContext: boolean
Returns D[typeof EntityManagerType]
find
Finds selection of entities
Type parameters
- T: object
- P: string = never
- F: string = *
- E: string = never
Parameters
entityName: string
where: FilterQuery<T>
options: FindOptions<T, P, F, E> = {}
Returns Promise<EntityData<T>[]>
findOne
Finds single entity (table row, document)
Type parameters
- T: object
- P: string = never
- F: string = ALL
- E: string = never
Parameters
entityName: string
where: FilterQuery<T>
options: FindOneOptions<T, P, F, E> = ...
Returns Promise<null | EntityData<T>>
findVirtual
Type parameters
- T: object
Parameters
entityName: string
where: FilterQuery<T>
options: FindOptions<T, any, any, any>
Returns Promise<EntityData<T>[]>
getConnection
Parameters
type: ConnectionType = 'write'
Returns MongoConnection
getDependencies
Returns name of the underlying database dependencies (e.g.
mongodb
ormysql2
) for SQL drivers it also returnsknex
in the array as connectors are not used directly thereReturns string[]
getMetadata
Returns MetadataStorage
getPlatform
Returns MongoPlatform
loadFromPivotTable
When driver uses pivot tables for M:N, this method will load identifiers for given collections from them
Type parameters
- T: object
- O: object
Parameters
prop: EntityProperty<any, any>
owners: (O extends { [PrimaryKeyProp]?: PK } ? PK extends keyof O ? ReadonlyPrimary<UnwrapPrimary<O[PK]>> : PK extends keyof O[] ? ReadonlyPrimary<PrimaryPropToType<O, PK>> : PK : O extends { _id?: PK } ? string | ReadonlyPrimary<PK> : O extends { uuid?: PK } ? ReadonlyPrimary<PK> : O extends { id?: PK } ? ReadonlyPrimary<PK> : O)[][]
optionalwhere: any
optionalorderBy: OrderDefinition<T>
optionalctx: any
optionaloptions: FindOptions<T, any, any, any>
optionalpivotJoin: boolean
Returns Promise<Dictionary<T[]>>
lockPessimistic
Type parameters
- T: object
Parameters
entity: T
options: LockOptions
Returns Promise<void>
mapResult
Type parameters
- T: object
Parameters
result: EntityDictionary<T>
optionalmeta: EntityMetadata<T>
populate: PopulateOptions<T>[] = []
Returns null | EntityData<T>
nativeDelete
Type parameters
- T: object
Parameters
entityName: string
where: FilterQuery<T>
options: { ctx?: ClientSession } = {}
optionalctx: ClientSession
Returns Promise<QueryResult<T>>
nativeInsert
Type parameters
- T: object
Parameters
entityName: string
data: EntityDictionary<T>
options: NativeInsertUpdateOptions<T> = {}
Returns Promise<QueryResult<T>>
nativeInsertMany
Type parameters
- T: object
Parameters
entityName: string
data: EntityDictionary<T>[]
options: NativeInsertUpdateManyOptions<T> = {}
Returns Promise<QueryResult<T>>
nativeUpdate
Type parameters
- T: object
Parameters
entityName: string
where: FilterQuery<T>
data: EntityDictionary<T>
options: NativeInsertUpdateOptions<T> & UpsertOptions<T, never> = {}
Returns Promise<QueryResult<T>>
nativeUpdateMany
Type parameters
- T: object
Parameters
entityName: string
where: FilterQuery<T>[]
data: EntityDictionary<T>[]
options: NativeInsertUpdateOptions<T> & UpsertManyOptions<T, never> = {}
Returns Promise<QueryResult<T>>
reconnect
Returns Promise<MongoConnection>
setMetadata
Parameters
metadata: MetadataStorage
Returns void
syncCollections
Type parameters
- T: object
- O: object
Parameters
collections: Iterable<Collection<T, O>, any, any>
optionaloptions: DriverMethodOptions
Returns Promise<void>
Converts native db errors to standardized driver exceptions