Hi,
This query works and returns an element.
db.Cart.find(
{ "items": { $elemMatch: { productId: "123", productType: "TSHIRT" } } }
)
But when I want to remove this item from the items array with the following statement:
This one doesn not work:
db.Cart.updateMany( { }, { $pull: { "items": { $elemMatch: { "productId": "123", "productType": "TSHIRT" } } } }
)
This one works:
db.Cart.updateMany( { }, { $pull: { "items": { "productType": "TSHIRT", "productId": "123" } } })
Why is this?
And I am using the JVM (scala driver) - So I need to translate it into Scala code. Still haven’t found a way to do that with the one statement that works.