#Is there any way to do something similar to a sql left join using queries?

6 messages · Page 1 of 1 (latest)

jovial meteor
#

Without needing to send another query for that

hot galleon
#

also im not seeing a join method on the query

halcyon scroll
#

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.

In this post, we’ll look at some helper functions to help write code to traverse relationships in a readable, predictable, and debuggable way.

jovial meteor
#

Thank you guys, i ask because i was wondering if i could optimize thinking about the cost of multiple queries in an action

dense steppe
#

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