Mongoid query for array field

前端 未结 4 729
余生分开走
余生分开走 2021-02-01 22:59

I have a category field of type Array in Mongoid.

Ex. category: [\"val1\",\"val2\",\"val3\"]

4条回答
  •  有刺的猬
    2021-02-01 23:09

    You can use Criteria all_in to make it simpler:

    Model.all_in(category: ['val1','val2'])
    

提交回复
热议问题