Consider:
Summary schema with a minimum_score propertyPersonRecord schema with a score propertySummary document should contain minimum_score of all the PersonRecord documents.Following two actions are done in a transaction:
PersonRecord collectionSummary document's minimum_score property using { $min: personRecord.score }However, there is another requirement to allow a person to delete his PersonRecord document. So consider the scenarios such as following:
PersonRecord documentsPersonRecord document while another person is inserting a new one.How can we handle the scenarios in mongodb (mongoose) if we ALWAYS want to have the correct minimum_score value in Summary document?
I can think of achieve this is using the principle of eventual consistency. Is there any other way?