I have the following variable in my code:
const data = [
{ _id: "66324310da5f0f7575da0292", from: "66324110da5f0f7275cd8949" },
{ _id: "66324350sa5f0sdd575da0s92", from: "62a34303530f3275c3d99" }
]
I want to find all users where their _id
is equal to any from
value in the data
variable. The problem I have is that data
is an array of objects, and I want to query based on the from
property of all the objects within the array.
I have tried the following code:
User.updateMany({_id: {$in: data})
However, this doesn’t work as it isn’t specifically checking the from
attribute, and data
is an array of objects.
Any other ways I can accomplish this? Thanks.