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

143
Views
obtenga los 10 recods agregados recientemente de mogodb en express,js

Estoy tratando de crear una API que pueda obtener 10 registros agregados recientemente cada vez que se llama a la API desde la base de datos. ¿Hay algún método para hacerlo?

tengo este código que puede acceder a todos los registros cómo limito solo los primeros 10

 app.get("/questapi", function (req, res) { mydb .collection("questions") .find({}) .toArray(function (err, data) { if (err) throw error; res.send(data); }); });

cada vez que llamo a la API, debería agregarse recientemente 10. Estoy obteniendo de mogodb

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Prueba esto,

 app.get("/questapi", function (req, res) { mydb .collection("questions") .find() .limit(10); //here you can limit how many elements you want to retrieve .toArray(function (err, data) { if (err) throw error; res.send(data); }); });
over 4 years ago · Santiago Trujillo 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!