N
N
nomta2021-02-07 17:02:15
MongoDB
nomta, 2021-02-07 17:02:15

How to get data fetch in reverse order using mongoose?

I'm trying to select data using the slice method:

const questions = await Question
        .find({})
        .where('reply')
        .slice([-1, limit]);

...but this does not work, the same data comes in as without slice.

If who faced, prompt, in what there can be a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Cheremkhin, 2021-02-07
@nomta

const questions = await Question
        .find({})
        .sort({_id: -1})
        .limit(100)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question