2 Commits

Author SHA1 Message Date
b8d929f4de 1.0.3 2022-03-02 13:20:19 +01:00
cbc7b5a4a7 fix(core): update 2022-03-02 13:20:18 +01:00
4 changed files with 26 additions and 7 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@pushrocks/smartclickhouse", "name": "@pushrocks/smartclickhouse",
"version": "1.0.2", "version": "1.0.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@pushrocks/smartclickhouse", "name": "@pushrocks/smartclickhouse",
"version": "1.0.2", "version": "1.0.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"clickhouse": "^2.4.4" "clickhouse": "^2.4.4"

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartclickhouse", "name": "@pushrocks/smartclickhouse",
"version": "1.0.2", "version": "1.0.3",
"private": false, "private": false,
"description": "an odm for talking to clickhouse", "description": "an odm for talking to clickhouse",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@ -15,7 +15,7 @@ tap.test('should start the clickhouse db', async () => {
}) })
tap.test('should write something to the clickhouse db', async () => { tap.test('should write something to the clickhouse db', async () => {
const result = await testClickhouseDb.clickhouseClient.query(`CREATE DATABASE IF NOT EXISTS lossless`); const result = await testClickhouseDb.clickhouseClient.query(`CREATE DATABASE IF NOT EXISTS lossless`).toPromise();
console.log(result); console.log(result);
const result2 = await testClickhouseDb.clickhouseClient.query(`CREATE TABLE IF NOT EXISTS lossless.visits ( const result2 = await testClickhouseDb.clickhouseClient.query(`CREATE TABLE IF NOT EXISTS lossless.visits (
timestamp UInt64, timestamp UInt64,
@ -23,8 +23,23 @@ tap.test('should write something to the clickhouse db', async () => {
os String, os String,
userAgent String, userAgent String,
version String version String
)`); ) ENGINE=MergeTree() ORDER BY timestamp`).toPromise();
console.log(result); console.log(result2);
const ws = testClickhouseDb.clickhouseClient.insert('INSERT INTO lossless.visits FORMAT JSONEachRow').stream();
for(let i = 0; i <= 1000; i++) {
await ws.writeRow(
JSON.stringify({
timestamp: Date.now(),
ip: '127.0.01',
os: 'Mac OS X',
userAgent: 'some',
version: 'someversion'
})
);
}
//wait stream finish
const result3 = await ws.exec();
}) })
tap.start(); tap.start();

View File

@ -17,6 +17,10 @@ export class ClickhouseDb {
* starts the connection to the Clickhouse db * starts the connection to the Clickhouse db
*/ */
public start() { public start() {
this.clickhouseClient = new plugins.clickhouse.ClickHouse(this.options); this.clickhouseClient = new plugins.clickhouse.ClickHouse({
...this.options,
basicAuth: null,
format: 'json'
});
} }
} }