Find in Double Nested Array MongoDB

前端 未结 2 1413
误落风尘
误落风尘 2020-11-22 00:55

I have this Collection in mongodb

{
\"_id\" : \"777\",
\"someKey\" : \"someValue\",
\"someArray\" : [
    {
        \"name\" : \"name1\",
        \"someNeste         


        
2条回答
  •  隐瞒了意图╮
    2020-11-22 01:29

    You can also try something like below:

    db.collection.aggregate(
        { $unwind: '$someArray' },
        {
            $project: {
                'filteredValue': {
                    $filter: {
                      input: "$someArray.someNestedArray",
                      as: "someObj",
                      cond: { $eq: [ '$$someObj.name', 'delete me' ] }
                    }
                }
            }
        }
    )
    

提交回复
热议问题