Ash FrameworkAF
Ash Frameworkโ€ข7mo agoโ€ข
4 replies
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.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 ๐Ÿ™‚
Was this page helpful?