Query across many tenants
I am developing an application with postgres attribute multitenancy and there is one query that I want to make across multiple tenants (tenants will be provided as argument)
I was wandering if there is a way to do that somewhat simpler and more idiomatic, then just making a custom query and running a query multiple times. I also have nested fields to resolve for each element, so I would need to resolve every dependency somehow too.
Solution:Jump to solution
You can make specific read actions allow bypassing multitenancy with
multitenancy :bypass
5 Replies
Solution
You can make specific read actions allow bypassing multitenancy with
multitenancy :bypass
and then you can filter where
attribute in [....]
no need for multiple queries.
Someone just PRd a feature where you can set that to :bypass_all
which bypasses the tenant for all nested queries.So If I just bypass on the top query and load many things inside, the queries inside it will not be bypassed?
They will be
well, if you use
:bypss_all
Ah, so in your case you may need to run many queries
if you want each resulting thing to load related data as if it was tenantedOk, got it, thanks a lot