4
在Rails AR可以运行这样的疑问:如何执行ActiveRecord的查询current_user.articles等同于Ecto?
current_user.articles # fetch all articles from current_user
SELECT * from articles where user_id = <user_id>;
有同等的方式与外生做到这一点?
在Rails AR可以运行这样的疑问:如何执行ActiveRecord的查询current_user.articles等同于Ecto?
current_user.articles # fetch all articles from current_user
SELECT * from articles where user_id = <user_id>;
有同等的方式与外生做到这一点?
articles = Repo.all(from a in assoc(current_user, :articles))
或预装物品进入用户
current_user = Repo.preload(current_user, [:articles])
current_user.articles