RethinkDB - First Steps

Posted by n3integration on March 6, 2016

I am starting a new project and was in search of a database that was easy to setup, has a solid query language, and is easy to integrate into my codebase. In my search, I came across RethinkDB. Having worked with other document stores in past projects, namely MongoDB and CouchDB, RethinkDB has two features that caught my eye for this particular project: joins and changefeeds. In this project, some of the data is relational, so having join support built into a document database is a welcome feature. The changefeed support is a great feature for realtime applications - think WebSockets or SSE.

RethinkDB provides a Docker image to help bootstrap new development environments. Assuming that you already have Docker installed, you can easily spin up a new container. Otherwise, you can download a binary and find installation instructions for your platform on the RethinkDB website.

$ docker run -d -P --name rethink1 rethinkdb

After the Docker container has spun up, we can explore the RethinkDB dashboard to confirm that the database is up and running properly, by opening a browser to http://localhost:8080/#dashboard.

RethinkDB Dashboard

Since this step took less than 10 minutes, I think that it is safe to say that it was easy to setup, satisfying the first requirement. RethinkDB also comes preinstalled with a default test database so that we can quickly connect and start inserting data. RethinkDB provides a query language comparable to SQL, which is named ReQL, or RethinkDB query language. The company provides a quick introduction to the syntax on their website as well as a 10 minute guide for each supported driver.

The database also provides a Data Explorer that allows users to execute ReQL queries within the browser. This is a very useful feature when testing out queries or verifying that the data is persisted in the expected format.