All Projects → almightycouch → Rethinkdb_ecto

almightycouch / Rethinkdb_ecto

Licence: mit
RethinkDB adapter for Ecto.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Rethinkdb ecto

Ecto mnesia
Ecto adapter for Mnesia Erlang term database.
Stars: ✭ 223 (+99.11%)
Mutual labels:  ecto, adapter
Rethinkdb Adapter
RethinkDB adapter for Casbin https://github.com/casbin/casbin
Stars: ✭ 148 (+32.14%)
Mutual labels:  rethinkdb, adapter
Wallaby
Concurrent browser tests with elixir
Stars: ✭ 1,143 (+920.54%)
Mutual labels:  ecto
Defql
Create elixir functions with SQL as a body.
Stars: ✭ 100 (-10.71%)
Mutual labels:  ecto
Hibiki
🤖 The best all-in-one Discord bot! Automod, fun, music, utilities, and more. Customizable, easy-to-use, and fully translatable.
Stars: ✭ 86 (-23.21%)
Mutual labels:  rethinkdb
Molasses
Feature toggle library for elixir
Stars: ✭ 70 (-37.5%)
Mutual labels:  ecto
Alfonz
Mr. Alfonz is here to help you build your Android app, make the development process easier and avoid boilerplate code.
Stars: ✭ 90 (-19.64%)
Mutual labels:  adapter
Wireless Rc Adapter
🎮 Arduino USB-Joystick adapter for RC receivers with PWM and PPM modulations up to 8 channels.
Stars: ✭ 62 (-44.64%)
Mutual labels:  adapter
Poweradapter
Adapter for RecyclerView(only 21KB).RecyclerView万能适配器(仅21KB)
Stars: ✭ 112 (+0%)
Mutual labels:  adapter
Filterable
Filtering from incoming params in Elixir/Ecto/Phoenix with easy to use DSL.
Stars: ✭ 83 (-25.89%)
Mutual labels:  ecto
Ecto state machine
State machine pattern for Ecto
Stars: ✭ 91 (-18.75%)
Mutual labels:  ecto
Polymorphic embed
Polymorphic embeds in Ecto
Stars: ✭ 80 (-28.57%)
Mutual labels:  ecto
Ecto morph
morph your Ecto capabilities into the s t r a t o s p h e r e !
Stars: ✭ 72 (-35.71%)
Mutual labels:  ecto
Lib.reviews
A free/libre code and information platform for reviews of anything
Stars: ✭ 90 (-19.64%)
Mutual labels:  rethinkdb
Parabol
Free online agile retrospective meeting tool
Stars: ✭ 1,145 (+922.32%)
Mutual labels:  rethinkdb
Spectrum
Simple, powerful online communities.
Stars: ✭ 10,315 (+9109.82%)
Mutual labels:  rethinkdb
Rom Http
Abstract HTTP adapter for ROM
Stars: ✭ 65 (-41.96%)
Mutual labels:  adapter
Efficientadapter
一个可以提高开发效率的adapter
Stars: ✭ 78 (-30.36%)
Mutual labels:  adapter
Recyclerviewpresenter
RecyclerView Adapter Library with different models and different layouts as convenient as possible.
Stars: ✭ 86 (-23.21%)
Mutual labels:  adapter
Elixir Cowboy React Spa
Example application that shows how to use Cowboy 2.0 in conjunction with React and Redux to create data driven Single Page Applications
Stars: ✭ 112 (+0%)
Mutual labels:  ecto

RethinkDB.Ecto

Travis Hex.pm Documentation Status GitHub license Github Issues

RethinkDB adapter for Ecto 2.1.x (see issue #41 for Ecto 2.2.x support).

Installation

Add :rethinkdb_ecto to your list of dependencies in mix.exs:

def deps do
  [{:rethinkdb_ecto, "~> 0.7"}]
end

Finally, in the repository configuration, you will need to specify the :adapter:

config :my_app, MyApp.Repo,
  adapter: RethinkDB.Ecto,
  ...

Setup

First, create you repository with mix ecto.gen.repo and add the repository to you config:

config :my_app, ecto_repos: [MyApp.Repo]

Start the repository as a supervisor on your application’s supervisor:

def start(_type, _args) do
  import Supervisor.Spec

  children = [
    supervisor(MyApp.Repo, [])
  ]

  opts = [strategy: :one_for_one, name: MyApp.Supervisor]
  Supervisor.start_link(children, opts)
end

Define your schema:

defmodule User do
  use Ecto.Schema

  # You must define your primary-key and foreign-key types as :binary_id
  @primary_key {:id, :binary_id, autogenerate: false}
  @foreign_key_type :binary_id

  schema "users" do
    field :name, :string
    field :age, :integer
    has_many :posts, Post
    timestamps
  end
end

And the matching migration:

defmodule UserMigration do
  use Ecto.Migration

  def change do
    create table("users")
    create index("users", [:name])
  end
end

Create the database and apply migrations:

$ mix ecto.create
$ mix ecto.migrate

You are ready to go.

Usage

The adapter supports almost all of Ecto.Query functions. This includes group-by and order-by clauses, aggregators, ranges, complex filter and select queries, etc.

Start a IEx shell and run a few basic queries:

iex(2)> MyApp.Repo.insert %Post{title: "Ecto is great!"}
iex(3)> MyApp.Repo.one Post

You can build relationships using :belongs_to, has_one, has_many, etc. in your schema definitions and use them to load associations:

iex(4)> MyApp.Repo.all(Post) |> MyApp.Repo.preload(:comments)

RethinkDB.Ecto provides support for :inner_join (default), which means that you can preload relationships within a single query:

iex(5)> MyApp.Repo.all from p in Post,
...(5)>               join: u in assoc(p, :author),
...(5)>               join: c in assoc(p, :comments),
...(5)>              where: u.name == "Theresia",
...(5)>            preload: [author: u, comments: c]

Limitations

Check the known limitations section in the RethinkDB.Ecto documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].