@iarayan/ch-orm
Version:
A Developer-First ClickHouse ORM with Powerful CLI Tools
106 lines • 3.19 kB
TypeScript
import { ConnectionConfig, QueryOptions, QueryResult } from "../types/connection";
/**
* Connection class for managing connections to a ClickHouse server
* Handles query execution and manages connection state
*/
export declare class Connection {
/**
* Configuration for this connection
*/
private config;
/**
* Base URL for ClickHouse HTTP interface
*/
private baseUrl;
/**
* HTTP module to use (http or https)
*/
private httpModule;
/**
* Default query options
*/
private defaultQueryOptions;
/**
* Create a new ClickHouse connection
* @param config - Connection configuration
*/
constructor(config: Partial<ConnectionConfig>);
/**
* Execute a raw SQL query
* @param sql - SQL query to execute
* @param options - Query options
* @returns Query result
*/
query<T = any>(sql: string, options?: QueryOptions): Promise<QueryResult<T>>;
/**
* Execute a parameterized query with values
* @param sql - SQL query with placeholders (?)
* @param params - Parameter values
* @param options - Query options
* @returns Query result
*/
execute<T = any>(sql: string, params?: any[], options?: QueryOptions): Promise<QueryResult<T>>;
/**
* Execute a simple INSERT query
* @param table - Table name
* @param data - Data to insert (object or array of objects)
* @param options - Query options
* @returns Query result
*/
insert<T = any>(table: string, data: Record<string, any> | Record<string, any>[], options?: QueryOptions): Promise<QueryResult<T>>;
/**
* Execute a HTTP request to ClickHouse
* @param url - Request URL
* @param body - Request body (SQL query)
* @returns Query result
*/
private executeRequest;
/**
* Ping the ClickHouse server to test the connection
* @returns True if connected successfully
*/
ping(): Promise<boolean>;
/**
* Get information about the ClickHouse server
* @returns Server information
*/
serverInfo(): Promise<any>;
/**
* List databases on the ClickHouse server
* @returns Array of database names
*/
listDatabases(): Promise<string[]>;
/**
* List tables in the current database
* @returns Array of table names
*/
listTables(): Promise<string[]>;
/**
* Get table schema information
* @param table - Table name
* @returns Table schema information
*/
describeTable(table: string): Promise<any[]>;
/**
* Create a new database
* @param database - Database name
* @returns Query result
*/
createDatabase(database: string): Promise<QueryResult>;
/**
* Drop a database
* @param database - Database name
* @returns Query result
*/
dropDatabase(database: string): Promise<QueryResult>;
/**
* Get the current connection configuration
* @returns Connection configuration
*/
getConfig(): ConnectionConfig;
/**
* Close the connection and release resources
*/
close(): Promise<void>;
}
//# sourceMappingURL=Connection.d.ts.map