Property 'pull' does not exist on type 'ObjectId[]'

moongose
moongose
typescript
typescript
I want to remove from an Array list and this is the error I am getting when I tried to use the
PULL
PULL
method, please how do i resolve this error ?
3 Replies
ErickO
ErickO3y ago
never seen pull before not as a function at least you can use update instead and inside the update add the $pull property mongo has it seems to me that is used for sub-documents not just any array
ErickO
ErickO3y ago
ErickO
ErickO3y ago
pull only exists for document arrays not arrays of object ids what you need is more along the lines of mydocument.updateOne({userId: someId}, {$pull: {favorites: {_id: favoriteId} } })
Want results from more Discord servers?
Add your server