【发布时间】:2017-07-10 11:17:20
【问题描述】:
在 ruby on rails(active record) 中,我们可以通过调用来更新计数器
update_counter 方法。例如在 rails 你只需要写:
# For the Post with id of 5, decrement the comment_count by 1, and
# increment the action_count by 1
Post.update_counters 5, :comment_count => -1, :action_count => 1
# Executes the following SQL:
# UPDATE posts
# SET comment_count = comment_count - 1,
# action_count = action_count + 1
# WHERE id = 5
考虑到我必须更新多列的计数器,是否有任何简单的方法可以在 elixir/phoenix 中执行此操作?
【问题讨论】:
-
请随时更新或提出任何改进问题的建议。谢谢
-
请谨慎选择标签。 phoenix与本题无关。
-
当然@mudasobwa。感谢您的建议。
-
虽然没有必要删除phoenix-framework :)
标签: ruby-on-rails elixir phoenix-framework ecto