0

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

invzbl3
  • 5,872
  • 9
  • 36
  • 76

1 Answers1

0

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

  • I'm getting the exact id ( checked by printing it in console) ,the whole function run without error but the array element is still there. – Rahul Bishnoi Oct 27 '22 at 08:25