View Source Ash.ToTenant protocol (ash v3.3.0)
Converts a value to a tenant. To add this to a resource, implement the protocol like so:application
What this should do is entirely dependent on how you've set up your tenants. This example assumes
that you want the tenant to be org_#{organization_id}
, but it could also be something like
organization.schema
.
defmodule MyApp.Organization do
use Ash.Resource, ...
...
defimpl Ash.ToTenant do
def to_tenant(%{id: id}, _resource), do: "org_#{id}"
end
end
Summary
Types
@type t() :: term()
Functions
@spec to_tenant(t(), Ash.Resource.t()) :: term()