rethinkly

a library to make easier the operations handling in rethinkdb

Usage no npm install needed!

<script type="module">
  import rethinkly from 'https://cdn.skypack.dev/rethinkly';
</script>

README

Rethinkly 🚀

Build Status Maintainability Test Coverage

👷 Work in progress 🚧

A carefuly created set of bindings to present an easy way to handle RethinkDB instances.

Rethinkly is a collection of methods to make more literal and legible gathering data from rethink into JavaScript applications. Supports node and browser.

Rethink. Again.

Installation

- $ yarn add rethinkly
- $ npm i rethinkly --save

Available methods:

  • createLink
  • data get insert remove update seed
  • table
    • create
    • drop database
    • create
    • drop
    • checkForExistence
    • list

Usage

import { createLink } from 'rethinkly'

const dbConfig = {
  host: process.env.ENV === 'mock' ? '172.18.0.2' : 'localhost',
  port: 32769,
  db: 'the_database',
}

const instance = createLink(dbConfig)

API

Retrieving data (data.get)
  • Method to get a list or a specific value from a table.

Params:

  • connection: object
  • tableName: string
  • id?: string

Example

import { createLink, data } from 'rethinkly'
const instance = createLink(dbConfig)

// Get your data as list
const users = data.get(instance, 'users')
/** output 
[
    {
        id: 'a3bbd8e3-b53f-4ecd-bab9-6c65cfcf931b',
        name: 'Caio Alcantara',
        nickname: 'caio',
        role: '99bd6af9-922e-4787-a97d-3d915f60e65b'
    }
]
*/

/**
 * Match your results using where clause
 */
const users = data.get(instance, 'users', { role: '99bd6af9-922e-4787-a97d-3d915f60e65b' })
/**

* Implicit byId
*/
const users = data.get(instance, 'users', 'a3bbd8e3-b53f-4ecd-bab9-6c65cfcf931b')

/** output 
[
    {
        id: 'a3bbd8e3-b53f-4ecd-bab9-6c65cfcf931b',
        name: 'Caio Alcantara',
        nickname: 'caio',
        role: '99bd6af9-922e-4787-a97d-3d915f60e65b'
    }
]
*/