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

260
Vistas
Generate Unique Sequential ID (starting from 1) with multi-user - Javascript

The application that I am building is being used by multiple users.

I am having a problem upon generating a unique ID.

My code runs like this: it will query the mongoDB for the length of all data and will add one to it so it will become unique and sequential. (For example, the database already have 40 data on it, now when the user clicked the save button, the function will get the length of the data which is 40 and it will add 1 to it. So the ID of the data will be 41.)

I encountered 2 problems. First, when the 2 user clicked the save button at the same exact time, both the data they created will have an ID of 41. Second, when the user doubled click the save button, it will still generate 2 data with both 41 as their ID.

I looked for an answer and I saw UUID but I need sequential ID that starts from 1 to infinite.

Can someone help me?

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