AF
Ash Framework•4mo ago
ankit

Multitenancy with code interface on the domain?

So I have this:
defmodule MyApp.FlyingTrainingOrg do
use Ash.Domain
# ...
resources do
resource MyApp.FlyingTrainingOrg.Airplanes do
define :get_airplanes, action: :read
end
end
end
defmodule MyApp.FlyingTrainingOrg do
use Ash.Domain
# ...
resources do
resource MyApp.FlyingTrainingOrg.Airplanes do
define :get_airplanes, action: :read
end
end
end
defmodule MyApp.FlyingTrainingOrg.Airplanes do
use Ash.Resource
# ...
multitenancey do
strategy :attribute
attribute :org_id
end
actions do
defaults [:read]
# ...
end
end
defmodule MyApp.FlyingTrainingOrg.Airplanes do
use Ash.Resource
# ...
multitenancey do
strategy :attribute
attribute :org_id
end
actions do
defaults [:read]
# ...
end
end
Is it possible to set the tenant on the MyApp.FlyingTrainingOrg.get_airplanes() call? I can right now query MyApp.FlyingTrainingOrg.Airplanes |> Ash.Query.set_tenant("some-id") |> Ash.read() but I would prefer to use the code interface especially when performing cross-domain lookups.
Solution:
There is a tenant option to all code interfaces 🙂
Jump to solution
2 Replies
Solution
ZachDaniel
ZachDaniel•4mo ago
There is a tenant option to all code interfaces 🙂
ankit
ankitOP•4mo ago
I knew this was something trivial... thank you 😅

Did you find this page helpful?