npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rethinkdb-ts

v2.6.1

Published

RethinkDB TypeScript driver

Downloads

18,535

Readme

rethinkdb-ts

npm node deps licenses downloads size build

Install

npm i rethinkdb-ts

or

yarn add rethinkdb-ts

Import

// if you support import
import { r } from 'rethinkdb-ts';
// if you dont
const { r } = require('rethinkdb-ts');

Initialize

// in an async context
// if you want to initialize a connection pool
await r.connectPool(options);
// if you want to initialize a single connection
const conn = await r.connect(options);

STATUS:

  • Fully working typescript driver!
  • Rebuilt from scratch using the latest ES/TS features for readability and maintainability
  • Drop-in replacement for rethinkdbdash with only some minor changes

CHANGES FROM RETHINKDBDASH

  • Support for complex socket configuration + tls (notice that for SSL/TLS or any configuration more complex than { host: '...', port: '...' } you'll have to encapsulate in a server/servers property:
{ 
   server: {
      host: '172.23.12.2',
      port: 21085,
      tls: true,
      ca: caCert,
      // If your certificate common name doesn't match the host:
      // checkServerIdentity() {}
   }
}

The options for standard connections is described here.

If you want an SSL/TLS, add tls: true and the options described here and

  • Importing property instead of entire library: const {r} = require('rethinkdb-ts') or import {r} from 'rethinkdb-ts' instead of const r = require('rethinkdbdash')(options)
  • No top level initialization, initializing a pool is done by await r.connectPool()
  • No { cursor: true } option, for getting a cursor use .getCursor(runOptions) instead of .run(runOptions)
    • .run() will coerce streams to array by default feeds will return a cursor like rethinkdbdash
  • Uses native promises instead of bluebird
  • A cursor is already a readable stream, no need for toStream()
  • A readable stream is already an async iterator in node 10 no need for .asyncIterator()
  • In a connection pool, reusing open connections that already run queries instead of making queries wait for a connection when max connections exceeded
  • Integrated fully encompasing type definitions

NEW FEATURES

  • serialize / deserialize. You can store the query as a string like this const serializedQuery = r.table(...).filter(...).map(...).serialize() and get it like this r.deserialize(serializedQuery).run() or even r.deserialize<RStream>(serializedQuery).reduce(...).run() the serialized query is a normal string so you can store it in the DB. No need for ugly workarounds like .toString and eval anymore. Also the serialized query is the actual JSON that gets sent to the server so it should be cross-language compatible if any other driver cares to implement it.

DROPPING SUPPORT:

  • Support node < 12
  • Support callbacks
  • Support using .then() directly on a query (optionalRun), it can confuse users that queries are promises leading to false assumptions:
    • Queries are not promises since they are not eagerly evaluated and therefore they can:
      • .run() as many times as you want (promises run only once and return the same value without running other times)
      • be stored for future evaluation (promises run as you create them)
  • Support browsers (Unless it's the only demand of making this driver used instead of rethinkdbdash)
  • Support write streams (Does anyone use it? Will add it if its a popular demand)
  • Multiple connection pools (if someone has a good usecase I'll support it)