I want to use Paginate
such that given two points, I want to grab all items starting from that point up to (inclusive of, meaning, it should also get the target point) the target point.
Imagine that there are 10,000 documents in a collection called messages
. I have two points, A
– the starting point, and B
the last point, what I need to do is get all items starting at point A + 1
to point B
. I tried using Paginate with before
and after
but it returned an error.
Paginate(
Match(
Index("messages"),
"295664821370618375",
"295664230831489541"
),
{
size: 20,
before: [
"2021-05-22T12:18:46.120288Z",
"299291982379876871"
],
after: [
"2021-06-02T14:12:15.101330Z",
"300295688333296129"
],
}
);
Error: [
{
"position": [],
"code": "invalid expression",
"description": "No form/function found, or invalid argument keys: { paginate, size, before, after }."
}
]
This is the definition of the index messages
:
CreateIndex({
name: 'messages',
source: Collection('inbox'),
terms: [
{ field: ['data', 'senderId'] },
{ field: ['data', 'recipientId'] }
],
values: [
{ field: ['data', 'createdAt'], reverse: true },
{ field: ['ref'] }
]
})
EDIT 1:
Additionally, what if I want to say "get all documents from point A + 1
to point B + 5
", notice the +5
here, it’s the offset, basically get A + 1
to B
and then 5 more items after it.