Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!