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

153
Views
Node.js, Mongo find last 10 items sort by start date

This time I have problem with querying last X records with certain value from mongodb.

What I have so far ->

Data.find({'ResourceID': 61}, {}, {limit: 10}, function (err, docs) {
    res.json(docs);
});

This returns first 10 records. How can I get last 10?


EDIT :

This works, but can I convert this to the looks of the upper or whats the point of this 'exec' function?->

Data.find({
        'ResourceID': 61
    }).sort('-Start').limit(10).exec(function (err, docs) {
        console.log(docs);
        res.json(docs);
 });
over 4 years ago · Santiago Trujillo
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!