I'm just learning Phoenix and Elixir and I'm coming from Ruby/Rails where I work in the REPL using pry
to inspect my database and application state.
I'm trying to figure out how to interact with my database and models in a Phoenix app. I'm aware of iex
, but I don't know how to use it inspect my app's database from the repl. Do I need to connect to it with ecto each time from the repl? Is there a rails console
equivalent. I've checked the Phoenix docs, Elixir Dose, and the Ecto repo, but can't find what I'm looking for. Am I missing something?
Edit: Based on the answer below I found this section of the ecto docs. Based on this I can do something like ArticlesApi.Repo.all ArticlesApi.Article
alias ArticlesApi.{Repo, Article}
. Also, keep in mind that you can very conveniently recompile individual modules from your console (r Article
), or recompile the whole project usingrecompile
. This allows you to leave aniex
session open all the time, keeping aliases active. – hmans