I have following code that returns findOneAndUpdate response. But returnDocument: "after" not working properly when I'm using it with arrayFilters. If I remove arrayFilters it works fine. What causes this or is there a better way to get modified document in response?
const addStartingCards = async (lobbyId) => {
const res = await db.findOneAndUpdate(
{ lobbyId: lobbyId },
{
$push: {
"seats.$[el].cards": {
$each: [Math.floor(Math.random() * 52), Math.floor(Math.random() * 52)]
}
}
},
{
arrayFilters: [
{
"el.status": true,
}
]
},
{ returnOriginal: false, returnDocument: "after" });
return (res.value);
};