M
M
midiks12019-12-10 19:13:04
MongoDB
midiks1, 2019-12-10 19:13:04

How to skip records in mongo?

Hello. The task is this:
- there is a collection of data that is added every second
- you need to get 24 records (for the last 24 hours)
Here is the algorithm for what I need:

const found = []

for(let i = 0; i < КОЛИЧЕСТВО ВСЕХ ЗАПИСЕЙ; i++) {
  if(found.length == 24) {
    break;
  }
  if(i % 3600 == 0) {
    found.push(data[i]);
  } else {
    continue;
  }
}

That is, I want to not just do .skip(3600), but to skip the next 3600(3599) for each record found.
Is there such a possibility for mongo?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question