[data-reveal]{opacity:1!important;transform:none!important}
All modules
rethinkdb

antelopejs/rethinkdb

Official

RethinkDB client module implementing the Database interface

ajs project modules add @antelopejs/rethinkdb

@antelopejs/rethinkdb

The RethinkDB backend of AntelopeJS: it runs the database interface's queries on RethinkDB with rethinkdb-ts, and exposes that driver to modules that need it directly.

Interfaces

Schemas, tables, queries, change feeds and atomic mutations are documented on the database interface pages.

Install

ajs project modules add @antelopejs/rethinkdb

The command writes the module's default configuration: a connection pool to 127.0.0.1:28015 as admin.

Configuration

The module connects either through a connection pool (pool) or through a single connection (connection). When both are set, pool wins.

import { defineConfig } from "@antelopejs/interface-core/config";

export default defineConfig({
  name: "my-project",
  modules: {
    rethinkdb: {
      source: {
        type: "package",
        package: "@antelopejs/rethinkdb",
        version: "^1.4.0",
      },
      config: {
        pool: {
          host: "127.0.0.1",
          port: 28015,
          user: "admin",
          password: "",
          pool: true,
          cursor: false,
          silent: true,
          discovery: true,
        },
      },
    },
  },
});

For a single connection:

config: {
  connection: { host: "127.0.0.1", port: 28015, user: "admin", password: "" },
},
KeyDescription
poolrethinkdb-ts pool options (RPoolConnectionOptions), passed to r.connectPool().
connectionrethinkdb-ts connection options (RConnectionOptions), passed to r.connect(). Used when pool is unset.

The module refuses to start when neither key is set. The option types come from rethinkdb-ts.

Quick start

In the module that stores data, add the database interface:

pnpm add @antelopejs/interface-database

Then follow the database interface guide to declare a schema and query it. The same code runs on @antelopejs/mongodb.

To use the driver directly instead, add @antelopejs/interface-rethinkdb and read its documentation.

Storage layout

  • Each schema is a RethinkDB database, and each schema table is a table in it. Every table has a tenant_id index that scopes it to one instance.
  • Each declared index <name> becomes a <name>__i index led by the instance. An index declared with crossInstance: true also gets an unprefixed <name> index for CROSS_INSTANCE queries; without it, those queries scan the table and log a one-time warning. Index names ending in __i are reserved.
  • Schema initialization creates missing databases, tables and indexes, retries up to five times, and waits for the indexes before the schema accepts queries.

Version 1.4 added the <name>__i indexes. The first boot after an upgrade builds them, which takes longer on large tables. The module never drops an index: drop the old ones you no longer need by hand, for example r.db("<schema>").table("<table>").indexDrop("<name>").

Documentation

  • Database: the @antelopejs/interface-database contract this module implements
  • RethinkDB: the @antelopejs/interface-rethinkdb contract this module implements
  • Configuration: module sources, config blocks and config variables in antelope.config.ts

Compatibility

PackageSupported range
@antelopejs/interface-database^0.1.8
@antelopejs/interface-rethinkdb>=0.0.5 <1.0.0
@antelopejs/interface-core>=0.1.1 <1.0.0

The module is developed and tested against @antelopejs/core ^1.13.4 on Node.js 24, with rethinkdb-ts ^2.7.0 and RethinkDB 2.4.

Contributing

The tests need a RethinkDB server on 127.0.0.1:28015. Start the one CI uses:

docker compose -f .github/release-services.yml up -d --wait

Then run the checks:

pnpm install
pnpm lint
pnpm format:check
pnpm typecheck
pnpm knip
pnpm test           # build, then ajs module test

The tests also run the shared conformance suite of @antelopejs/interface-database. Read the contribution guidelines before opening a pull request.

License

Apache-2.0