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

164
Visualizações
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 à 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