Class ClickhouseConnector

Description

Clickhouse connector

Features:

  • connector manager for Clickhouse

Example

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { ClickhouseConnector, ClickhouseConfig } from '@biorate/clickhouse';

class Root extends Core() {
@inject(ClickhouseConnector) public connector: ClickhouseConnector;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<ClickhouseConnector>(ClickhouseConnector).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
Clickhouse: [
{
name: 'connection',
options: {
},
},
],
});

(async () => {
const root = container.get<Root>(Root);
await root.$run();
const cursor = await root.connector
.get()
.query({ query: 'SELECT 1 AS result;', format: 'JSON' });
const { data } = await cursor.json<{ result: number }>();
console.log(data); // [{ result: 1 }]
})();

Hierarchy

Constructors

Properties

#connections: Map<string, ClickHouseClient>

Description

Private connections storage

#connections: Map<string, ClickHouseClient> = ...

Description

Private connections storage

Description

Private link to selected (used) connection

#current: ClickHouseClient = undefined

Description

Private link to selected (used) connection

config: IConfig

Description

Config dependency

namespace: "Clickhouse" = 'Clickhouse'

Description

Namespace path for fetching configuration

Accessors

Methods

Generated using TypeDoc