2.0.0 • Published 6 years ago

rqlite-client v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

rqlite-client

NPM Version Build Status Node.js Version

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')
}
2.0.0

6 years ago

1.0.0

6 years ago

0.1.1

6 years ago