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

119
Views
No puedo reemplazar el valor de una matriz devuelta por mangosta

Tengo una consulta de notificaciones. encontrar (mangosta) que devuelve varias hojas

 Notification.find({id: id}, function(err, notifications){}

Necesito convertir los valores de marca de tiempo que se devuelven así

 [ { _id: new ObjectId("12934193c51a231b0165425a"), userid: '62921df1c14a2eea0efa9399', timestamp: 1653817696599, }, { _id: new ObjectId("11934193c51a231b0165425a"), userid: '62921df1c14a2eea0efa9399', timestamp: 1653817696600, } ]

probé esto

 notifications.forEach((element, index) => { notifications[index].timestamp = new Date(notifications[index].timestamp); });

y este codigo

 new Date(notifications[index].timestamp);

parece funcionar al convertir la marca de tiempo de cada valor, pero no puedo reemplazarlo en la matriz

llevo varias horas con este tema

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En lugar de forEach use el map

 const newNotifications = notifications.map((element, index) => { return { ...element, timestamp: new Date(element.timestamp), } });
about 4 years ago · Juan Pablo Isaza Report
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!