Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

92
Visualizações
How to ensure minimum value during both creation and deletion in mongodb?

Consider:

  1. Summary schema with a minimum_score property
  2. PersonRecord schema with a score property
  3. A single Summary document should contain minimum_score of all the PersonRecord documents.

Following two actions are done in a transaction:

  1. Insertion of new document in PersonRecord collection
  2. Update Summary 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:

  1. All of the persons delete their PersonRecord documents
  2. One person deletes his PersonRecord 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?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda