clickhouse-buffer
v2.3.0
Published
```shell yarn add clickhouse-buffer # or npm install clickhouse-buffer ```
Downloads
40
Maintainers
Readme
clickhouse-buffer
Install
yarn add clickhouse-buffer
# or
npm install clickhouse-buffer
How to use
import {ClickhouseBuffer, DEFAULT_DATABASE} from "clickhouse-buffer";
(async () => {
const database = DEFAULT_DATABASE;
const table = 'events';
const directoryPath = await ClickhouseBuffer.prepareDirectoryPath('buffer', database, table, 0o777);
const clickhouseBuffer = new ClickhouseBuffer({
directoryPath,
database,
table
});
await clickhouseBuffer.clickhouseClient.query(`CREATE TABLE IF NOT EXISTS ${database}.${table} (id UInt16) ENGINE = MergeTree() ORDER BY id`);
await clickhouseBuffer.loadFilesToDatabase();
for (let i = 0; i <= 9; i++) {
clickhouseBuffer.push([i]);
}
setTimeout(() => {
for (let i = 10; i <= 19; i++) {
clickhouseBuffer.push([i]);
}
}, 5000)
setTimeout(() => {
clickhouseBuffer.release();
}, 15000);
})();