如何檢索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