1

How to push element to marked array?

enter image description here

1
  • see how to ask question, 1) post some sample document in json instead of image, 2) post what you have tried? 3) after try what is the error you are getting. Commented Feb 28, 2021 at 9:47

1 Answer 1

2

just try

let commentId = "",
let replies = ""
Model.update(
  { comment: { $elemMatch: { _id: commentId } } },
  {
    $push: { "comment.$.replies": replies  },
  }
);

playground

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.