rqlite-client
v2.0.0
Published
nodejs client for rqlite, with cluster support
Downloads
2
Readme
rqlite-client
nodejs client for rqlite, with cluster support, documentation
const { Client } = require('rqlite-client')
const client = new Client(['http://localhost:4001', 'http://localhost:4003'])
const schema = `\
CREATE TABLE IF NOT EXISTS account (
id integer not null primary key,
name text,
balance integer not null default 0
)`
async function main() {
await client.exec(schema)
await client.exec('INSERT INTO account(name, balance) VALUES("foo", 10)')
await client.exec('INSERT INTO account(name, balance) VALUES("bar", 10)')
await client.batch([
'UPDATE ACCOUNT SET balance = balance - 1 WHERE name = "foo"',
'UPDATE ACCOUNT SET balance = balance + 1 WHERE name = "bar"',
], true) // true for atomic
await client.query('SELECT * FROM account')
}