是否有菲尼克斯相当于Rails Console [英] Is there a Phoenix equivalent to Rails Console
问题描述
我刚刚学习Phoenix和Elixir,我来自Ruby/Rails,在那我使用pry
在REPL中工作,以检查我的数据库和应用程序状态.
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.
我试图弄清楚如何在Phoenix应用程序中与数据库和模型进行交互.我知道iex
,但是我不知道如何使用它来从repl检查我的应用程序数据库.每次从repl时都需要用ecto连接到它吗?是否有rails console
等效项.我已经检查了Phoenix文档,Elixir Dose和Ecto回购,但是找不到我想要的东西.我想念什么吗?
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?
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
推荐答案
您可以运行iex -S mix
来运行iex
并包含当前混合项目中的依赖项.您可以在http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix .html
You can run iex -S mix
to run iex
with the dependencies in your current mix project included.. You can read about this at http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html
您可以从此处执行Ecto查询:
From there you can execute Ecto queries:
iex> MyApp.Repo.all(MyApp.User)
运行iex -S mix phoenix.server
还将启动phoenix服务器.
Running iex -S mix phoenix.server
will also start the phoenix server.
这篇关于是否有菲尼克斯相当于Rails Console的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!