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

前端 未结 2 435
借酒劲吻你
借酒劲吻你 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:35

    you can also do this, which should be more efficient:

    articles = Article.where(:"comments.created_at".gt => 20.minutes.ago)
    

提交回复
热议问题