Version: 4.3

Class: MongoConnection

Hierarchy

  • Connection

    MongoConnection

Constructors

constructor

+ new MongoConnection(config: Configuration, options?: ConnectionOptions | undefined, type?: "read" | "write"): MongoConnection

Inherited from MongoConnection.constructor

Defined in packages/core/dist/connections/Connection.d.ts:11

Parameters:

NameType
configConfiguration
options?ConnectionOptions | undefined
type?"read" | "write"

Returns: MongoConnection

Properties

client

Protected client: MongoClient

Overrides void

Defined in packages/mongodb/src/MongoConnection.ts:13


config

Protected Readonly config: Configuration

Inherited from AbstractSqlConnection.config

Defined in packages/core/dist/connections/Connection.d.ts:6


db

Protected db: Db

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


metadata

Protected metadata: MetadataStorage

Inherited from AbstractSqlConnection.metadata

Defined in packages/core/dist/connections/Connection.d.ts:9


options

Protected Optional Readonly options: ConnectionOptions | undefined

Inherited from AbstractSqlConnection.options

Defined in packages/core/dist/connections/Connection.d.ts:7


platform

Protected platform: Platform

Inherited from MongoConnection.platform

Defined in packages/core/dist/connections/Connection.d.ts:10


type

Protected Readonly type: "read" | "write"

Inherited from AbstractSqlConnection.type

Defined in packages/core/dist/connections/Connection.d.ts:8

Methods

aggregate

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

Defined in packages/mongodb/src/MongoConnection.ts:136

Parameters:

NameType
collectionstring
pipelineany[]
ctx?Transaction<ClientSession>

Returns: Promise<any[]>


begin

begin(ctx?: ClientSession): Promise<ClientSession>

Overrides void

Defined in packages/mongodb/src/MongoConnection.ts:168

Parameters:

NameType
ctx?ClientSession

Returns: Promise<ClientSession>


bulkUpdateMany

bulkUpdateMany<T>(collection: string, where: FilterQuery<T>[], data: Partial<T>[], ctx?: Transaction<ClientSession>): Promise<QueryResult>

Defined in packages/mongodb/src/MongoConnection.ts:128

Type parameters:

NameType
T{ _id: any }

Parameters:

NameType
collectionstring
whereFilterQuery<T>[]
dataPartial<T>[]
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>


close

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

Overrides void

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

Parameters:

NameType
force?boolean

Returns: Promise<void>


commit

commit(ctx: ClientSession): Promise<void>

Overrides void

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

Parameters:

NameType
ctxClientSession

Returns: Promise<void>


connect

connect(): Promise<void>

Overrides AbstractSqlConnection.connect

Defined in packages/mongodb/src/MongoConnection.ts:16

Returns: Promise<void>


countDocuments

countDocuments<T>(collection: string, where: FilterQuery<T>, ctx?: Transaction<ClientSession>): Promise<number>

Defined in packages/mongodb/src/MongoConnection.ts:147

Type parameters:

NameType
T{ _id: any }

Parameters:

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

Returns: Promise<number>


createCollection

createCollection(name: EntityName<AnyEntity>): Promise<Collection>

Defined in packages/mongodb/src/MongoConnection.ts:34

Parameters:

NameType
nameEntityName<AnyEntity>

Returns: Promise<Collection>


deleteMany

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

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

Type parameters:

NameType
T{ _id: any }

Parameters:

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

Returns: Promise<QueryResult>


dropCollection

dropCollection(name: EntityName<AnyEntity>): Promise<boolean>

Defined in packages/mongodb/src/MongoConnection.ts:43

Parameters:

NameType
nameEntityName<AnyEntity>

Returns: Promise<boolean>


execute

execute(query: string): Promise<any>

Overrides void

Defined in packages/mongodb/src/MongoConnection.ts:75

Parameters:

NameType
querystring

Returns: Promise<any>


executeQuery

ProtectedexecuteQuery<T>(query: string, cb: () => Promise<T>): Promise<T>

Inherited from AbstractSqlConnection.executeQuery

Defined in packages/core/dist/connections/Connection.d.ts:38

Type parameters:

Name
T

Parameters:

NameType
querystring
cb() => Promise<T>

Returns: Promise<T>


find

find<T>(collection: string, where: FilterQuery<T>, orderBy?: QueryOrderMap, limit?: number, offset?: number, fields?: string[], ctx?: Transaction<ClientSession>): Promise<EntityData<T>[]>

Defined in packages/mongodb/src/MongoConnection.ts:79

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
collectionstring
whereFilterQuery<T>
orderBy?QueryOrderMap
limit?number
offset?number
fields?string[]
ctx?Transaction<ClientSession>

Returns: Promise<EntityData<T>[]>


getClientUrl

getClientUrl(): string

Overrides AbstractSqlConnection.getClientUrl

