@clickhouse/client 1.16.0
New features
- Added support for the new Disposable API (a.k.a the
usingkeyword) (#500)
async function main() {
await using client = await client.query(…);
// some code that can throw
// but thanks to `using` the client will still get closed
// client is also automatically closed here by calling [Symbol.disaposeAsync]
}
Without the new using keyword it is required to wrap the code that might leak expensive resources like sockets and big buffers in try / finally
async function main() {
let client
try {
client = await createClient(…);
// some code that can throw
} finally {
if (client) {
await client.close()
}
}
}