/** * @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 { Operations } from '#src/types'; import { BaseKnexDriver } from '#src/database/drivers/BaseKnexDriver'; import type { ConnectionOptions } from '#src/types/ConnectionOptions'; import { CheckViolationException } from '#src/exceptions/CheckViolationException'; import { UniqueViolationException } from '#src/exceptions/UniqueViolationException'; import { NotNullViolationException } from '#src/exceptions/NotNullViolationException'; import { ForeignKeyViolationException } from '#src/exceptions/ForeignKeyViolationException'; export declare class PostgresDriver extends BaseKnexDriver { /** * Connect to database. */ connect(options?: ConnectionOptions): void; /** * Close the connection with database in this instance. */ close(): Promise; /** * List all databases available. */ getDatabases(): Promise; /** * Create a new database. */ createDatabase(database: string): Promise; /** * Drop some database. */ dropDatabase(database: string): Promise; /** * List all tables available. */ getTables(): Promise; /** * Remove all data inside some database table * and restart the identity of the table. */ truncate(table: string): Promise; /** * Create many values in database. */ createMany(data?: Partial[]): Promise; whereJson(column: string, value: any): this; whereJson(column: string, operation: Operations, value: any): this; orWhereJson(column: string, value: any): this; orWhereJson(column: string, operation: Operations, value: any): this; /** * Convert a json selector path to a valid postgres json path. */ private parseJsonSelectorToWildcardPath; /** * Normalize operator/value pair for postgres json path comparisons. */ private normalizeJsonOperation; /** * Convert query operators to postgres json path operators. */ private getJsonPathOperator; /** * Translate a PostgreSQL error (SQLSTATE codes) into a normalized Athenna * constraint violation exception. * * @see https://www.postgresql.org/docs/current/errcodes-appendix.html */ parseError(error: any): UniqueViolationException | CheckViolationException | NotNullViolationException | ForeignKeyViolationException; }