MongoConnection
Hierarchy
- Connection
- MongoConnection
Index
Constructors
Methods
Constructors
constructor
Parameters
config: Configuration<IDatabaseDriver<Connection>>
optionaloptions: ConnectionOptions
type: ConnectionType = 'write'
Returns MongoConnection
Methods
aggregate
Type parameters
- T: object = any
Parameters
collection: string
pipeline: any[]
optionalctx: ClientSession
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: UpsertOptions<T>
Returns Promise<QueryResult<T>>
close
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>
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
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>>
Closes the database connection (aka disconnect)