Hi,
I’m having trouble updating my data. I’ve created two objects, “send” and “received.” While I can successfully update the “isRead” field in the “messages” array for the “send” object, I’m facing challenges updating the same field for the “received” object.
Below is my data.
I’ve tried various solutions involving updateOne and arrayFilters, but I consistently receive a “not-found” error.
If anyone could provide guidance on how to achieve this, I would greatly appreciate it.
"_id": "658c328bcc61d05e51becd32",
"fieldName": "send",
"user": [
{
"userID": "658c32bbcc61d05e51becd38",
"userEmail": "bartek@wp.pl",
"_id": "658c32bccc61d05e51becd3b",
"messages": [
{
"_id": "658d64c4d8b190b753ebb251",
"to": "658c32bbcc61d05e51becd38",
"from": "658c32decc61d05e51becd42",
"sender": "bartek",
"recipient": "jacek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 13:06:28",
"updatedAt": "2023.12.28 13:06:28"
},
],
"createdAt": "2023.12.27 15:20:44",
"updatedAt": "2023.12.27 15:20:44"
},
{
"userID": "658c32decc61d05e51becd42",
"userEmail": "jacek@wp.pl",
"_id": "658c32decc61d05e51becd45",
"messages": [
{
"_id": "658d8b5514fe15ea4ea78b8d",
"to": "658c32decc61d05e51becd42",
"from": "658c32bbcc61d05e51becd38",
"sender": "jacek",
"recipient": "Bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 15:51:01",
"updatedAt": "2023.12.28 15:51:01"
},
{
"_id": "658d8ba914fe15ea4ea78b91",
"to": "658c32decc61d05e51becd42",
"from": "658c32bbcc61d05e51becd38",
"sender": "jacek",
"recipient": "Bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 15:52:25",
"updatedAt": "2023.12.28 15:52:25"
}
],
"createdAt": "2023.12.27 15:21:18",
"updatedAt": "2023.12.27 15:21:18"
},
{
"userID": "658c32eecc61d05e51becd4b",
"userEmail": "robert@wp.pl",
"_id": "658c32efcc61d05e51becd4e",
"messages": [],
"createdAt": "2023.12.27 15:21:35",
"updatedAt": "2023.12.27 15:21:35"
}
],
"__v": 3
},
{
"_id": "658c3296cc61d05e51becd34",
"fieldName": "received",
"user": [
{
"userID": "658c32bbcc61d05e51becd38",
"userEmail": "bartek@wp.pl",
"_id": "658c32bccc61d05e51becd3b",
"messages": [
{
"_id": "658d612386c9b5e7dcbb7662",
"to": "658c32bbcc61d05e51becd38",
"from": "658c32decc61d05e51becd42",
"sender": "jacek",
"recipient": "bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 12:50:59",
"updatedAt": "2023.12.28 12:50:59"
},
{
"_id": "658d6194d8b190b753ebb229",
"to": "658c32bbcc61d05e51becd38",
"from": "658c32decc61d05e51becd42",
"sender": "jacek",
"recipient": "bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 12:52:52",
"updatedAt": "2023.12.28 12:52:52"
},
{
"_id": "658d892514fe15ea4ea78b65",
"to": "658c32bbcc61d05e51becd38",
"from": "658c32decc61d05e51becd42",
"sender": "jacek",
"recipient": "Bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 15:41:41",
"updatedAt": "2023.12.28 15:41:41"
},
{
"_id": "658d893314fe15ea4ea78b69",
"to": "658c32bbcc61d05e51becd38",
"from": "658c32decc61d05e51becd42",
"sender": "jacek",
"recipient": "Bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 15:41:55",
"updatedAt": "2023.12.28 15:41:55"
},
{
"_id": "658d8ba914fe15ea4ea78b90",
"to": "658c32bbcc61d05e51becd38",
"from": "658c32decc61d05e51becd42",
"sender": "jacek",
"recipient": "Bartek",
"subject": "subject",
"content": "content",
"isRead": false,
"isReply": false,
"createdAt": "2023.12.28 15:52:25",
"updatedAt": "2023.12.28 15:52:25"
}
],
"createdAt": "2023.12.27 15:20:44",
"updatedAt": "2023.12.27 15:20:44"
},
{
"userID": "658c32decc61d05e51becd42",
"userEmail": "jacek@wp.pl",
"_id": "658c32decc61d05e51becd45",
"messages": [],
"createdAt": "2023.12.27 15:21:18",
"updatedAt": "2023.12.27 15:21:18"
},
{
"userID": "658c32eecc61d05e51becd4b",
"userEmail": "robert@wp.pl",
"_id": "658c32efcc61d05e51becd4e",
"messages": [],
"createdAt": "2023.12.27 15:21:35",
"updatedAt": "2023.12.27 15:21:35"
}
],
"__v": 3
}