{"id":13508895,"url":"https://github.com/hamiltop/rethinkdb-elixir","last_synced_at":"2025-12-11T23:32:40.539Z","repository":{"id":30710364,"uuid":"34266469","full_name":"hamiltop/rethinkdb-elixir","owner":"hamiltop","description":"Rethinkdb client in pure elixir (JSON protocol)","archived":false,"fork":false,"pushed_at":"2018-11-27T01:10:07.000Z","size":402,"stargazers_count":492,"open_issues_count":20,"forks_count":64,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-10-24T22:39:24.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hamiltop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-20T14:48:34.000Z","updated_at":"2025-10-12T16:51:20.000Z","dependencies_parsed_at":"2022-09-04T00:23:48.809Z","dependency_job_id":null,"html_url":"https://github.com/hamiltop/rethinkdb-elixir","commit_stats":null,"previous_names":["hamiltop/exrethinkdb"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/hamiltop/rethinkdb-elixir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamiltop%2Frethinkdb-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamiltop%2Frethinkdb-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamiltop%2Frethinkdb-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamiltop%2Frethinkdb-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hamiltop","download_url":"https://codeload.github.com/hamiltop/rethinkdb-elixir/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamiltop%2Frethinkdb-elixir/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27672094,"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","status":"online","status_checked_at":"2025-12-11T02:00:11.302Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-01T02:01:00.115Z","updated_at":"2025-12-11T23:32:40.512Z","avatar_url":"https://github.com/hamiltop.png","language":"Elixir","funding_links":[],"categories":["ORM and Datamapping","Awesome RethinkDB [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)"],"sub_categories":["Table of Contents"],"readme":"RethinkDB [![Build Status](https://travis-ci.org/hamiltop/rethinkdb-elixir.svg?branch=master)](https://travis-ci.org/hamiltop/rethinkdb-elixir)\n===========\nUPDATE: I am not actively developing this.\n\nMultiplexed RethinkDB client in pure Elixir.\n\nIf you are coming here from elixir-rethinkdb, welcome!\nIf you were expecting `Exrethinkdb` you are in the right place. We decided to change the name to just `RethinkDB` and the repo to `rethinkdb-elixir`. Sorry if it has caused confusion. Better now in the early stages than later!\n\nI just set up a channel on the Elixir slack, so if you are on there join #rethinkdb.\n\n### Recent changes\n\n#### 0.4.0\n\n* Extract Changefeed out into separate [package](https://github.com/hamiltop/rethinkdb_changefeed)\n* Accept keyword options with queries\n\n## Getting Started\n\nSee [API documentation](http://hexdocs.pm/rethinkdb/) for more details.\n\n### Connection\n\nConnections are managed by a process. Start the process by calling `start_link/1`. See [documentation for `Connection.start_link/1`](http://hexdocs.pm/rethinkdb/RethinkDB.Connection.html#start_link/1) for supported options.\n\n#### Basic Remote Connection\n\n```elixir\n{:ok, conn} = RethinkDB.Connection.start_link([host: \"10.0.0.17\", port: 28015])\n```\n\n#### Named Connection\n\n```elixir\n{:ok, conn} = RethinkDB.Connection.start_link([name: :foo])\n```\n\n#### Supervised Connection\n\nStart the supervisor with:\n\n```elixir\nworker(RethinkDB.Connection, [[name: :foo]])\nworker(RethinkDB.Connection, [[name: :bar, host: 'localhost', port: 28015]])\n```\n\n#### Default Connection\n\nAn `RethinkDB.Connection` does parallel queries via pipelining. It can and should be shared among multiple processes. Because of this, it is common to have one connection shared in your application. To create a default connection, we create a new module and `use RethinkDB.Connection`.\n\n```elixir\ndefmodule FooDatabase do\n  use RethinkDB.Connection\nend\n```\n\nThis connection can be supervised without a name (it will assume the module as the name).\n\n```elixir\nworker(FooDatabase, [])\n```\n\nQueries can be run without providing a connection (it will use the name connection).\n\n```elixir\nimport RethinkDB.Query\ntable(\"people\") |\u003e FooDatabase.run\n```\n\n#### Connection Pooling\n\nTo use a connection pool, add Poolboy to your dependencies:\n\n```elixir\n{:poolboy, \"~\u003e 1.5\"}\n```\n\nThen, in your supervision tree, add:\n\n```elixir\nworker(:poolboy, [[name: {:local, :rethinkdb_pool}, worker_module: RethinkDB.Connection, size: 10, max_overflow: 0], [])\n```\n\nNOTE: If you want to use changefeeds or any persistent queries, `max_overflow: 0` is required.\n\nThen use it in your code:\n\n```elixir\ndb = :poolboy.checkout(:rethinkdb_pool)\ntable(\"people\") |\u003e db\n:poolboy.checkin(:rethinkdb_pool, db)\n```\n\n### Query\n\n`RethinkDB.run/2` accepts a process as the second argument (to facilitate piping).\n\n#### Insert\n\n```elixir\n\nq = Query.table(\"people\")\n  |\u003e Query.insert(%{first_name: \"John\", last_name: \"Smith\"})\n  |\u003e RethinkDB.run conn\n```\n\n#### Filter\n\n```elixir\nq = Query.table(\"people\")\n  |\u003e Query.filter(%{last_name: \"Smith\"})\n  |\u003e RethinkDB.run conn\n```\n\n#### Functions\n\nRethinkDB supports RethinkDB functions in queries. There are two approaches you can take:\n\nUse RethinkDB operators\n\n```elixir\nimport RethinkDB.Query\n\nmake_array([1,2,3]) |\u003e map(fn (x) -\u003e add(x, 1) end)\n```\n\nUse Elixir operators via the lambda macro\n\n```elixir\nrequire RethinkDB.Lambda\nimport RethinkDB.Lambda\n\nmake_array([1,2,3]) |\u003e map(lambda fn (x) -\u003e x + 1 end)\n```\n\n#### Map\n\n```elixir\nrequire RethinkDB.Lambda\nimport Query\nimport RethinkDB.Lambda\n\nconn = RethinkDB.connect\n\ntable(\"people\")\n  |\u003e has_fields([\"first_name\", \"last_name\"])\n  |\u003e map(lambda fn (person) -\u003e\n    person[:first_name] + \" \" + person[:last_name]\n  end) |\u003e RethinkDB.run conn\n```\n\nSee [query.ex](lib/rethinkdb/query.ex) for more basic queries. If you don't see something supported, please open an issue. We're moving fast and any guidance on desired features is helpful.\n\n#### Indexes\n\n```elixir\n# Simple indexes\n# create\nresult = Query.table(\"people\")\n  |\u003e Query.index_create(\"first_name\", Lambda.lambda fn(row) -\u003e row[\"first_name\"] end)\n  |\u003e RethinkDB.run conn\n\n# retrieve\nresult = Query.table(\"people\")\n  |\u003e Query.get_all([\"Will\"], index: \"first_name\")\n  |\u003e RethinkDB.run conn\n\n\n# Compound indexes\n# create\nresult = Query.table(\"people\")\n  |\u003e Query.index_create(\"full_name\", Lambda.lambda fn(row) -\u003e [row[\"first_name\"], row[\"last_name\"]] end)\n  |\u003e RethinkDB.run conn\n\n# retrieve\nresult = Query.table(\"people\")\n  |\u003e Query.get_all([[\"Will\", \"Smith\"], [\"James\", \"Bond\"]], index: \"full_name\")\n  |\u003e RethinkDB.run conn\n```\n\nOne limitation we have in Elixir is that we don't support varargs. So in JavaScript you would do `getAll(key1, key2, {index: \"uniqueness\"})`. In Elixir we have to do `get_all([key1, key2], index: \"uniqueness\")`. With a single key it becomes `get_all([key1], index: \"uniqueness\")` and when `key1` is `[partA, partB]` you have to do `get_all([[partA, partB]], index: \"uniqueness\")`\n\n### Changes\n\nChange feeds can be consumed either incrementally (by calling `RethinkDB.next/1`) or via the Enumerable Protocol.\n\n```elixir\nresults = Query.table(\"people\")\n  |\u003e Query.filter(%{last_name: \"Smith\"})\n  |\u003e Query.changes\n  |\u003e RethinkDB.run conn\n# get one result\nfirst_change = RethinkDB.next results\n# get stream, chunked in groups of 5, Inspect\nresults |\u003e Stream.chunk(5) |\u003e Enum.each \u0026IO.inspect/1\n```\n\n### Supervised Changefeeds\n\nSupervised Changefeeds (an OTP behavior for running a changefeed as a process) have been moved to their own repo to enable independent release cycles. See https://github.com/hamiltop/rethinkdb_changefeed\n\n### Roadmap\n\nVersion 1.0.0 will be limited to individual connections and implement the entire documented ReQL (as of rethinkdb 2.0)\n\nWhile not provided by this library, we will also include example code for:\n\n* Connection Pooling\n\nThe goal for 1.0.0 is to be stable. Issues have been filed for work that needs to be completed before 1.0.0 and tagged with the 1.0.0 milestone.\n\n\n### Example Apps\n\nCheckout the wiki page for various [example apps](https://github.com/hamiltop/rethinkdb-elixir/wiki/Example-Apps)\n\n### Contributing\n\nContributions are welcome. Take a look at the Issues. Anything that is tagged `Help Wanted` or `Feedback Wanted` is a good candidate for contributions. Even if you don't know where to start, respond to an interesting issue and you will be pointed in the right direction.\n\n#### Testing\n\nBe intentional. Whether you are writing production code or tests, make sure there is value in the test being written.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamiltop%2Frethinkdb-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamiltop%2Frethinkdb-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamiltop%2Frethinkdb-elixir/lists"}