Find Documents in MongoDB whose with an array field is a subset of a query array

前端 未结 3 2005
没有蜡笔的小新
没有蜡笔的小新 2020-12-16 22:40

Suppose I have a insert a set of documents each with an array field. I would like to find all documents such that their array field is a subset of

3条回答
  •  猫巷女王i
    2020-12-16 23:22

    In MongoDb, for array field:

    "$in:[...]" means "intersection" or "any element in",
    "$all:[...]" means "subset" or "contain",
    "$elemMatch:{...}" means "any element match"
    "$not:{$elemMatch:{$nin:[...]}}" means "superset" or "in"
    

提交回复
热议问题