Using TypeScript to Write Complex Query ...
in case it's easier, you could consider compiling the react query builder into a js function and using this helper to run the filter https://stack.convex.dev/complex-filters-in-convex
Using TypeScript to Write Complex Query Filters
Thereβs a new Convex helper to perform generic TypeScript filters, with the same performance as built-in Convex filters, and unlimited potential.
7 Replies
hey yeah that's a valid point. I just finished with the default filters though and its working fine right now. the one thing i really need to solve (maybe filter can help) i couldn't find any
union
anywhere. Does convex filters has that? Goal is to actually be able to get inside two tables and match query their documents. do you have any suggestion for that ?you can do two
db.query
calls in the same convex queryyou mean inside
ctx.db.query
?
can you context me on this Please?
currently the buildFilters
function i did construct the filters using FilterBuilder
and Expression
aswell as GenericTableInfo
from convex/server
and can be used like this
const results = await ctx.db.query("table").order("desc").filter(filters).paginate(args.paginationOpts);
you mean i can join another table
here and apply same filters
object to it too ?
or some way else?i mean you can do
oh i know that. but i was saving myself to do a lookup function. which would be necessary with this. will see how it goes! :todayilearned:
:convex: π
reading from two tables is always going to do two lookups (even in other databases like postgres). This is just the syntax for doing it in convex
i'd not be surprised if convex turns out to be better then how we operate in regular databases. i'm not limiting myself comparing convex to other databases or this is all moot π i'm a fan!
and you're right ofcourse!