Search documentation of ash

# View Source Ash.ToTenant protocol (ash v3.4.30)

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

t()

## Functions

to_tenant(value, resource)

# Types

Link to this type

# t()

View Source

    @type t() :: term()

# Functions

Link to this function

# to_tenant(value, resource)

View Source

    @spec to_tenant(t(), Ash.Resource.t()) :: term()