Open benfurber opened 3 weeks ago
why is _deleted
an issue?
a onWrite function for the discussion could filter that for the totalCommentCount
update
There are definitely alternative bottom-up functions that could be done to fulfill the same brief:
Pros and cons of both approaches and I don't really mind which. Mainly just detailed the first approach I thought of in case a new contributor fancied picking this up. :)
Thinking more on this, having a background job is a good enough solution for now.
As an alternative/complement to the proposed solution:
Due to the move to discussion documents holding the comments for each research update and changing comments from being deleted from the DB to be updated to
_deleted
, it's much more common and noticiable that the comment count stored for each research articles (totalCommentCount
) gets out of sync with the reality.Solution: Accept that certain changes in data will be fallible and have a cloud function that runs daily for research that:
_deleted
and published research articles._deleted
updates for each article._id
of an update being thesourceId
of the discussion).That should then give a total that can be set as the
totalCommentCount
for the research.