rethinkdown

0.3.0 • Public • Published

rethinkdown

A RethinkDB implementation of the LevelDOWN API

Tested with RethinkDB drivers
  • rethinkdb
  • rethinkdbdash

Example (ES6)

import r from 'rethinkdb'
import rethinkdown from 'rethinkdown'
 
const database = 'test'
const options = { host: 'db.myserver.com' }
const table = 'mydbtable'
 
let db = rethinkdown(r, database, options)(table)
 
db.open({ createIfMissing: true }, (error) => {
  db.put('1', 'one', (error) => {
    db.get('one', { asBuffer: false }, (error, value) => {
      console.log(value)
      // > one
      db.close((error) => {
        // ...
      })
    })
  })
})

API

Refer to the LevelDOWN or AbstractLevelDOWN documentation for full API


RethinkDOWN ( driver, [database], [connectOptions] )

A RethinDOWN instance needs to first be initialized with either a rethinkdb or rethinkdbdash driver, optional database name, and optional connection options

Parameters

  • driver {rethinkdb|rethinkdbdash} - Supported RethinkDB driver
  • [database="test"] {String} - Database name to use
  • [connectOptions] {Object} - A rethinkdb or rethinkdbdash connect options object
  • [connectOptions.singleTable] {String} - Single mode table name

Returns {rethinkdown} - Instance of rethinkdown that can be passed a location/table

Example
import r from 'rethinkdbdash'
import RethinkDOWN from 'rethinkdown'
 
let rethinkdown = RethinkDOWN(r, 'test', { silent: true })
let db = rethinkdown('myleveldb')

rethinkdown ( location )

returns a new RethinkDOWN instance

Parameters

  • location {String} - table name or record filter when using single mode

Returns {RethinkDOWN}


location

The location should be the name of the table that should be used as the LevelDB store. All non-alphanumeric and _ characters will be replaced with _

Single-Mode since v0.3.0

Single mode allows the same table to be used for all level databases. The table name specified by connectOptions.singleTable will store all data and the location will be added as a value in each record so that multiple databases can be stored in the same table.

Single Mode Example
import r from 'rethinkdb'
import RethinkDOWN from 'rethinkdown'
 
let rethinkdown = RethinkDOWN(r, 'test', { singleTable: 'myleveldb' })
let db1 = rethinkdown('db1')
let db2 = rethinkdown('db2')

Dependents (0)

Package Sidebar

Install

npm i rethinkdown

Weekly Downloads

0

Version

0.3.0

License

MIT

Last publish

Collaborators

  • vbranden