fix(core): update
This commit is contained in:
@@ -7,8 +7,6 @@ export interface IClickhouseConstructorOptions {
|
||||
password?: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class SmartClickHouseDb {
|
||||
public options: IClickhouseConstructorOptions;
|
||||
public clickhouseClient: plugins.clickhouse.ClickHouseClient;
|
||||
@@ -20,24 +18,25 @@ export class SmartClickHouseDb {
|
||||
/**
|
||||
* starts the connection to the Clickhouse db
|
||||
*/
|
||||
public async start() {
|
||||
console.log(`Connecting to default database first.`)
|
||||
public async start(dropOld = false) {
|
||||
console.log(`Connecting to default database first.`);
|
||||
const defaultClient = new plugins.clickhouse.ClickHouseClient({
|
||||
...this.options,
|
||||
database: 'default'
|
||||
database: 'default',
|
||||
});
|
||||
console.log(`Create database ${this.options.database}, if it does not exist...`);
|
||||
if (dropOld) {
|
||||
await defaultClient.queryPromise(`DROP DATABASE IF EXISTS ${this.options.database}`);
|
||||
}
|
||||
await defaultClient.queryPromise(`CREATE DATABASE IF NOT EXISTS ${this.options.database}`);
|
||||
|
||||
console.log(`Ensured database. Now connecting to wanted database: ${this.options.database}`)
|
||||
console.log(`Ensured database. Now connecting to wanted database: ${this.options.database}`);
|
||||
this.clickhouseClient = new plugins.clickhouse.ClickHouseClient({
|
||||
...this.options,
|
||||
|
||||
});
|
||||
console.log(`trying to ping database...`);
|
||||
const result = await this.clickhouseClient.ping();
|
||||
console.log(`Ping successfull?: ${result}`);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,5 +44,6 @@ export class SmartClickHouseDb {
|
||||
*/
|
||||
public async getTable(tableName: string) {
|
||||
const newTable = TimeDataTable.getTable(this, tableName);
|
||||
return newTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user