@clickhouse/client
Advanced tools
Changelog
0.2.2 (Common, Node.js & Web)
default_format
setting, which allows to perform exec
calls without FORMAT
clause.Changelog
0.2.1 (Common, Node.js & Web)
Date objects in query parameters are now serialized as time-zone-agnostic Unix timestamps (NNNNNNNNNN[.NNN], optionally with millisecond-precision) instead of datetime strings without time zones (YYYY-MM-DD HH:MM:SS[.MMM]). This means the server will receive the same absolute timestamp the client sent even if the client's time zone and the database server's time zone differ. Previously, if the server used one time zone and the client used another, Date objects would be encoded in the client's time zone and decoded in the server's time zone and create a mismatch.
For instance, if the server used UTC (GMT) and the client used PST (GMT-8), a Date object for "2023-01-01 13:00:00 PST" would be encoded as "2023-01-01 13:00:00.000" and decoded as "2023-01-01 13:00:00 UTC" (which is 2023-01-01 05:00:00 PST). Now, "2023-01-01 13:00:00 PST" is encoded as "1672606800000" and decoded as "2023-01-01 21:00:00 UTC", the same time the client sent.
Changelog
0.2.0 (web platform support)
Introduces web client (using native fetch and WebStream APIs) without Node.js modules in the common interfaces. No polyfills are required.
Web client is confirmed to work with Chrome/Firefox/CloudFlare workers.
It is now possible to implement new custom connections on top of @clickhouse/client-common
.
The client was refactored into three packages:
@clickhouse/client-common
: all possible platform-independent code, types and interfaces@clickhouse/client-web
: new web (or non-Node.js env) connection, uses native fetch.@clickhouse/client
: Node.js connection as it was before.Changelog
0.1.1
ClickHouseClientConfigOptions.keep_alive
for more details. Disabled by default.TRACE
log level.const client = createClient({
keep_alive: {
enabled: false,
},
})
const client = createClient({
keep_alive: {
enabled: true,
// should be slightly less than the `keep_alive_timeout` setting in server's `config.xml`
// default is 3s there, so 2500 milliseconds seems to be a safe client value in this scenario
// another example: if your configuration has `keep_alive_timeout` set to 60s, you could put 59_000 here
socket_ttl: 2500,
retry_on_expired_socket: true,
},
})
Changelog
0.1.0
connect_timeout
client setting is removed, as it was unused in the code.command
method is introduced as an alternative to exec
.
command
does not expect user to consume the response stream, and it is destroyed immediately.
Essentially, this is a shortcut to exec
that destroys the stream under the hood.
Consider using command
instead of exec
for DDLs and other custom commands which do not provide any valuable output.Example:
// incorrect: stream is not consumed and not destroyed, request will be timed out eventually
await client.exec('CREATE TABLE foo (id String) ENGINE Memory')
// correct: stream does not contain any information and just destroyed
const { stream } = await client.exec(
'CREATE TABLE foo (id String) ENGINE Memory',
)
stream.destroy()
// correct: same as exec + stream.destroy()
await client.command('CREATE TABLE foo (id String) ENGINE Memory')
Changelog
0.0.16
\N
instead of 'NULL'
string, it is now correctly handled for both null
and explicitly undefined
parameters. See the test scenarios for more details.Changelog
0.0.15