Suppose, I have an Article and Comment.
a1 = Repo.get(Article, 123)
cm1 = a1.comments
cm2 = get_new_comments()
Enum.each(fn c ->
# insert comment to Article a1
end)
# ??? how to reload a1 without additional overhead?
I already have loaded a1
and I have a list
of new comments. After inserting the new comments, how can I make a1 change its state such that it becomes aware of the new comments.
I could do that by callling Repo.get(Article, 123)
again. My question, however, how to avoid this additional db request?