Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda