RethinkDB.Ecto v0.6.1 RethinkDB.Ecto

Ecto adapter module for RethinkDB.

It uses :rethinkdb to connect and communicate with a RethinkDB database.

The adapter tries to serialize SQL-like Ecto queries to the ReQL query language in a performant manner. Lots of the query patterns are inspired by the SQL to ReQL cheat-sheet1. If you want to know how a specific function is implemented, look at the RethinkDB.Ecto.NormalizedQuery module.

You can create and drop databases using mix ecto.create and mix.ecto.drop. Migrations will work for creating tables and indexes. Field specifications are not supported and will be ommited when executing the migration.

Additionaly, repositories using this adapter can run ReQL queries directly:

import RethinkDB.{Query, Lambda}

table("users")
|> has_fields(["first_name", "last_name"])
|> map(lambda & &1[:first_name] + " " + &1[:last_name])
|> MyApp.Repo.run()

Known Limitations

The adapter does not support connection pooling. All the queries are executed on the same connection. Due to the multiplex nature of RethinkDB connections, a single connection should do just fine for most use cases.

The data type of a primary key is a UUID :binary_id. In order to work properly, you must add the following attributes to your schema definitions:

@primary_key {:id, :binary_id, autogenerate: false}
@foreign_key_type :binary_id

You can set the :autogenerate option to true if you want to generate primary keys on the client side.

RethinkDB does not support unique secondary indexes. Indexes can be created normaly using a migration file. When running migrations with unique indexes, you will get a warning. Nevertheless, the index will be created.

Summary

Functions

autogenerate(atom)

Callback implementation for Ecto.Adapter.autogenerate/1.

child_spec(repo, options)

Callback implementation for Ecto.Adapter.child_spec/2.

delete(repo, meta, filters, options)

Callback implementation for Ecto.Adapter.delete/4.

dumpers(arg1, type)

Callback implementation for Ecto.Adapter.dumpers/2.

ensure_all_started(repo, type)

Callback implementation for Ecto.Adapter.ensure_all_started/2.

execute(repo, meta, arg, params, preprocess, options)

Callback implementation for Ecto.Adapter.execute/6.

execute_ddl(repo, arg, options)

Callback implementation for Ecto.Adapter.Migration.execute_ddl/3.

in_transaction?(repo)
insert(repo, meta, fields, returning, options)

Callback implementation for Ecto.Adapter.insert/5.

insert_all(repo, meta, header, fields, returning, options)

Callback implementation for Ecto.Adapter.insert_all/6.

loaders(arg1, type)

Callback implementation for Ecto.Adapter.loaders/2.

prepare(func, query)

Callback implementation for Ecto.Adapter.prepare/2.

rollback(repo, value)
storage_down(options)

Callback implementation for Ecto.Adapter.Storage.storage_down/1.

storage_up(options)

Callback implementation for Ecto.Adapter.Storage.storage_up/1.

supports_ddl_transaction?()

Callback implementation for Ecto.Adapter.Migration.supports_ddl_transaction?/0.

update(repo, meta, fields, filters, returning, options)

Callback implementation for Ecto.Adapter.update/6.