How to use elemMatch to match nested array

前端 未结 2 1997
忘了有多久
忘了有多久 2021-01-02 09:37

I have some data structure like this

{
  a: 1,
  array1: [
    {
      b: 2
      array2: [
        { 
          // this is my target
          c: 3,
                


        
2条回答
  •  醉酒成梦
    2021-01-02 09:43

    try this,it help me a lot.

    { 
      "array1": {
        "$elemMatch": {
          "array2": {
            "$elemMatch": {
              "c": 3
            }
          }
        }
      }
    }
    

提交回复
热议问题