clickhouse-ts
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"license": "MIT", | ||
@@ -13,0 +13,0 @@ "description": "Light stable Clickhouse client", |
@@ -1,3 +0,8 @@ | ||
# clickhouse-ts by @bytadaniel | ||
<p align="center"> | ||
<img src="https://cdn.worldvectorlogo.com/logos/clickhouse.svg" width="200px" align="center"> | ||
<h2 align="center">ClickHouse TypeScript client by @bytadaniel</h2> | ||
</p> | ||
<br/> | ||
![Travis (.org)](https://img.shields.io/travis/bytadaniel/clickhouse-ts) | ||
@@ -7,13 +12,6 @@ ![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/bytadaniel/clickhouse-ts) | ||
![GitHub issues](https://img.shields.io/github/issues/bytadaniel/clickhouse-ts) | ||
[![Join the chat at https://gitter.im/bytadaniel/clickhouse-ts](https://badges.gitter.im/bytadaniel/clickhouse-ts.svg)](https://gitter.im/bytadaniel/clickhouse-ts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
![GitHub followers](https://img.shields.io/github/followers/bytadaniel?style=social) | ||
#### Select, insert in-memory batches safely and enjoy Clickhouse! | ||
### Hello from [LookFor.sale](https://lookforsale.ru) developer which produces WB Analytics! | ||
![Backers on Open Collective](https://lookforsale.ru/wp-content/uploads/2021/06/lfsw.jpg) | ||
## TS client for clickhouse database with using in-memory caching rows for batch insertion | ||
## Introduction | ||
### 💙 Typescript | ||
@@ -34,13 +32,19 @@ This package is written in TypeScript because Node.js typing development is already an industry standard. | ||
### 🌈 Free for use | ||
The package has a public license and is available for download to any developer! | ||
The package has a public license and is available for download to any developer!## Installation | ||
## Installation | ||
```bash | ||
npm i clickhouse-ts | ||
npm i clickcache | ||
``` | ||
## *How can I insert in-memory batches? | ||
Starting from version 2.0.0 [the caching module](https://www.npmjs.com/package/clickcache) should be imported separately. | ||
Starting from version `2.0.0` [the caching module](https://www.npmjs.com/package/clickcache) should be imported separately. | ||
This is because clickcache package, like clickhouse-ts, is going to be part of my Clickhouse Node.js ecosystem. | ||
In addition, it planned to introduce [data validation](https://www.npmjs.com/package/chvalid), as in Joi and model generation, as in mongodb/mongoose. | ||
## Connection | ||
Only HTTP(s) protocol is supported. | ||
## Usage | ||
```js | ||
```ts | ||
const client = new Clickhouse( | ||
@@ -56,2 +60,3 @@ { | ||
{ | ||
/* https://clickhouse.com/docs/en/interfaces/formats */ | ||
defaultResponseFormat: 'JSON', | ||
@@ -64,10 +69,10 @@ clickhouseOptions: { | ||
) | ||
``` | ||
## Usage examples | ||
Basically, this client supports data insertion, but you should consider collecting your data before passing it as an argument here. Use `clickcache` to prepare batches! | ||
## Insert | ||
```js | ||
```ts | ||
const response = await client.insert('table_strings', rows, { | ||
responseFormat: 'CSVWithNames' // or other format | ||
// other query options | ||
format: 'CSVWithNames' | ||
}) | ||
@@ -77,11 +82,11 @@ ``` | ||
## Select | ||
```js | ||
```ts | ||
await clickhouseInstance.query<{ t: string }>('WITH now() as t SELECT t', { | ||
responseFormat: 'TSV', | ||
// ...other query options | ||
format: 'TSV', | ||
send_progress_in_http_headers: '1' | ||
}) | ||
``` | ||
## Create | ||
```js | ||
## DDL queries | ||
```ts | ||
await clickhouseInstance.query(` | ||
@@ -94,3 +99,3 @@ CREATE TABLE strings ( | ||
ORDER BY (date, string) | ||
`) | ||
``` | ||
`, { noFormat: true }) | ||
``` |
Sorry, the diff of this file is too big to display
214342
95