ExTenant.Schema (ExTenant v0.1.4) View Source

## to use the Extenant.Schema in your schema modules follow this example

  • it injects the belongs_to relationship to the tenant
  • it also raises a compiler error if the tenanted() call was omitted
  • it works with the tenant_id field set in Config.exs

defmodule Post do

use ExTenant.Schema
import Ecto.Changeset

tenanted_schema "posts" do
  field(:name, :string)
  field(:body, :string)

  tenanted()
end

end ...

Link to this section Summary

Functions

injects belongs_to relationship to the tenant model see this example

Replaces Ecto.Schema.embedded_schema/2 - checking whether tenanted() has been called - that injects the belongs_to tenant relationship

Replaces Ecto.Schema.schema/2 - checking whether tenanted() has been called - that injects the belongs_to tenant relationship

Link to this section Functions

injects belongs_to relationship to the tenant model see this example

tenanted_schema "posts" do

field(:name, :string)
tenanted()

end

Link to this macro

tenanted_embedded_schema(list)

View Source (macro)

Replaces Ecto.Schema.embedded_schema/2 - checking whether tenanted() has been called - that injects the belongs_to tenant relationship

Link to this macro

tenanted_schema(table_name, list)

View Source (macro)

Replaces Ecto.Schema.schema/2 - checking whether tenanted() has been called - that injects the belongs_to tenant relationship