smartclickhouse/ts/smartclickhouse.classes.timedatatable.ts
2022-03-02 16:44:09 +01:00

29 lines
1011 B
TypeScript

import * as plugins from './smartclickhouse.plugins';
import { SmartClickHouseDb } from './smartclickhouse.classes.smartclickhouse';
export class TimeDataTable {
public static async getTable (smartClickHouseDbRefArg: SmartClickHouseDb, tableNameArg: string) {
const newTable = new TimeDataTable(smartClickHouseDbRefArg, tableNameArg);
// create table in clickhouse
await smartClickHouseDbRefArg.clickhouseClient.queryPromise(`CREATE TABLE IF NOT EXISTS ${newTable.tableName} (
timestamp DateTime64(3, 'Europe/Berlin'),
message String
) ENGINE=MergeTree() ORDER BY timestamp`);
return newTable;
}
// INSTANCE
public smartClickHouseDbRef: SmartClickHouseDb;
public tableName: string;
constructor(smartClickHouseDbRefArg: SmartClickHouseDb, tableNameArg: string) {
this.smartClickHouseDbRef = smartClickHouseDbRefArg;
this.tableName = tableNameArg;
}
/**
* stores a json and tries to map it to the nested syntax
*/
public async storeJson () {}
}