# acl-backend-rethinkdb

> RethinkDB backend for acl

Latest version **1.0.0** (published 2017-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install acl-backend-rethinkdb
pnpm add acl-backend-rethinkdb
yarn add acl-backend-rethinkdb
bun add acl-backend-rethinkdb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-10-05 |
| First published | 2016-07-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Branden Horiuchi |
| Maintainers | vbranden |
| Keywords | acl, rethink, rethinkdb, backend, node |

## Links

- npm: https://www.npmjs.com/package/acl-backend-rethinkdb
- Repository: https://github.com/bhoriuchi/node-acl-backend-rethink
- Homepage: https://github.com/bhoriuchi/node-acl-backend-rethink#readme
- Issues: https://github.com/bhoriuchi/node-acl-backend-rethink/issues
- npm.io page: https://npm.io/package/acl-backend-rethinkdb

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-10-05
- 0.1.0 — 2016-07-28

## README

# acl-backend-rethinkdb
RethinkDB backend for [`acl`](https://github.com/optimalbits/node_acl) that 
works with both [`rethinkdb`](https://github.com/rethinkdb/rethinkdb) 
and [`rethinkdbdash`](https://github.com/neumino/rethinkdbdash) drivers

### Using [`rethinkdbdash`](https://github.com/neumino/rethinkdbdash) driver

This driver takes care of creating the connection for the user so usage is 
more straightforward

```
var acl = require('acl')
var r = require('rethinkdbdash')()
var RethinkDBBackend = require('acl-backend-rethinkdb')

var options = {
  prefix: 'acl_',
  useSingle: true,
  ensureTable: true
}

acl = new acl(new RethinkDBBackend(r, options))
acl.addUserRoles('john', 'admin', function(err) {
 ...
})
```

### Using [`rethinkdb`](https://github.com/rethinkdb/rethinkdb) driver

Since the official rethinkdb driver requires a connection to be passed to 
the `run` method, the connection parameter is required for the backend to function

```
var acl = require('acl')
var r = require('rethinkdb')
var RethinkDBBackend = require('acl-backend-rethinkdb')

r.connect({}).then(function (connection) {
  var options = {
    prefix: 'acl_',
    useSingle: true,
    ensureTable: true
  }

  acl = new acl(new RethinkDBBackend(r, options, connection))
  acl.addUserRoles('john', 'admin', function(err) {
   ...
  })
})
```

### API

##### `RethinkDBBackend` ( `rethink`, [ `options` ], [ `connection` ] )

* `rethink` { `Object` } - RethinkDB instance
* `options` { `Object` }
  * [`db="test"`] { `String` } - Database name
  * [`prefix="acl_"`] { `String` } - Prefix for table names
  * [`table="resources"`] { `String` } - Table name for useSingle
  * [`useSingle=true`] { `Boolean` } - Use a single table for storing data when `true`
  * [`ensureTable=true`] { `Boolean` } - Creates a table if it does not exist 
  when `true`. Should be `true` when `useSingle=false` since bucket/table names are
  created based on resource names
* [`connection`] { `Object` } - Database connection object. Required for `rethinkdb` 
driver and not used by `rethinkdbdash` driver

### Notes

* When `useSingle=false` is set buckets not matching `/A-Za-z0-9_/` will have their 
bucket/table name names encoded with their hex value. This allows any character to be used
for the bucket name without violating RethinkDB's table naming constraint.

---
_Source: https://npm.io/package/acl-backend-rethinkdb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
