【发布时间】:2016-06-13 17:20:28
【问题描述】:
来自 Rails Active Record 我想知道如何才能真正获取今天创建的记录。
在 Rails 中我们可以这样做
User.where(created_at:Date.today.beginning_of_day..Date.today.end_of_day)
或者更简洁
scope :created_today, ->(date = Date.today) { where(created_at: date..date.end_of_day) }
User.created_today
用 Ecto 实现相同功能的最佳方法是什么?
【问题讨论】:
-
您想在哪个时区计算“今天”? UTC,当前系统的默认值,还是特定的?
-
当前系统的默认值
标签: elixir phoenix-framework ecto