{"id":16522,"library":"rethinkdb","title":"RethinkDB JavaScript Driver","description":"The RethinkDB JavaScript driver provides programmatic access to RethinkDB, a NoSQL database known for its real-time capabilities via push queries. It is primarily designed for Node.js environments and implements the ReQL query language. The current stable version is 2.4.4. After a period of inactivity from the original creators, the project transitioned to community-driven maintenance under the Linux Foundation, with recent 2.4.x releases (2023-2024) addressing bug fixes and compilation issues. Its key differentiator remains the 'changefeeds' feature, which allows applications to receive real-time updates as data changes. While the official documentation is still available, the release cadence is irregular, reflecting its community-supported status.","status":"maintenance","version":"2.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/rethinkdb/rethinkdb","tags":["javascript","database","NoSQL","reql","query language"],"install":[{"cmd":"npm install rethinkdb","lang":"bash","label":"npm"},{"cmd":"yarn add rethinkdb","lang":"bash","label":"yarn"},{"cmd":"pnpm add rethinkdb","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The 'rethinkdb' package exports a single object, typically aliased as 'r', which is the entry point for all ReQL commands and connection functions. ESM import 'import r from \"rethinkdb\"' may work in modern Node.js environments but CJS is historically dominant.","symbol":"r","correct":"const r = require('rethinkdb');"},{"note":"The `connect` method is a property of the main `r` object, not a named export. Ensure you import the entire 'rethinkdb' module first.","wrong":"import { connect } from 'rethinkdb'","symbol":"connect","correct":"const r = require('rethinkdb');\nr.connect({...})"},{"note":"RethinkDB error types are typically accessed as properties of the main `r` object rather than direct named exports. `r.Error` is the base class for all RethinkDB errors.","wrong":"import { RethinkDBError } from 'rethinkdb'","symbol":"RethinkDBError","correct":"const r = require('rethinkdb');\nconst { RethinkDBError } = r;"}],"quickstart":{"code":"const r = require('rethinkdb');\n\nasync function runExample() {\n  let connection;\n  try {\n    connection = await r.connect({\n      host: process.env.DB_HOST ?? 'localhost',\n      port: parseInt(process.env.DB_PORT ?? '28015'),\n      db: process.env.DB_NAME ?? 'test',\n      user: process.env.DB_USER ?? 'admin',\n      password: process.env.DB_PASSWORD ?? ''\n    });\n\n    // Create a table if it doesn't exist\n    const tableList = await r.db('test').tableList().run(connection);\n    if (!tableList.includes('authors')) {\n      await r.db('test').tableCreate('authors').run(connection);\n      console.log('Table \"authors\" created.');\n    }\n\n    // Insert a document\n    const insertResult = await r.table('authors').insert({\n      name: 'John Doe',\n      posts: 5\n    }).run(connection);\n    console.log('Inserted:', insertResult.generated_keys[0]);\n\n    // Fetch all documents\n    const cursor = await r.table('authors').run(connection);\n    const authors = await cursor.toArray();\n    console.log('Authors:', authors);\n\n  } catch (err) {\n    console.error('Error:', err.message);\n  } finally {\n    if (connection) {\n      await connection.close();\n      console.log('Connection closed.');\n    }\n  }\n}\n\nrunExample();","lang":"javascript","description":"Demonstrates connecting to RethinkDB, creating a table if it doesn't exist, inserting a document, and fetching all documents."},"warnings":[{"fix":"Consult the RethinkDB 2.4.0 release notes for details on the `r.js` command changes and update usage accordingly.","message":"The API for the `r.js` ReQL command experienced breaking changes in version 2.4.2. Users relying on this command should review their code.","severity":"breaking","affected_versions":">=2.4.2"},{"fix":"Ensure all servers in a cluster are upgraded to 2.4.x before deploying new instances. Avoid running mixed-version clusters for extended periods during upgrades.","message":"RethinkDB 2.4.x servers are not compatible with 2.3.x or earlier versions when mixed in the same cluster. Mixing versions can lead to cluster instability or data inconsistencies.","severity":"breaking","affected_versions":">=2.4.0"},{"fix":"Always use the default TCP connection for applications. The HTTP connection type is planned to be removed from the driver in future versions.","message":"The HTTP connection type provided by the driver is intended only for the RethinkDB web UI and is explicitly stated not to be secure for application use. Using it in production applications is a security risk.","severity":"gotcha","affected_versions":"*"},{"fix":"Before upgrading to RethinkDB 2.4.0 or later from older major versions, perform a full backup of all your data files to prevent potential data loss.","message":"When upgrading to RethinkDB 2.4.0 from versions 1.16 or earlier, data files will be automatically migrated. However, it is strongly recommended to back up your data files before performing any major version upgrade.","severity":"breaking","affected_versions":">=2.4.0"},{"fix":"On affected platforms, ensure a complete cluster upgrade to 2.3.5+ without mixing older versions. On 64-bit Linux/macOS, mixed 2.3.x versions are temporarily tolerated during upgrade.","message":"On 32-bit platforms and Windows (both 32 and 64-bit), RethinkDB 2.3.5 servers should not be mixed with servers running 2.3.3 or older in the same cluster. This can cause server crashes, especially when using the web UI or accessing system tables.","severity":"breaking","affected_versions":"2.3.5"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure the RethinkDB server is running and accessible from your application. Verify the `host` and `port` parameters in your `r.connect()` call match the server's configuration.","cause":"The RethinkDB server is not running, or the connection details (host/port) are incorrect.","error":"Error: connect ECONNREFUSED 127.0.0.1:28015"},{"fix":"Ensure that the database and table exist before attempting to query them. You can use `r.dbCreate('your_db')` and `r.db('your_db').tableCreate('your_table')` to create them programmatically or via the RethinkDB Data Explorer.","cause":"The specified database or table has not been created in RethinkDB.","error":"RethinkDBError: Table `db.table_name` does not exist."},{"fix":"All ReQL queries must be terminated with a `.run(connection, callback)` or `await .run(connection)` call to execute them against the database. Verify your ReQL chain for correct command usage.","cause":"A ReQL query command was called without a `run()` method or with incorrect syntax, or the connection object was not passed.","error":"TypeError: r.table(...).insert is not a function"}],"ecosystem":"npm"}