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

158
Vistas
Mongo { current_tracking_number: null } dupplicate key error

I'm getting this mongo duplicate key error when the following code executes. Basically, it creates a new storeAdmin document and saves it. After that, it creates a new restaurant document and assigns the previously created store admin's id to the storeAdminID field.

When the restaurant collection is empty it executes without giving an error. But when there is at least one document it gives me the above error. There is no field called current_tracking_number in any of my schemas.

    // create a new  store admin
    const newStoreAdmin = new StoreAdmin({
      ...userData,
    });

    await newStoreAdmin.save();

    // create a new restaurant for the store admin
    const restaurant = new Restaurant({
      storeAdminID: newStoreAdmin._id,
    });

    await restaurant.save();

    // assign the newly created store admins id to the restaurant document

    newStoreAdmin.restaurantID = restaurant._id;
    await newStoreAdmin.save();
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