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

130
Views
Cómo generar una identificación automática para un objeto anidado usando una publicación http en expressJs

Investigué, pero la respuesta estaba relacionada con la identificación generada automáticamente usando mongodb, no express y no para un objeto anidado.

Me pregunto si alguien me ayuda a generar la identificación automática para un objeto anidado dep4.id presente en

mi archivo server.js

 function create() { let shop = {}; shop.id = "shop1"; shop.departmentList = []; let dep1 = {}; dep1.id = "d1" dep1.name = "my department 1"; shop.departmentList.push(dep1); let dep2 = {}; dep2.id = "d2" dep2.name = "my department 2"; dep2.departmentVariationList = []; let dep2v1 = {}; dep2v1.id = "dep2v1" dep2v1.name = "my department variation dep2v1"; dep2.departmentVariationList.push(dep2v1); //shop.departmentList.push(dep2); let dep2v2 = {}; dep2v2.id = "dep2v2" dep2v2.name = "my department variation dep2v2"; dep2.departmentVariationList.push(dep2v2); shop.departmentList.push(dep2); let dep3 = {}; dep3.id = "d3" dep3.name = "my department 3"; shop.departmentList.push(dep3); return shop; }

Información: Aquí estoy agregando el departamento 4 usando cartero y quiero generar una identificación automática para el departamento 4 y así sucesivamente.

 app.post('/shops/:shopId', (req, res) => { const shop = req.body; let shopId = req.params.shopId; if (shopId === "shop1") { shop1 = req.body; } else { shop2 = req.body; } });

Su tiempo y ayuda serán realmente apreciados. Gracias :)

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!