A RethinkDB-compatible database rethinkdb database rocksdb
HEAD Latest release released

GitHub Actions Crystal Version


This is a personal project aiming at reimplementing everything RethinkDB currently does. At the same time, it is also a driver capable of connecting to a database and sending queries.

First use case: Database driver

You can connect to a running RethinkDB instance and send queries. Methods are pretty much equal to the official Ruby driver, for which you can find documentation here: This is not feature complete yet, a lot of functions are missing. Be aware of bugs (please report them).

require "rethinkdb-lite/src/driver/*"
include RethinkDB::DSL

conn = r.connect("localhost")

r.table("heros").insert({name: "Iron Man", power: 17}).run(conn)
r.table("heros").insert({name: "Batman", power: 13}).run(conn)
r.table("heros").insert({name: "Superman", power: 650}).run(conn)
r.table("heros").insert({name: "Hulk", power: 103}).run(conn)

overpower_hero = r.table("heros").filter { |hero| hero["power"] == 650 }["name"][0].run(conn)

pp overpower_hero

Second use case: Local database for your application

This is similar to SQLite. A single-user database is run with a local path where data is stored. This is reimplementing the behavior of RethinkDB, but working as an embeddable library. The goal is to have every query that you would do on the real RethinkDB working here, with similar semantics. This is not feature complete yet, a lot of functions are missing. Be aware of bugs (please report them).

require "rethinkdb-lite/src/driver/*"
include RethinkDB::DSL

# The data will be stored in this directory.
conn = r.local_database("path/to/data")

r.table("users").insert({name: "John", username: "john", password: "123"}).run(conn)

Third use case: RethinkDB server

That local database from the second use case can also be served as a full multi-user database, listening for RethinkDB driver connections and also serving the Web UI for administration. It can receive connection from any official or non-official RethinkDB driver from

require "rethinkdb-lite/src/server/*"
require "rethinkdb-lite/src/driver/*"
include RethinkDB::DSL

conn = r.local_database("path/to/data"), conn).start, conn).start

# http://localhost:8080 will bring the Web UI
# localhost:28015 will be ready for driver connections



  • Implement all current features of RethinkDB (all query functions, clustering, changefeed, geoindex, ...)
  • Be fully compatible with RethinkDB's drivers and WebUI
  • Make small improvements along the way (with minimal user impact)
  • Make it fast
  • Add new features (query optimizer? autorebalancing?)


  • Pass successfuly on RethinkDB's spec suite
  • Add some better newer tests
  • Benchmark and improve performance
  • Implement epic features: clustering, changefeeds
  • Implement new features: query optimizer?


Install these dependencies:

  • Crystal for compiling the main code
  • Node for compiling the Web UI
  • Duktape for a embeddable javascript runtime for r.js() (apt install duktape-dev)
  • RocksDB for the storage engine (apt install librocksdb-dev)

Then run:

cd vendor/rethinkdb-webui
npm ci
npm run build
cd ../..
crystal src/

And open your browser at http://localhost:8080.

Most of the Web UI doesn't work yet, but you can use the tabs Tables and Data Explorer. Try some queries there.

You can also use any client driver to connect from another language, see

For higher read/write throughput enable multithreading. Use the following:

crystal run -Dpreview_mt src/

Running Tests

You should have a running real empty RethinkDB server for testing. Do not use one with data in it. You can start one with by simply running rethinkdb on the terminal, after installing it.

crystal spec


  github: lbguilherme/rethinkdb-lite
License MIT
Crystal >= 1.0, < 2.0


Dependencies 2

  • future
    {'github' => 'crystal-community/'}
  • rocksdb~lbguilherme master
    {'branch' => 'master', 'github' => 'lbguilherme/rocksdb-crystal'}

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently