ash_postgres v0.23.0 AshPostgres.DataLayer View Source

A postgres data layer that levereges Ecto's postgres capabilities.

AshPostgres supports all capabilities of an Ash data layer, and it will most likely stay that way, as postgres is the primary target/most maintained data layer.

Custom Predicates:

  • AshPostgres.Predicates.Trigram

Usage

First, ensure you've added ash_postgres to your mix.exs file.

{:ash_postgres, "~> x.y.z"}

To use this data layer, you need to define an Ecto.Repo. AshPostgres adds some functionality on top of ecto repos, so you'll want to use AshPostgres.Repo

Then, configure your resource like so:

postgres do
  repo MyApp.Repo
  table "table_name"
end

Generating Migrations

See the documentation for Mix.Tasks.AshPostgres.GenerateMigrations for how to generate migrations from your resources

Link to this section Summary

Functions

Postgres data layer configuration

Link to this section Functions

Link to this macro

postgres(body)

View Source (macro)

Postgres data layer configuration

Options

  • :repo - Required. The repo that will be used to fetch your data. See the AshPostgres.Repo documentation for more

  • :migrate? - Whether or not to include this resource in the generated migrations with mix ash.generate_migrations The default value is true.

  • :base_filter_sql - A raw sql version of the base_filter, e.g representative = true. Required if trying to create a unique constraint on a resource with a base_filter

  • :skip_unique_indexes - Skip generating unique indexes when generating migrations The default value is false.

  • :table - Required. The table to store and read the resource from