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
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
Parameters
collection: string
where: FilterQuery<T>[]
data: Partial<T>[]
optionalctx: ClientSession
optionalupsert: boolean
optionalupsertOptions: UpsertManyOptions<T, never>
Returns Promise<QueryResult<T>>
checkConnection
Returns Promise<{ ok: true } | { error?: Error; ok: false; 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
Parameters
collection: string
where: FilterQuery<T>
optionalctx: ClientSession
Returns Promise<number>
createCollection
Parameters
name: EntityName<T>
Returns Promise<Collection<T>>
deleteMany
Parameters
collection: string
where: FilterQuery<T>
optionalctx: ClientSession
Returns Promise<QueryResult<T>>
dropCollection
Parameters
name: EntityName<Partial<any>>
Returns Promise<boolean>
inheritedensureConnection
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
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
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
inheritedgetPlatform
Returns Platform
insertMany
Parameters
collection: string
data: Partial<T>[]
optionalctx: ClientSession
Returns Promise<QueryResult<T>>
insertOne
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>
inheritedsetMetadata
Parameters
metadata: MetadataStorage
Returns void
inheritedsetPlatform
Parameters
platform: Platform
Returns void
transactional
Parameters
cb: (trx: ClientSession) => Promise<T>
options: { ctx?: ClientSession; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel } & TransactionOptions = {}
Returns Promise<T>
updateMany
Parameters
collection: string
where: FilterQuery<T>
data: Partial<T>
optionalctx: ClientSession
optionalupsert: boolean
optionalupsertOptions: UpsertOptions<T, never>
Returns Promise<QueryResult<T>>
Are we connected to the database