我在 model 使用include Mongoid::Timestamps::Created在数据库插入时间,怎么根据日期来作为查询条件,比如我要查询 2 月 24 号的记录,应该怎么办?
include Mongoid::Timestamps::Created
这种问题你应该查看 mongoid.org 里的 doc,这种问题不查文档就问人显得你太懒了
#1 楼 @mjf429 我查了但是没有查到!
http://mongoid.org/en/mongoid/docs/extras.html#timestamps http://mongoid.org/en/mongoid/docs/querying.html 看完这两条你就可以得出结论 where(:created_at.lte => yourdate ) lte == less than or equal gte == greater than or equal lt == less than gt == greater than 如果是等于呢,就直接:created_at => yourdate 所以看文档要一行行看,这是最基本的