Defined in packages/mongodb/src/MongoConnection.ts:63

Returns: string


getCollection

getCollection(name: EntityName<AnyEntity>): Collection

Defined in packages/mongodb/src/MongoConnection.ts:30

Parameters:

NameType
nameEntityName<AnyEntity>

Returns: Collection


getCollectionName

PrivategetCollectionName(name: EntityName<AnyEntity>): string

Defined in packages/mongodb/src/MongoConnection.ts:254

Parameters:

NameType
nameEntityName<AnyEntity>

Returns: string


getConnectionOptions

getConnectionOptions(): MongoClientOptions & ConnectionConfig

Overrides AbstractSqlConnection.getConnectionOptions

Defined in packages/mongodb/src/MongoConnection.ts:51

Returns: MongoClientOptions & ConnectionConfig


getDb

getDb(): Db

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

Returns: Db


getDefaultClientUrl

getDefaultClientUrl(): string

Overrides AbstractSqlConnection.getDefaultClientUrl

Defined in packages/mongodb/src/MongoConnection.ts:47

Returns: string


insertMany

insertMany<T>(collection: string, data: Partial<T>[], ctx?: Transaction<ClientSession>): Promise<QueryResult>

Defined in packages/mongodb/src/MongoConnection.ts:120

Type parameters:

NameType
T{ _id: any }

Parameters:

NameType
collectionstring
dataPartial<T>[]
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>


insertOne

insertOne<T>(collection: string, data: Partial<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult>

Defined in packages/mongodb/src/MongoConnection.ts:116

Type parameters:

NameType
T{ _id: any }

Parameters:

NameType
collectionstring
dataPartial<T>
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>


isConnected

isConnected(): Promise<boolean>

Overrides void

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

Returns: Promise<boolean>


listCollections

listCollections(): Promise<string[]>

Defined in packages/mongodb/src/MongoConnection.ts:38

Returns: Promise<string[]>


logObject

PrivatelogObject(o: any): string

Defined in packages/mongodb/src/MongoConnection.ts:261

Parameters:

NameType
oany

Returns: string


logQuery

ProtectedlogQuery(query: string, took?: number): void

Overrides void

Defined in packages/mongodb/src/MongoConnection.ts:186

Parameters:

NameType
querystring
took?number

Returns: void


rollback

rollback(ctx: ClientSession): Promise<void>

Overrides void

Defined in packages/mongodb/src/MongoConnection.ts:181

Parameters:

NameType
ctxClientSession

Returns: Promise<void>


runQuery

PrivaterunQuery<T, U>(method: "insertOne" | "insertMany" | "updateMany" | "bulkUpdateMany" | "deleteMany" | "countDocuments", collection: string, data?: Partial<T> | Partial<T>[], where?: FilterQuery<T> | FilterQuery<T>[], ctx?: Transaction<ClientSession>): Promise<U>

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

Type parameters:

NameTypeDefault
T{ _id: any }-
UQueryResult | numberQueryResult

Parameters:

NameType
method"insertOne" | "insertMany" | "updateMany" | "bulkUpdateMany" | "deleteMany" | "countDocuments"
collectionstring
data?Partial<T> | Partial<T>[]
where?FilterQuery<T> | FilterQuery<T>[]
ctx?Transaction<ClientSession>

Returns: Promise<U>


setMetadata

setMetadata(metadata: MetadataStorage): void

Inherited from AbstractSqlConnection.setMetadata

Defined in packages/core/dist/connections/Connection.d.ts:36

Parameters:

NameType
metadataMetadataStorage

Returns: void


setPlatform

setPlatform(platform: Platform): void

Inherited from AbstractSqlConnection.setPlatform

Defined in packages/core/dist/connections/Connection.d.ts:37

Parameters:

NameType
platformPlatform

Returns: void


transactional

transactional<T>(cb: (trx: Transaction<ClientSession>) => Promise<T>, ctx?: Transaction<ClientSession>): Promise<T>

Overrides void

Defined in packages/mongodb/src/MongoConnection.ts:151

Type parameters:

Name
T

Parameters:

NameType
cb(trx: Transaction<ClientSession>) => Promise<T>
ctx?Transaction<ClientSession>

Returns: Promise<T>


transformResult

PrivatetransformResult(res: any): QueryResult

Defined in packages/mongodb/src/MongoConnection.ts:245

Parameters:

NameType
resany

Returns: QueryResult


updateMany

updateMany<T>(collection: string, where: FilterQuery<T>, data: Partial<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult>

Defined in packages/mongodb/src/MongoConnection.ts:124

Type parameters:

NameType
T{ _id: any }

Parameters:

NameType
collectionstring
whereFilterQuery<T>
dataPartial<T>
ctx?Transaction<ClientSession>

Returns: Promise<QueryResult>

Last updated on by Martin Adámek