derby.js How can I query using $skip and $limit on a sorted collection?

136 Views Asked by At

Sorry if this is a dump question but I cannot figure it out.

As collections grow in size, it become convenient to render a portion of the data. For that we can something like

model.query('items', { $skip: 30, $limit: 30 })

but what if we want to do that on a filter or a sort?   I have tried

model.query('items', { $skip: 30, $limit: 30 }, { creation_time: -1})

to mimic MongoDB .find().

I haven't find a way to do a fetch/query on filters. Of course I don't want to slice after .get() since that would be problematic on large collections. I tried to use a ref() on filter with no success. Does someone know a recipe on how to handle those situations?

Thanks in advance.

PS: I hope .fetch() hold a cursor and wait for .get() to retrieve data.

1

There are 1 best solutions below

1
On BEST ANSWER
model.query('items', { $skip: 30, $limit: 30, $orderby: {creation_time: -1}})