Fastify ClickHouse connection plugin
npm i fastify-clickhouse --save
# or
yarn add fastify-clickhouse
Add it to your project with register
and you are done!
const fastify = require('fastify')()
fasttify.register(require('fastify-clickhouse'), {
url: 'http://localhost',
port: 8123,
debug: false,
basicAuth: null,
isUseGzip: false,
format: "json", // "json" || "csv" || "tsv"
config: {
session_id : 'session_id if neeed',
session_timeout : 60,
output_format_json_quote_64bit_integers : 0,
enable_http_compression : 0,
database : 'my_database_name',
},
});
fastify.get('/user/:id', function (req, reply) {
const clickhouse = fastify.clickhouse()
await clickhouse.query().exect()
})
fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${address}`)
})
This project is kindly sponsored by:
Licensed under MIT.