我尝试了几种方法来尝试这样做但没有一种方法可以工作:
User.where(name:"Jon Sparks").first.purchased_items.where
('(month = 5 AND year = 2012) OR (month = 6 AND year = 2012)')
User.where(name:"Jon Sparks").first.purchased_items.any_of
({:month => 5, :year => 2012}, {:month => 6, :year => 2012})
我想要做的是在5/2012或6/2012中提取所有purchased_items
个嵌入式文档。
答案 0 :(得分:0)
这是您的查询
User.where(:name => "JohnSparks").first.purchased_items.where(:year => 2012, :month.in => [5,6])