Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
clickhouse-ts
Advanced tools
import { Clickhouse } from 'clickhouse-ts'
import fs from 'fs'
import dayjs from 'dayjs'
import { serializeError } from 'serialize-error'
import Redis from 'ioredis' // for correct work use only this package
const clickhouseInstance = new Clickhouse(
{
url: 'url',
port: 8443,
user: 'user',
password: 'password',
database: 'database',
ca: fs.readFileSync('cert.crt')
},
{
cache: { // cache can be undefined
chunkTTLSeconds: 3600,
/* after this time chunk will be completed */
chunkResolverIntervalSeconds: 180,
/* interval of checking chunks */
chunkSizeLimit: 10_000,
/* count of rows in one chunk */
chunkResolveType: 'events'
/*
'events': on completed chunk emits event 'chunk'. You can save rows as you want
'autoInsert': on completed chunk inserts rows automatically
*/
},
defaultResponseFormat: 'JSON',
clickhouseOptions: {
/*
any clickhouse options
https://clickhouse.tech/docs/en/operations/settings/settings/
*/
send_progress_in_http_headers: '1'
}
}
)
await clickhouseInstance.useCaching('redis', new Redis())
clickhouseInstance.onChunk((chunkId, table, rows) => {
// do want you want
})
clickhouseInstance
.query('WITH now() as t SELECT t', {
responseFormat: 'TSV',
// ...another query options
})
.then(result => result.data.data)
.catch(e => serializeError(e))
clickhouseInstance.query(`
CREATE TABLE strings (
date DateTime('UTC'),
string String
) Engine = ReplacingMergeTree()
PARTITION BY toMonday(date)
ORDER BY (date, string)
`)
const response = clickhouseInstance
.cache(
'strings',
[{ date: '2021-01-01', string: 'str1' }, { date: '2021-01-02', string: 'str2' }],
{
responseFormat: 'CSVWithNames' // or another format
// another query options
}
)
.then(response => response)
.catch(e => serializeError(e))
response
/*
{
cached: 2,
chunk: 'strings-1624746778066-4ebdfda07dc6e73a73a3c87490b8ebf0'
}
*/
const response = clickhouseInstance
.insert(
'strings',
[{ date: '2021-01-01', string: 'str1' }, { date: '2021-01-02', string: 'str2' }],
{
responseFormat: 'CSVWithNames' // or another format
// another query options
}
)
.then(response => response)
.catch(e => serializeError(e))
response
/*
{
inserted: 2,
data: [...rows]
}
*/
FAQs
Light stable Clickhouse client
The npm package clickhouse-ts receives a total of 164 weekly downloads. As such, clickhouse-ts popularity was classified as not popular.
We found that clickhouse-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.