2.0.0 • Published 3 years ago

rethinkdb-generator v2.0.0

Weekly downloads
18
License
MIT
Repository
github
Last release
3 years ago

rethinkdb-generator

Create an generator (iterable) from a rethinkdb cursor

Installation

npm i --save rethinkdb-generator

Usage

Supports both ESM and CommonJS

// esm
import rethinkdbGenerator from 'rethinkdb-generator'
// commonjs
const rethinkdbGenerator = require('rethinkdb-generator')

Example: create a generator from a rethinkdb cursor

import getRows from 'rethinkdb-generator'
import r from 'rethinkdb'

const conn = r.connect()
const cursor = await r.db('test').table('test').run(conn)
const rows = getRows(cursor)

// use generator directly
const row = await rows.next() // get "next" row
await rows.return() // close cursor

Example: use rethinkdb generators with "for await .. of"

import getRows from 'rethinkdb-generator'
import r from 'rethinkdb'

const conn = r.connect()
const cursor = await r.db('test').table('test').run(conn)
const rows = getRows(cursor)

// use generator w/ "for await .. of"
for await (let row of rows) {
  console.log(row)
}
// cursor will be closed after loop completes or breaks

License

MIT

2.0.0

3 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago