erquhartE
Convex Community2y ago
6 replies
erquhart

Multi-value indexes

Especially for paginated queries, supporting multiple values for the same field in an index would be make certain queries a lot less complicated to write. The pattern of paging through n pages from the client to gather a complete page does work, but it's fiddly to implement and, on a lesser note, typically multiplies function calls.

Example, I want to paginate through high priority records in a table. Priority is a number, and high priority is anything above 10. I either have to do excess pagination calls on the frontend to build up a page, or add a "high priority" field to the table that provides a boolean for whether the priority field qualifies as "high".

I don't honestly know what the API for that would look like. Maybe each field name string in the index definition can be optionally replaced with a config object.

.index('highPriority', [{ field: 'priority', values: [10, 20] }])
Was this page helpful?