The InvalidCursor error happens if the query's index range changes between requests
Wanting to confirm something. The InvalidCursor error
( InvalidCursor: Tried to run a query starting from a cursor, but it looks like this cursor is from a different query.)
happens if the query's index range changes between requests, and thus it is not possible/viable to setup multiple query definitions/statements if (x) query.withIndex(by_1), else if(y) withIndex(by_2)
inside a single query function? Is the best/only way then to separate each query into its own query function?4 Replies
Yeah, I've run into this. You only want one paginated db call per query.
The cursors aren't interchangeable between
ctx.db.query
calls.If you can use separate paginated queries, then great.
If not, you can implement the pagination yourself, like I did here:
https://github.com/xixixao/convex-ents/blob/main/src/deletion.ts#L356-L363
GitHub
convex-ents/src/deletion.ts at main · xixixao/convex-ents
Contribute to xixixao/convex-ents development by creating an account on GitHub.
thank you Michal. That's interesting! from what i can tell at a glance youre controlling the num of items read from a table; not sure about the bytes part however. Regardless i'll takea serious look this evening thank you!
Got it, most likely i'll separate this into its own fns, at least write a hook to encapsulate all the permutations
just wanted to note this is a great example (just had a chance to review), thank you for sharing!
This is a helpful example to have! Does this account for the possibility that multiple documents have equivalent
_creationTime
s?