/** * @athenna/database * * (c) João Lenon * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import type { Knex } from 'knex'; import { Macroable } from '@athenna/common'; import type { Driver } from '#src/database/drivers/Driver'; import { QueryBuilder } from '#src/database/builders/QueryBuilder'; export declare class Transaction extends Macroable { /** * The drivers responsible for handling database operations. */ driver: Driver; /** * Creates a new instance of transaction. */ constructor(driver: Driver); /** * Return the client of driver. */ getClient(): Client; /** * Return the query builder of driver. */ getQueryBuilder(): QB; /** * Commit the transaction. */ commitTransaction(): Promise; /** * Rollback the transaction. */ rollbackTransaction(): Promise; /** * Run database migrations. */ runMigrations(): Promise; /** * Revert database migrations. */ revertMigrations(): Promise; /** * List all databases available. */ getDatabases(): Promise; /** * Get the current database name. */ getCurrentDatabase(): Promise; /** * Verify if database exists. */ hasDatabase(database: string): Promise; /** * Create a new database. */ createDatabase(database: string): Promise; /** * Drop some database. */ dropDatabase(database: string): Promise; /** * List all tables available. */ getTables(): Promise; /** * Verify if table exists. */ hasTable(table: string): Promise; /** * Create a new table in database. */ createTable(table: string, closure?: (builder: Knex.TableBuilder) => void | Promise): Promise; /** * Alter a table in database. */ alterTable(table: string, closure?: (builder: Knex.TableBuilder) => void | Promise): Promise; /** * Drop a table in database. */ dropTable(table: string): Promise; /** * Remove all data inside some database table * and restart the identity of the table. */ truncate(table: string): Promise; /** * Make a raw query in database. */ raw(sql: string, bindings?: any): Knex.Raw; /** * Creates a new instance of QueryBuilder for this table. */ table(table: string | any): QueryBuilder; }