An open API service indexing awesome lists of open source software.

https://github.com/zweifisch/rqlite-client

nodejs client for rqlite with cluster support
https://github.com/zweifisch/rqlite-client

Last synced: about 2 months ago
JSON representation

nodejs client for rqlite with cluster support

Awesome Lists containing this project

README

        

# rqlite-client

[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Node.js Version][node-version-image]][node-version-url]

nodejs client for [rqlite](https://github.com/rqlite/rqlite), with cluster support, [documentation](https://zweifisch.github.io/rqlite-client/)

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

[npm-image]: https://img.shields.io/npm/v/rqlite-client.svg?style=flat
[npm-url]: https://npmjs.org/package/rqlite-client
[travis-image]: https://img.shields.io/travis/zweifisch/rqlite-client.svg?style=flat
[travis-url]: https://travis-ci.org/zweifisch/rqlite-client
[node-version-image]: https://img.shields.io/node/v/rqlite-client.svg
[node-version-url]: https://nodejs.org/en/download/