将项目模块导入IEX会话 [英] Import project module into IEX session

查看:50
本文介绍了将项目模块导入IEX会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 MyApp 的应用程序,每当我通过 iex -S mix 打开IEx会话时,都必须像这样调用存储库: MyApp.Repo.all(MyApp.User).

I have an application called MyApp and whenever I open an IEx session via iex -S mix I have to call the repo like this: MyApp.Repo.all(MyApp.User).

如果可以自动导入项目模块,以便只需要执行 Repo.all(User)来获得与上述相同的值,我会喜欢的.

I would love it if I could automatically import the project module so that I only have to do this Repo.all(User) to get the same value as above.

有没有办法做到这一点?

Is there a way I can accomplish this?

推荐答案

您可以使用使用en .iex.exs文件进行别名.您创建文件并添加:

You can use the aliases with en .iex.exs file. You create the file and add:

# .iex.exs
alias MyApp.Repo

这将为您设置这些别名.该文件还有您可以做的其他事情,例如设置变量,或添加一些shell配置.

And that will set these aliases for you. There are other things you can do with that file, like set variables up, or add some shell configuration.

这篇关于将项目模块导入IEX会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