Mongoid query for array field

前端 未结 4 736
余生分开走
余生分开走 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:16

    In mongoid, there is '$in' operator. So you can do this :

    Model.where(category: { '$in': ['val1', 'val2'] })
    

提交回复
热议问题