2.0.0 • Published 2 years ago

rethinkdb-generator v2.0.0

Weekly downloads
18
License
MIT
Repository
github
Last release
2 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

2 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago