how to get data from an array in mongodb using find function code example
Example 1: how to get array object value in mongodb
db.products.aggregate([
{$unwind: "$ratings"},
{$match: {'ratings.user': ObjectId("5f6e2e0b70eb0208fc8401a1")}}
])
Example 2: fetching data from inside an array in mongodb
db.users.find( { name: "John"}, { items: { $elemMatch: { item_id: "1234" } } })