Select or Project Method
Does convex have any built in for doing some sort of select statement or project method when querying?
I see how I can make a query, collect the documents, and return them after mapping over the documents.
But that doesn't really work if you want to use a paginated query. It seems like in this case you'd have to implement your own pagination in the query.
4 Replies
You can modify, even filter pagination results before returning them! just unpack the results, replace the page, and return the expected type.
Oh I didn't know that. I'll explore that some.
@ballingt how do you go about replacing the page though? The page is typed to the documents I queryed. If I want to map over them and just return a subset of fields and then replace the page with this array of objects it won't statisfy the expected type of the page.
Or do you just type the page like this?
I personally prefer immutable style, it types better (and has other advantages):
We are lacking this example in the pagination docs, it's on our list to fix
Oh that is way cleaner. Okay perfect. Thank you both so much!