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

189
Views
Filtrado de resultados poblados

Me pregunto si puedo filtrar el array de visits , para no duplicar patient en las visitas (no tiene sentido si me sale un paciente y en sus visitas está su id). Quería filtrarlo pero dice patient.aggregate is not a function . ¿No puedo usar agregados aquí?

 router.get("/:id", async (req,res) => { try { await Patient.findById(req.params.id) .populate('visits') .exec((err, patient) => { if (err) { return res.status(500).send("Error") } else { const patientFiltered = patient.aggregate([ { $project: { city: 1, country: 1, dateOfBirth: 1, firstName: 1, lastName: 1, married: 1, points: 1, visits: { $filter: { cost: 1, date: 1, doctor: 1 } } } } ]) return res.send(patientFiltered) } }) } catch (err) { return res.send(err) } })

salida de corriente:

 { "__v": 0, "_id": "619e777b1b7c2e173140c920", "city": "Praga", "country": "CZ", "dateOfBirth": "1999-12-12T00:00:00.000Z", "firstName": "Al", "lastName": "Varo", "married": true, "points": 99, "visits": [ { "__v": 0, "_id": "619ea657697f46c16cbde582", "cost": 20, "date": "2021-11-24T00:00:00.000Z", "doctor": [ "619ea1139218eae32f3f8111" ], "patient": [ "619e777b1b7c2e173140c920" ] } ] }
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!