apla / node-clickhouse

Yandex ClickHouse driver for nodejs
MIT License
216 stars 50 forks source link

We are getting types issues when using with typescript. #77

Open awais-satti opened 3 years ago

awais-satti commented 3 years ago

Do you guys have types available for the extension?

depyronick commented 3 years ago

something... like this...

declare module "@apla/clickhouse" {
    import { Duplex } from 'stream';

    interface ClickHouseOptions {
        host?: string;
        user?: string;
        password?: string;
        dataObjects?: boolean;
        path?: string;
        format?: string;
        readonly?: boolean;
        queryOptions?: { [key: string]: any };
    }

    interface Meta {
        name: string;
        type: string;
    }

    interface Statistics {
        elapsed: number;
        rows_read: number;
        bytes_read: number;
        transferred: number;
    }

    interface QueryingResult {
        meta: Meta[];
        data: any[];
        rows: number;
        statistics: Statistics
    }

    interface ClickHouse {
        new(opts: ClickHouseOptions): this;

        query(query: string, options?: ClickHouseOptions, callback?: (error, result) => void): Duplex;
        querying(query: string, options?: ClickHouseOptions): Promise<QueryingResult>;
        ping(callback: (error: any, result: any) => void): Duplex;
        pinging(): Promise<any>
    }

    const ClickHouse: ClickHouse;

    export = ClickHouse;
}