QuestDB Node.js Client
Major API improvements, including support for InfluxDB Line Protocol over HTTP.
Breaking change: With the introduction of the HTTP transport it is now mandatory to select the protocol to be used by the client.
Support for the ILP protocol over HTTP transport, as well as the new config string syntax
flush()
call.fromConf()
method provides a convenient way for constructing a Sender
via a configuration string.v2 code example:
const sender = new Sender();
await sender.connect({ port: 9009, host: 'localhost' });
sender.table('tablename').intColumn('id', 0).atNow();
await sender.flush();
await sender.close();
Migrated v3 code:
const sender = Sender.fromConfig('http::addr=localhost:9000');
await sender.table('tablename').intColumn('id', 0).atNow();
await sender.flush();
await sender.close();
Note, that the migrated code uses the HTTP sender instead of the TCP one.
Previous versions of the client required the entire JWK for authentication.
const sender = new Sender({
jwk: {
kid: '<username>',
d: '<private key>'
x: '<public key x>',
y: '<public key y>',
kty: 'EC',
crv: 'P-256'
}
});
Starting with v2.1.0 the client supports a simpler way of authentication, where it is enough to specify only the username and the user's private key.
const sender = new Sender({
auth: {
keyId: '<username>',
token: '<private key>'
}
});
An optional time unit parameter can be passed to timestamp-accepting methods:
const bday = Date.parse('1856-07-10');
sender
.table('inventors')
.symbol('born', 'Austrian Empire')
.timestampColumn('birthday', bday, 'ms') // notice 'ms' here
.intColumn('id', 0)
.stringColumn('name', 'Nicola Tesla')
.at(Date.now(), 'ms'); // notice 'ms' here
The time unit defaults to 'us' (native QuestDB resolution) in both timestampColumn()
and at()
.
Supported values are:
Note: This release contains a breaking change.
at()
does not accept string
type anymore, and number
/BigInt
values are interpreted as microseconds instead of nanoseconds.
The client's API will accept BigInt types wherever a timestamp needs to be passed. The API change is backwards compatible.
TCP keepalive has been enabled for the QuestDB socket connection to avoid disconnects caused by client inactivity. Should work in most cases; if the connection goes through a firewall this solution might not be good enough. In that case users could add empty messages on application layer probably to keep the connection alive. The long term solution is definitely to improve the client further and implement keepalive on ILP protocol level (or whatever will be replacing it in the future).
A new option to pass a custom logging function to the client.
If no logger specified the client will write log messages to console, default logging level is info
.
This release introduces a new option called 'copyBuffer', the option is not set by default. If the option is set the client will create a new buffer for each flush() call with the data belongs to the returned promise. This prevents creating duplicate rows if await is missed when calling flush() or if the calls to flush() are not serialised.
Example:
const sender = new Sender({ copyBuffer: true });
Node.js client for QuestDB.
Connect to QuestDB and ingest data via ILP. Supports TLS encryption and ILP authentication.