hamiltop / rethinkdb_ecto

Shim library for using Ecto with RethinkDB. Not a full adapter.
24 stars 4 forks source link

Where to put connection code? #2

Open gilbert opened 8 years ago

gilbert commented 8 years ago
def MyConnection do
  use RethinkDB.Ecto.Connection
end

Where does the above code go in a Phoenix project? How does it relate to Ecto.Repo, if at all?

I'm new to Phoenix, so these are probably beginner questions; I'll be happy to make a PR to the readme with your answers if applicable :)

hamiltop commented 8 years ago

This is super expermental, so keep that in mind.

MyConnection in your example is a RethinkDB connection with a few extra methods to make it act like an Ecto Repo. See https://github.com/hamiltop/rethinkdb-elixir#default-connection for how to add it to a supervision tree.

You then use MyConnection in place of an Ecto.Repo. MyConnection.get(Model, id) for example.