1

I want to query on the 3rd level nested array of objects using mongodb first and then want to implement the same with mongoose. In the below json which is stored as a document, I want to fetch the document which have products metadata with {"value" : "abc"}.

As the below json is containing nested multiple arrays so I am not able to find the right solution for it.

{
    "_id" : "12341234",
   "products" : [ 
        {
            "productCode" : "P05-02",
            "type" : "XX",
            "metaData" : [ 
                  [ 
                    {
                        "keyName" : "CUS_NME",
                        "isPrimary" : false,
                        "displayName" : "Customer Name",
                        "value" : "abc"
                    },
                   {
                        "keyName" : "CUS_DOB",
                        "isPrimary" : true,
                        "displayName" : "Customer DOB",   
                    }
                  ],
                  [ 
                    {
                        "keyName" : "CUS_NME",
                        "isPrimary" : false,
                        "displayName" : "Customer Name",
                        "value" : "xyz"
                    },
                   {
                        "keyName" : "CUS_DOB",
                        "isPrimary" : true,
                        "displayName" : "Customer DOB",
                    }
                  ]
                 ]
    }
  ]
}
Sandeep Ghosh
  • 291
  • 2
  • 10

0 Answers0