Answers for "how to get array object value in mongodb"

0

how to get array object value in mongodb

db.products.aggregate([
    {$unwind: "$ratings"},
    {$match: {'ratings.user': ObjectId("5f6e2e0b70eb0208fc8401a1")}}
])
Posted by: Guest on September-25-2020
0

how to get array object value in mongodb

db.test.aggregate([
    {$match: {'shapes.color': 'red'}},
    {$project: {
        shapes: {$filter: {
            input: '$shapes',
            as: 'shape',
            cond: {$eq: ['$$shape.color', 'red']}
        }},
        _id: 0
    }}
])
Posted by: Guest on September-25-2020

Code answers related to "how to get array object value in mongodb"

Browse Popular Code Answers by Language