#Is there any way to do something similar to a sql left join using queries?
6 messages · Page 1 of 1 (latest)
I was wondering the same thing, the docs say that complex queries, including a join, should be handled with javascript. https://docs.convex.dev/database/reading-data#more-complex-queries
also im not seeing a join method on the query
Yep there's no way to do a join within a single db.query (https://stack.convex.dev/functional-relationships-helpers has some helpers for doing different sorts of joins in JS).
Generally making multiple db.query or db.get calls within a single function is fine performance-wise, since the thing running the JS is very close to the database executing the db.query calls.
Thank you guys, i ask because i was wondering if i could optimize thinking about the cost of multiple queries in an action
Cost in terms of time or database bandwidth? For database bandwidth a join is the same cost whether you do it in javascript or if we exposed a query join syntax. For time you can improve it a little by doing the queries in parallel (with a Promise.all) but that's usually not necessary. Let us know if you're running into any cost issues