2.0.4 • Published 2 years ago

clickhouse-ts v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Travis (.org) Libraries.io dependency status for GitHub repo npms.io (final) GitHub issues Join the chat at https://gitter.im/bytadaniel/clickhouse-ts GitHub followers

Introduction

💙 Typescript

This package is written in TypeScript because Node.js typing development is already an industry standard.

🖐 Batch insert*

It has been empirically verified that in-memory collecting rows is the most efficient and consistent way to insert into Clickhouse. To work with built-in caching, you just need to call the useCaching() method

💪 Transparent and Stability

clickhouse-ts doesn't use a lot of abstractions and dependencies, so it's fast and stable.

🏗 Ready for production

The Lookforsale team has been using clickhouse-ts effectively for over a year under extreme loads!

👍 Batch validation

Double checking data for anomalies during in-memory caching and when inserting a finished batch.

✨ Flexibility

Flexible configuration of the Clickhouse client instance and support for all features provided by Clickhouse developers.

🔐 Security

SQL Injection Protection with sqlstring

🌈 Free for use

The package has a public license and is available for download to any developer!## Installation

Installation

npm i clickhouse-ts
npm i clickcache

*How can I insert in-memory batches?

Starting from version 2.0.0 the caching module 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, as in Joi and model generation, as in mongodb/mongoose.

Connection

Only HTTP(s) protocol is supported.

const client = new Clickhouse(
  {
    url: 'url',
    port: 8443,
    user: 'user',
    password: 'password',
    database: 'database',
    ca: fs.readFileSync('cert.crt')
  },
  {
	/* https://clickhouse.com/docs/en/interfaces/formats */  
    defaultResponseFormat: 'JSON',
    clickhouseOptions: {
      /* https://clickhouse.tech/docs/en/operations/settings/settings/ */
      send_progress_in_http_headers: '1'
    }
  }
)

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

const response = await client.insert('table_strings', rows, {
  format: 'CSVWithNames'
})

Select

await clickhouseInstance.query<{ t: string }>('WITH now() as t SELECT t', {
  format: 'TSV',
  send_progress_in_http_headers: '1'
})

DDL queries

await clickhouseInstance.query(`
  CREATE TABLE strings (
    date DateTime('UTC'),
    string String
  ) Engine = ReplacingMergeTree()
  PARTITION BY toMonday(date)
  ORDER BY (date, string)
`, { noFormat: true })
1.8.1

2 years ago

1.8.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.11.0

2 years ago

1.11.1

2 years ago

1.9.0

2 years ago

1.7.0

2 years ago

1.10.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.2

2 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.18

3 years ago

1.3.19

3 years ago

1.3.17

3 years ago

1.3.16

3 years ago

1.3.14

3 years ago

1.3.15

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.3.10

3 years ago

1.3.13

3 years ago

1.3.11

3 years ago

1.3.12

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.2.0

3 years ago

1.1.19

3 years ago

1.1.18

3 years ago

1.1.17

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago