@opra/sqb
Version:
Opra SQB adapter package
42 lines (41 loc) • 1.22 kB
TypeScript
import { ServiceBase } from '@opra/core';
import { SqbClient, SqbConnection } from '@sqb/connect';
/**
* @namespace SqbServiceBase
*/
export declare namespace SqbServiceBase {
interface Options {
db?: SqbServiceBase['db'];
}
}
/**
* @class SqbServiceBase
* @template T - The data type class type of the resource
*/
export declare class SqbServiceBase extends ServiceBase {
/**
* Represents a SqbClient or SqbConnection object
*/
db?: (SqbClient | SqbConnection) | ((_this: this) => SqbClient | SqbConnection);
/**
* Constructs a new instance
*
* @param [options] - The options for the service.
* @constructor
*/
constructor(options?: SqbServiceBase.Options);
/**
* Executes the provided function within a transaction.
*
* @param callback - The function to be executed within the transaction.
*/
withTransaction(callback: (connection: SqbConnection, _this: this) => any): Promise<any>;
/**
* Retrieves the database connection.
*
* @protected
*
* @throws {Error} If the context or database is not set.
*/
getConnection(): SqbConnection | SqbClient | Promise<SqbConnection | SqbClient>;
}