我想在字段类型哈希参考示例代码的多个键上应用过滤器
######工作代码class Model
include Mongoid::Document
field :lD, as: :load_date, type:Time
field :cls, as: :classification, type:Hash
def self.base_filter(filters)
Model.where("cls.#{filters}.r"=>true,"cls.#{filters}.t"=>"news",:load_date.gte=>1.month.ago).count
end
end
######期望但不是工作代码
class Model
include Mongoid::Document
field :lD, as: :load_date, type:Time
field :cls, as: :classification, type:Hash
def self.base_filter(filters)
Model.where("cls.#{filters}"=>{'r'=>true,'t'=>"news"},:load_date.gte=>1.month.ago).count
end
end
是否有类似的东西在MongoID中可用或者它在MongoDB中可用而不是我如何从MongoID调用它