MongoConnection
Hierarchy
- Connection
- MongoConnection
Index
Constructors
Methods
- aggregate
- begin
- bulkUpdateMany
- checkConnection
- close
- commit
- connect
- countDocuments
- createCollection
- deleteMany
- dropCollection
- ensureConnection
- execute
- find
- getClient
- getClientUrl
- getCollection
- getConnectionOptions
- getDb
- getDefaultClientUrl
- getPlatform
- insertMany
- insertOne
- isConnected
- listCollections
- rollback
- setMetadata
- setPlatform
- transactional
- updateMany
Constructors
constructor
Parameters
config: Configuration<IDatabaseDriver<Connection>, EntityManager<IDatabaseDriver<Connection>>>
optionaloptions: ConnectionOptions
type: ConnectionType = 'write'
Returns MongoConnection
Methods
aggregate
Type parameters
- T: object = any
Parameters
collection: string
pipeline: any[]
optionalctx: ClientSession
optionalloggerContext: LoggingOptions
Returns Promise<T[]>
begin
Parameters
options: { ctx?: ClientSession; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel } & TransactionOptions = {}
Returns Promise<ClientSession>
bulkUpdateMany
Type parameters
- T: object
Parameters
collection: string
where: FilterQuery<T>[]
data: Partial<T>[]
optionalctx: ClientSession
optionalupsert: boolean
optionalupsertOptions: UpsertManyOptions<T>
Returns Promise<QueryResult<T>>
checkConnection
Returns Promise<{ error?: Error; ok: boolean; reason?: string }>
close
Closes the database connection (aka disconnect)
Parameters
optionalforce: boolean
Returns Promise<void>
commit
Parameters
ctx: ClientSession
optionaleventBroadcaster: TransactionEventBroadcaster
Returns Promise<void>
connect
Establishes connection to database
Returns Promise<void>
countDocuments
Type parameters
- T: object
Parameters
collection: string
where: FilterQuery<T>
optionalctx: ClientSession
Returns Promise<number>
createCollection
Type parameters
- T: object
Parameters
name: EntityName<T>
Returns Promise<Collection<T>>
deleteMany
Type parameters
- T: object
Parameters
collection: string
where: FilterQuery<T>
optionalctx: ClientSession
Returns Promise<QueryResult<T>>
dropCollection
Parameters
name: EntityName<Partial<any>>
Returns Promise<boolean>
ensureConnection
Ensure the connection exists, this is used to support lazy connect when using
MikroORM.initSync()
Returns Promise<void>
execute
Parameters
query: string
Returns Promise<any>
find
Type parameters
- T: object
Parameters
collection: string
where: FilterQuery<T>
optionalorderBy: QueryOrderMap<T> | QueryOrderMap<T>[]
optionallimit: number
optionaloffset: number
optionalfields: string[]
optionalctx: ClientSession
optionalloggerContext: LoggingOptions
Returns Promise<EntityData<T>[]>
getClient
Returns MongoClient
getClientUrl
Returns string
getCollection
Type parameters
- T: object
Parameters
name: EntityName<T>
Returns Collection<T>
getConnectionOptions
Returns MongoClientOptions & ConnectionConfig
getDb
Returns Db
getDefaultClientUrl
Returns default client url for given driver (e.g. mongodb://127.0.0.1:27017 for mongodb)
Returns string
getPlatform
Returns Platform
insertMany
Type parameters
- T: object
Parameters
collection: string
data: Partial<T>[]
optionalctx: ClientSession
Returns Promise<QueryResult<T>>
insertOne
Type parameters
- T: object
Parameters
collection: string
data: Partial<T>
optionalctx: ClientSession
Returns Promise<QueryResult<T>>
isConnected
Are we connected to the database
Returns Promise<boolean>
listCollections
Returns Promise<string[]>
rollback
Parameters
ctx: ClientSession
optionaleventBroadcaster: TransactionEventBroadcaster
Returns Promise<void>
setMetadata
Parameters
metadata: MetadataStorage
Returns void
setPlatform
Parameters
platform: Platform
Returns void
transactional
Type parameters
- T
Parameters
cb: (trx: ClientSession) => Promise<T>
options: { ctx?: ClientSession; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel } & TransactionOptions = {}
Returns Promise<T>
updateMany
Type parameters
- T: object
Parameters
collection: string
where: FilterQuery<T>
data: Partial<T>
optionalctx: ClientSession
optionalupsert: boolean
optionalupsertOptions: UpsertOptions<T>
Returns Promise<QueryResult<T>>
Are we connected to the database