UNPKG

@iarayan/ch-orm

Version:

A Developer-First ClickHouse ORM with Powerful CLI Tools

138 lines 5.4 kB
import { Connection } from "../connection/Connection"; import { Blueprint } from "./Blueprint"; /** * Schema class for managing database schema * Used for creating and modifying tables, views, and other database objects */ export declare class Schema { /** * Database connection */ private connection; /** * Create a new Schema instance * @param connection - ClickHouse connection */ constructor(connection: Connection); /** * Create a new table * @param table - Table name * @param callback - Callback function to define table structure using Blueprint * @returns Promise that resolves when the table is created */ create(table: string, callback: (blueprint: Blueprint) => void): Promise<void>; /** * Drop a table * @param table - Table name * @param ifExists - Whether to include IF EXISTS in the query * @returns Promise that resolves when the table is dropped */ drop(table: string, ifExists?: boolean): Promise<void>; /** * Drop a table if it exists and create a new one * @param table - Table name * @param callback - Callback function to define table structure using Blueprint * @returns Promise that resolves when the table is recreated */ createOrReplace(table: string, callback: (blueprint: Blueprint) => void): Promise<void>; /** * Check if a table exists * @param table - Table name * @returns Promise that resolves to true if the table exists, false otherwise */ hasTable(table: string): Promise<boolean>; /** * Get information about a table * @param table - Table name * @returns Promise that resolves to table information or null if not found */ getTable(table: string): Promise<any | null>; /** * Get all columns in a table * @param table - Table name * @returns Promise that resolves to array of column information */ getColumns(table: string): Promise<any[]>; /** * Check if a column exists in a table * @param table - Table name * @param column - Column name * @returns Promise that resolves to true if the column exists, false otherwise */ hasColumn(table: string, column: string): Promise<boolean>; /** * Create a materialized view * @param viewName - View name * @param selectQuery - SELECT query for the view * @param toTable - Target table (optional) * @param engine - Engine for the view (if not using TO table) * @returns Promise that resolves when the view is created */ createMaterializedView(viewName: string, selectQuery: string, toTable?: string, engine?: string): Promise<void>; /** * Drop a materialized view * @param viewName - View name * @param ifExists - Whether to include IF EXISTS in the query * @returns Promise that resolves when the view is dropped */ dropMaterializedView(viewName: string, ifExists?: boolean): Promise<void>; /** * Create a view * @param viewName - View name * @param selectQuery - SELECT query for the view * @returns Promise that resolves when the view is created */ createView(viewName: string, selectQuery: string): Promise<void>; /** * Drop a view * @param viewName - View name * @param ifExists - Whether to include IF EXISTS in the query * @returns Promise that resolves when the view is dropped */ dropView(viewName: string, ifExists?: boolean): Promise<void>; /** * Create a dictionary * @param dictionaryName - Dictionary name * @param structure - Dictionary structure * @param source - Dictionary source * @param layout - Dictionary layout * @param lifetime - Dictionary lifetime * @returns Promise that resolves when the dictionary is created */ createDictionary(dictionaryName: string, structure: string, source: string, layout: string, lifetime: string): Promise<void>; /** * Drop a dictionary * @param dictionaryName - Dictionary name * @param ifExists - Whether to include IF EXISTS in the query * @returns Promise that resolves when the dictionary is dropped */ dropDictionary(dictionaryName: string, ifExists?: boolean): Promise<void>; /** * Create a database * @param databaseName - Database name * @param ifNotExists - Whether to include IF NOT EXISTS in the query * @returns Promise that resolves when the database is created */ createDatabase(databaseName: string, ifNotExists?: boolean): Promise<void>; /** * Drop a database * @param databaseName - Database name * @param ifExists - Whether to include IF EXISTS in the query * @returns Promise that resolves when the database is dropped */ dropDatabase(databaseName: string, ifExists?: boolean): Promise<void>; /** * Execute raw SQL * @param sql - SQL query * @returns Promise that resolves with the query result */ raw(sql: string): Promise<any>; /** * Alter a table * @param table - Table name * @param callback - Callback function to define table alterations using Blueprint * @returns Promise that resolves when the table is altered */ alter(table: string, callback: (blueprint: Blueprint) => void): Promise<void>; } //# sourceMappingURL=Schema.d.ts.map