如何检索3天的文档?

时间:2013-09-23 10:31:32

标签: mongodb mongoid

如何检索3天前的所有文件(从发布之日起)?

与SQL中给出的类似的东西: Checking if date is more than 3 years old in PostgreSQL

SELECT * FROM foos WHERE date < '3 days'::interval;

1 个答案:

答案 0 :(得分:0)

db.collection.find({created_at : {$gt : <fill in the date of the day before three days back  in the right format> })

应该有效