skaidb — Node.js / TypeScript driver
Download: skaidb-driver-nodejs-0.234.0.tar.gz — unpacks to
skaidb-driver-nodejs/.
API modeled on node-postgres (pg). If you've
used pg, this is the same shape: new Client(...), await client.query(...),
{ rows, rowCount, fields }. Zero dependencies — pure net + crypto.
Ships with TypeScript types.
Install
npm install ./skaidb-driver-nodejs # unpacked from the tarball above
# or copy skaidb.js (+ skaidb.d.ts) into your project
Use
const { Client } = require('skaidb');
const client = new Client({
host: 'localhost', port: 7000,
user: 'skaidb', password: 'secret',
});
await client.connect();
await client.query('CREATE TABLE users (PRIMARY KEY (id))');
await client.query('INSERT INTO users (id, name) VALUES ($1, $2)', [1, 'Ada']);
const res = await client.query('SELECT id, name FROM users WHERE id = $1', [1]);
console.log(res.rows); // [ { id: 1, name: 'Ada' } ]
console.log(res.rowCount); // 1
await client.end();
TypeScript works out of the box:
import { Client, QueryResult } from 'skaidb';
const client = new Client({ host, port, user, password });
- Placeholders use
$1, $2, …(pg style). Parameters are safely quoted client-side, so"O'Brien"is fine. - Rows are objects keyed by column name by default. Pass
{ text, rowMode: 'array' }for array rows (likepg). - Queries on one client are serialized (one request/response in flight); open
multiple
Clients for concurrency, or reconnect per worker.
Failover
new Client({ seeds: ['db1:7000', 'db2:7000', 'db3:7000'], user, password });
Tried in shuffled order until one connects and authenticates. skaidb is leaderless, so any node serves.
TLS
new Client({ ..., tlsCa: '/etc/skaidb/skai-ca.crt' }); // verify against a CA
new Client({ ..., tlsInsecure: true }); // encrypt only — dev
new Client({ ..., tls: true, tlsServerName: 'skaidb' }); // system roots + SNI
A server with client_tls = required refuses plaintext connections, so one of
these is mandatory there. tlsServerName must match a SAN on the server
certificate and defaults to skaidb — usually not the address you dialled.
Consistency
new Client({ ..., consistency: 'ONE' }); // default 'QUORUM'
client.query({ text: 'SELECT ...', consistency: 'ALL' }); // per-query
Types
| skaidb | JavaScript |
|---|---|
| Null | null |
| Bool | boolean |
| Int | number (or bigint if > 2^53) |
| Float | number |
| Decimal | string (exact) |
| String | string |
| Bytes | Buffer |
| Uuid | string (canonical) |
| Timestamp | Date |
| Array | Array |
| Document | object |
Run the example
node example.js 192.168.7.117 7000 skaidb secret