Answer the question
In order to leave comments, you need to log in
How to update values in an array of objects?
It is required to update the values of some elements in the array with an object
For example, there is a document
{
"url": "link",
"comments": [{
"user": "user1",
"field": 1
},{
"user": "user1",
"field": 1
},{
"user": "user2",
"field": 1
},{
"user": "user3",
"field": 1
}]
}
Answer the question
In order to leave comments, you need to log in
In fact, the field field is a checkbox for sending notifications, i.e. 0 do not send a response to the user, 1 send.
{
comments: [],
flags: {
user1: true,
user2: false
}
}
With this structure, you can enable/disable the flag by user for all comments (the entire document), and if you need the ability to switch specific comments, you can store user-comment side by side ( flagsByComments:{ user2: {comment1: true, comment2: false} }). Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question