2019-12-05 03:58:20 +13:00
|
|
|
defmodule AshPostgres do
|
2019-12-06 07:45:42 +13:00
|
|
|
@moduledoc """
|
2020-06-14 19:04:18 +12:00
|
|
|
A postgres extension library for `Ash`.
|
2019-12-06 07:45:42 +13:00
|
|
|
|
2020-06-14 19:04:18 +12:00
|
|
|
`AshPostgres.DataLayer` provides a DataLayer, and a DSL extension to configure that data layer.
|
2019-12-06 07:45:42 +13:00
|
|
|
|
2020-06-14 19:04:18 +12:00
|
|
|
The dsl extension exposes the `postgres` section. See: `AshPostgres.DataLayer.postgres/1` for more.
|
2019-12-06 07:45:42 +13:00
|
|
|
"""
|
2020-05-03 07:06:52 +12:00
|
|
|
|
2020-06-14 19:04:18 +12:00
|
|
|
alias Ash.Dsl.Extension
|
2019-12-06 07:45:42 +13:00
|
|
|
|
2020-06-14 19:04:18 +12:00
|
|
|
@doc "Fetch the configured repo for a resource"
|
2019-11-27 11:33:52 +13:00
|
|
|
def repo(resource) do
|
2020-06-28 07:11:28 +12:00
|
|
|
Extension.get_opt(resource, [:postgres], :repo, nil, true)
|
2020-01-18 06:24:07 +13:00
|
|
|
end
|
2020-05-03 07:06:52 +12:00
|
|
|
|
2020-06-14 19:04:18 +12:00
|
|
|
@doc "Fetch the configured table for a resource"
|
|
|
|
def table(resource) do
|
2020-06-28 07:11:28 +12:00
|
|
|
Extension.get_opt(resource, [:postgres], :table, nil, true)
|
2020-05-03 07:06:52 +12:00
|
|
|
end
|
2020-09-11 12:26:47 +12:00
|
|
|
|
|
|
|
@doc "Whether or not the resource should be included when generating migrations"
|
|
|
|
def migrate?(resource) do
|
|
|
|
Extension.get_opt(resource, [:postgres], :migrate?, nil, true)
|
|
|
|
end
|
2019-10-31 04:13:22 +13:00
|
|
|
end
|