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
- Host: GitHub
- URL: https://github.com/zweifisch/rqlite-client
- Owner: zweifisch
- Created: 2018-08-25T03:22:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-26T14:05:26.000Z (over 6 years ago)
- Last Synced: 2025-03-16T14:37:37.312Z (2 months ago)
- Language: TypeScript
- Size: 157 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
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 atomicawait 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/