smartclickhouse/ts/smartclickhouse.classes.timedatatable.ts

29 lines
1011 B
TypeScript
Raw Normal View History

2022-03-02 15:35:20 +00:00
import * as plugins from './smartclickhouse.plugins';
import { SmartClickHouseDb } from './smartclickhouse.classes.smartclickhouse';
export class TimeDataTable {
2022-03-02 15:44:09 +00:00
public static async getTable (smartClickHouseDbRefArg: SmartClickHouseDb, tableNameArg: string) {
2022-03-02 15:35:20 +00:00
const newTable = new TimeDataTable(smartClickHouseDbRefArg, tableNameArg);
// create table in clickhouse
2022-03-02 15:44:09 +00:00
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;
2022-03-02 15:35:20 +00:00
}
// INSTANCE
public smartClickHouseDbRef: SmartClickHouseDb;
public tableName: string;
2022-03-02 15:44:09 +00:00
constructor(smartClickHouseDbRefArg: SmartClickHouseDb, tableNameArg: string) {
2022-03-02 15:35:20 +00:00
this.smartClickHouseDbRef = smartClickHouseDbRefArg;
this.tableName = tableNameArg;
}
2022-03-02 15:44:09 +00:00
/**
* stores a json and tries to map it to the nested syntax
*/
public async storeJson () {}
2022-03-02 15:35:20 +00:00
}