node-clickhouse icon indicating copy to clipboard operation
node-clickhouse copied to clipboard

We are getting types issues when using with typescript.

Open awais-satti opened this issue 4 years ago • 1 comments

Do you guys have types available for the extension?

awais-satti avatar May 06 '21 09:05 awais-satti

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;
}

depyronick avatar Jul 01 '21 10:07 depyronick