usage-rules/data_layers.md
Data layers determine how resources are stored and retrieved. Examples of data layers:
AshPostgres)Ash.DataLayer.Ets)Ash.DataLayer.Mnesia)data_layer: :embedded) (typically JSON under the hood)Specify a data layer when defining a resource:
defmodule MyApp.Post do
use Ash.Resource,
domain: MyApp.Blog,
data_layer: AshPostgres.DataLayer
postgres do
table "posts"
repo MyApp.Repo
end
# ... attributes, relationships, etc.
end
For embedded resources:
defmodule MyApp.Address do
use Ash.Resource,
data_layer: :embedded
attributes do
attribute :street, :string
attribute :city, :string
attribute :state, :string
attribute :zip, :string
end
end
Each data layer has its own configuration options and capabilities. Refer to the rules & documentation of the specific data layer package for more details.