如何检索3天内(从发布日期起)的所有文档?如何检索3天前的文档?
东西类似于SQL给定: Checking if date is more than 3 years old in PostgreSQL
SELECT * FROM foos WHERE date < '3 days'::interval;
如何检索3天内(从发布日期起)的所有文档?如何检索3天前的文档?
东西类似于SQL给定: Checking if date is more than 3 years old in PostgreSQL
SELECT * FROM foos WHERE date < '3 days'::interval;
db.collection.find({created_at : {$gt : <fill in the date of the day before three days back in the right format> })
应该工作
我假设字段created_at存在于您的文档 – Hrishi
我想动态地做到这一点。由于每个结果都有自己的created_at列 –
我真的不知道红宝石,从来没有编程它,但是你不能只是http: //ruby-doc.org/stdlib-2.0.0/libdoc/date/rdoc/Date.html与一个ISODate的mongoid表示? – Sammaye