I'm currently working with mongodb (mongoose). One of my example documents is:
myuser{
_id: 7777...,
money: 1000,
ships:[{
_id: 7777...
name: "myshipname",
products:[{
product_id: 7777....,
quantity: 24
}]
}
}
What I aim to do is to get a certain product given user id, ship id and product id, being the result something like: { product_id: 777..,quantity:24}
So far I got to find a certain user ship with:
findOne(userId,ships:{ $elemMatch: {_id:shipId}})
Which returns the information of the ship with shipId inside the array ships from user with userId. However, I cannot find the way to get only a certain product from that ship