Hi @anidotnet, I hope you're well :)
Today I faced a crash with Nitrite 3.4.2 where a field of a nested document was missing next after I wished to update another field of this nested document, I explain.
I have a repository of conversations containing an unread counter document which contains a me and an other counter.
Model is as follow:
"conversation": {
"unread": {
"me": int,
"other": int
}
}
What I would liked to achieve is for instance reset the me counter to 0 as I mark all my conversations as read without touching the other counter which keeps track of my sent messages not read by others.
What I've done is created an unread document containing only a me field set to 0 and update all the repository with it:
Document unreadDoc = new Document();
document.put("me", 0);
Document convDoc = new Document();
convDoc.put("unread", unreadDoc);
repository.update(ObjectFilters.ALL, convDoc);
So it looks like:
{
"unread": {
"me": 0
}
}
But every conversation of the repository now is laking the unread.other field which led me to a crash when querying the repository because null value cannot be cast to an int.
So is there a way to achieve a batch update of a field of a nested document without losing its other fields?
Thanks in advance and have a good day :)
Hi @anidotnet, I hope you're well :)
Today I faced a crash with Nitrite
3.4.2where a field of a nested document was missing next after I wished to update another field of this nested document, I explain.I have a repository of
conversationscontaining anunreadcounter document which contains ameand anothercounter.Model is as follow:
What I would liked to achieve is for instance reset the
mecounter to0as I mark all my conversations as read without touching theothercounter which keeps track of my sent messages not read by others.What I've done is created an
unreaddocument containing only amefield set to0and update all the repository with it:So it looks like:
But every
conversationof the repository now is laking theunread.otherfield which led me to a crash when querying the repository becausenullvalue cannot be cast to anint.So is there a way to achieve a batch update of a field of a nested document without losing its other fields?
Thanks in advance and have a good day :)