I'm working on my project and facing a problem in deleting a element in an array of objects

31 Views Asked by At

I'm working on my project and facing a problem in deleting a element in an array of objects ,the mongoose function run without error but the targated element won't delete at all .Help me with the code.

i want to delete the element of document(user) having _id->requestedUser and element having the postId -> requestedPost .

here is the img of code enter image description here

1

There are 1 best solutions below

1
Tornike Skhulukhia On

Problem may be that you pass requestedPost object directly as postId value, probably you should get exact id of post from it.

Similar example that works https://mongoplayground.net/p/CO5qR1RdbuL