So this is how my document looks like right now. And what I am trying to do is to push an element to an array which is located comments -> comment -> replies -> reply -> likes
{
_id: "5afa9d1a20baf95e03921a10",
comments: [
{
commentID: "67917200-67ca-11e8-85f8-49f00c21219a",
likes: [ ],
dislikes: [ ],
replies: [
{
replyID: "6c6e41e0-67ca-11e8-85f8-49f00c21219a",
likes: [
// this is the array I would like to update
],
dislikes: [ ]
}
]
}
]
},
I am successful when updating one level nested array but I do not understand why I cannot update this array the same way.
Right now my query looks like this.
db.collection.update(
{
"_id" : _id,
"comments.commentID" : cid,
"comments.replies.replyID" : rid },
{
$push : { "comments.replies.$.likes" : uid }
}
)
When trying to send a request with Postman it just freezes and I have to cancel the request.