How would I grab only articles with comments that were created 20 minutes ago?

前端 未结 2 436
借酒劲吻你
借酒劲吻你 2021-01-16 08:44

Using mongodb and mongoid. How would one grab all articles. Only articles with comments created 20 minutes ago?

class Article
  include Mongoid::Document

           


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-16 09:29

    articles = Article.where(:_id.in => Comment.where(:created_at => 20.minutes.ago).map(&:article_id))
    

提交回复
热议问题