{"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.","language":"javascript","status":"maintenance","last_verified":"Wed Apr 22","install":{"commands":["npm install rethinkdb"],"cli":null},"imports":["const r = require('rethinkdb');","const r = require('rethinkdb');\nr.connect({...})","const r = require('rethinkdb');\nconst { RethinkDBError } = r;"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}