【发布时间】:2015-04-16 09:11:07
【问题描述】:
我有很多 access_tokens 存储在 Mongoid4 中。我想根据expires_in 字段(以秒为单位)和created_at 字段(时间类型)查询所有过期和未过期的令牌。
这两个字段如下所示:
field :created_at, type: Time
field :expires_in, type: Integer
我知道我可以像 Doorkeeper::AccessToken.where(created_at: (3.days.ago..Time.now)) 这样按日期查询。
但是如何在一个查询中比较 created_at 字段和 expires_in 字段?我想拥有所有访问令牌,其中created_at 字段加上来自expires_in 的秒数与Time.now 相比更小或更大。这甚至可能吗?还是我必须遍历所有条目,然后手动选择它们?
【问题讨论】:
标签: mongodb mongoid access-token doorkeeper