Querying an array in MongoDB?

问答 Zach ⋅ 于 3个月前 ⋅ 211 阅读

Test data
   

db.multiArr.insert({"ID" : "fruit1","Keys" : [["carrot", "banana"]]})
db.multiArr.insert({"ID" : "fruit2","Keys" : ["apple", "orange"]})
db.multiArr.insert({"ID" : "fruit2","Keys" : ["apple"]})

How do I query for Keys in ["apple", "orange", "carrot"]?
Need

 ({"ID" : "fruit2","Keys" : ["apple", "orange"]})
 ({"ID" : "fruit2","Keys" : ["apple"]})

Thanks.

本文章首发在 Laravel China 社区
成为第一个点赞的人吧 :bowtie:
回复数量: 0
    暂无评论~~

      请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!