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
Quiero saber por qué la matriz de registro no devuelve al usuario especificado con la identificación dada.
 app.get("/api/users/:_id/logs", (req, res) => { const id = req.params._id; const { from, to, limit } = req.query;

** Aquí traté de buscar el usuario coincidente y funciona con éxito: **

 User.findById({ _id: id }, (err, user) => { if (!user || err) { res.send("Unknown User Id !!"); } else {

** Luego traté de filtrar la matriz de registro con la fecha **

 // const username = user.username; let responObject = {}; if (from) { responObject["$gte"] = new Date(from).toDateString(); } if (to) { responObject["$lte"] = new Date(to).toDateString(); } let filter = { _id: id, }; if (from || to) { filter.date = responObject; } let nonNullLimit = limit ?? 500;

** intente construir el registro de matriz y devolvérselo al usuario, pero siempre estará vacío y nunca devolverá los ejercicios para el usuario **

 Exercise.find(filter) .limit(+nonNullLimit) .exec((err, data) => { if (err || !data) { res.json([]); } else { const count = data.length; const rowLog = data; const { username, _id } = user; const log = rowLog.map((item) => ({ description: item.description, duration: item.duration, date: new Date(item.date).toDateString(), })); console.log(log) if (from && to) { res.json({ username, from: new Date(from).toDateString(), to: new Date(to).toDateString(), count, _id, log, }); } else { res.json({ username, count, _id, log, }); } } }); } }); });

este es el resultado cuando trato de registrar todos los ejercicios para el usuario {"username":"ahmed","count":0,"_id":"62a9aab2743ddfc9df5165f2","log":[]}

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!