0

I have the following collection :

order

I use the following code to remove the element of the orderList array that matches the orderId. But it doesn't work.

Order.update({"_id":ObjectId(userOrder._id)},{"$pull":{"orderList":{orderId: "WPN-1645691337205"}}});

and I tried the following code as well

Order.update({"_id:":ObjectId("621741dcd40da387489093c2")}, {$unset : {"orderList.0" : 1 }});

Order.update({"_id:":ObjectId("621741dcd40da387489093c2")}, {$pull:{"orderList":null}});

Thanks, Jo

1 Answer 1

0

Try this:

Order.update(
  { _id: ObjectId(userOrder._id)},
  { $pull: { orderList: { orderId: "WPN-1645691337205" } } },
  function(error, response) {}
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.