rqlite-connect
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i rqlite-connect

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

157 kB

Total Files

18

Last publish

Collaborators

  • tknew