{"id":15994247,"url":"https://github.com/pixelhandler/rethinkdb_adapter","last_synced_at":"2025-04-05T00:15:46.771Z","repository":{"id":24878894,"uuid":"28294849","full_name":"pixelhandler/rethinkdb_adapter","owner":"pixelhandler","description":"Adapter/connector for RethinkDB with simple query/persistence interface","archived":false,"fork":false,"pushed_at":"2015-01-21T08:07:56.000Z","size":168,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T09:36:36.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pixelhandler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-21T09:51:33.000Z","updated_at":"2015-02-16T16:54:37.000Z","dependencies_parsed_at":"2022-08-23T03:50:06.499Z","dependency_job_id":null,"html_url":"https://github.com/pixelhandler/rethinkdb_adapter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Frethinkdb_adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Frethinkdb_adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Frethinkdb_adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Frethinkdb_adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixelhandler","download_url":"https://codeload.github.com/pixelhandler/rethinkdb_adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266570,"owners_count":20910837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T07:07:45.397Z","updated_at":"2025-04-05T00:15:46.748Z","avatar_url":"https://github.com/pixelhandler.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## RethinkDB Adapter\n\nAdapter/connector for RethinkDB with simple query/persistence interface\n\nSee the [adapter.js](adapter.js) file which represents the interface for\nconnecting, querying, performing CRUD operations, and includes methods:\n\n* find\n* findMany\n* findQuery\n* createRecord\n* updateRecord\n* deleteRecord\n* patchRecord\n* findBySlug\n* updateRecordBySlug\n* deleteRecordBySlug\n* uuid\n* setup\n\nThe above method names may look familiar if you've used the Ember.js\nclient-side framework together with a data persistence library such as\nEmber Data, or Orbit.js.\n\nThis module was developed for a simple API for a blog application\nwithout a model layer, simply adapting a request to a resource in the\ndatabase. The adapter provides a simple interface to persist JSON data \nfrom a (smart) client application that has a model layer, it's own\nvalidations, and relelationship management; such as using the JSON API\nspec or JSON Patch.\n \n\n## Install\n\n    npm install rethinkdb_adapter --save\n\n\n## Connect\n\nRequire the module\n\n    var db = require('rethinkdb_adapter');\n\nEnvironment variables used to connect to your database:\n\n* RDB_HOST\n* RDB_PORT\n* RDB_DB\n\nBelow is the default connection setup\n\n```javascript\n/**\n  RethinkDB database settings.\n  Defaults can be overridden using environment variables.\n  @method find\n**/\nvar adapter = new db.Adapter({\n  host: process.env.RDB_HOST || 'localhost',\n  port: parseInt(process.env.RDB_PORT) || 28015,\n  db: process.env.RDB_DB\n});\n```\n\n### Examples\n\nBelow are a few examples taken from a simple blog API using Node.js w/ Express\n\nRefer to: https://github.com/pixelhandler/blog/tree/master/server\n\n*Create a record*, e.g. a blog post\n\n```javascript\n/**\n  Create a post\n\n  Route: (verb) POST /posts\n  @async\n**/\napp.post('/posts', restrict, function (req, res) {\n  db.createRecord('posts', req.body.posts, function (err, payload) {\n    if (err) {\n      logerror(err);\n      res.status(500).end();\n    } else {\n      loginfo('payload', payload.posts);\n      if (app._io) {\n        loginfo('didAdd', payload);\n        app._io.emit('didAdd', payload);\n      }\n      res.status(201).send(payload);\n    }\n  });\n});\n```\n\n*A JSON Patch request* to update a blog post title:\n\n```javascript\n/**\n  Patch a post by id, supports replace and remove operations\n\n  Route: (verb) PATCH /posts/:id\n\n  Example payload:\n\n  [{\n    \"op\": \"replace\",\n    \"path\": \"/title\",\n    \"value\": \"Refreshed my Blog with Express and Ember.js\"\n  }]\n\n  @async\n**/\napp.patch('/posts/:id', restrict, function (req, res) {\n  db.patchRecord('posts', req.params.id, req.body, function (err) {\n    if (err) {\n      logerror(err);\n      res.status(500).end();\n    } else {\n      res.status(204).end();\n    }\n  });\n});\n```\n\n*A PUT request* to update an author\n\n```javascript\n/**\n  Update a author by id\n\n  Route: (verb) PUT /authors/:id\n  @async\n**/\napp.put('/authors/:id', restrict, function (req, res) {\n  db.updateRecord('authors', req.params.id, req.body.authors, function (err) {\n    if (err) {\n      logerror(err);\n      res.status(500).end();\n    } else {\n      res.status(204).end();\n    }\n  });\n});\n```\n\n## Links\n\n* [RethinkDB]\n* [driver]\n\n[RethinkDB]: http://www.rethinkdb.com\n[driver]: http://www.rethinkdb.com/api/javascript/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelhandler%2Frethinkdb_adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelhandler%2Frethinkdb_adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelhandler%2Frethinkdb_adapter/lists"}