interface DatabaseContract {
    manager: ConnectionManagerContract;
    primaryConnectionName: string;
    connection(connectionName?: string): ConnectionContract;
    transaction<TResult>(
        handler: (client: ClientSession, db: Db) => Promise<TResult>,
        options?: TransactionOptions,
    ): Promise<TResult>;
}

Properties

Connection manager.

primaryConnectionName: string

Name of the primary connection defined inside config/mongodb.ts.

Methods

  • Shortcut to Database.connection().transaction()

    Type Parameters

    • TResult

    Parameters

    • handler: (client: ClientSession, db: Db) => Promise<TResult>
    • Optionaloptions: TransactionOptions

    Returns Promise<TResult>