$elemMatch

PHOTO EMBED

Fri Jun 28 2024 05:34:15 GMT+0000 (Coordinated Universal Time)

Saved by @CodeWithSachin #aggregation #mongodb #elemmatch #elem #match #$elemmatch

[
    {
        "$match": {
            "mealPlan": {
                "$elemMatch": {
                    "portionMeasure": "Tea Spoon",
                    "dishVariation": "Paneer Paratha"
                }
            }
        }
    },
    {
       $count:"toatal"
    }
]
content_copyCOPY

http://34.74.16.180:3000/question#eyJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjo2NSwibmF0aXZlIjp7ImNvbGxlY3Rpb24iOiJwYXJ0aWNpcGFudERpZXRNZWFsUGxhbkRldGFpbHMiLCJxdWVyeSI6IltcclxuICAgIHtcclxuICAgICAgICBcIiRtYXRjaFwiOiB7XHJcbiAgICAgICAgICAgIFwibWVhbFBsYW5cIjoge1xyXG4gICAgICAgICAgICAgICAgXCIkZWxlbU1hdGNoXCI6IHtcclxuICAgICAgICAgICAgICAgICAgICBcInBvcnRpb25NZWFzdXJlXCI6IFwiVGVhIFNwb29uXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgXCJkaXNoVmFyaWF0aW9uXCI6IFwiUGFuZWVyIFBhcmF0aGFcIlxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfSxcclxuICAgIHtcclxuICAgICAgICRjb3VudDpcInRvYXRhbFwiXHJcbiAgICB9XHJcbl1cclxuIiwidGVtcGxhdGUtdGFncyI6e319LCJ0eXBlIjoibmF0aXZlIn0sImRpc3BsYXkiOiJ0YWJsZSIsInZpc3VhbGl6YXRpb25fc2V0dGluZ3MiOnt9fQ==