almightycouch / rethinkdb_ecto

RethinkDB adapter for Ecto.
https://hexdocs.pm/rethinkdb_ecto
MIT License
114 stars 18 forks source link

Recommended method for ReQL specific commands? #10

Closed brezal closed 8 years ago

brezal commented 8 years ago

Hi @almightycouch! Thanks for putting this together. What are your thoughts on working with changefeeds, geospatial queries, and other RethinkdDB specific operations?

almightycouch commented 8 years ago

Currently there is no way to run such operations via Ecto DSL. You may want to use RethinkDB.run/2 which is available as shortcut in your repository:

defmodule MyApp.Repo do
  use Ecto.Repo, otp_app: :my_app
end

import RethinkDB.Query

feed =
  table("users")
  |> changes
  |> MyApp.Repo.run

This is not perfect, and in future it may be possible to use Ecto.Schema to run such queries:

import RethinkDB.Query

feed =
  MyApp.User
  |> MyApp.Repo.changes
  |> MyApp.Repo.run

or even

import RethinkDB.Query

feed =
  from(u in MyApp.User, where: u.age > 18)
  |> MyApp.Repo.changes
  |> MyApp.Repo.run