ash_postgres/README.md

60 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2019-12-05 03:58:20 +13:00
# AshPostgres
2020-06-03 14:30:02 +12:00
2020-06-03 14:31:10 +12:00
![Elixir CI](https://github.com/ash-project/ash_postgres/workflows/Elixir%20CI/badge.svg)
2020-06-01 17:41:10 +12:00
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2022-04-28 01:55:08 +12:00
[![Coverage Status](https://coveralls.io/repos/github/ash-project/ash_postgres/badge.svg?branch=main)](https://coveralls.io/github/ash-project/ash_postgres?branch=main)
2020-06-11 03:21:49 +12:00
[![Hex version badge](https://img.shields.io/hexpm/v/ash_postgres.svg)](https://hex.pm/packages/ash_postgres)
2020-09-03 20:18:11 +12:00
AshPostgres supports all the capabilities of an Ash data layer. AshPostgres is the primary Ash data layer.
2020-10-29 16:56:59 +13:00
Custom Predicates:
- `AshPostgres.Predicates.Trigram`
2020-10-29 16:56:59 +13:00
2020-12-27 19:20:12 +13:00
## DSL
See the DSL documentation in `AshPostgres.DataLayer` for DSL documentation
## Usage
2020-10-29 16:56:59 +13:00
Add `ash_postgres` to your `mix.exs` file.
2020-10-29 16:56:59 +13:00
```elixir
2022-10-18 10:45:06 +13:00
{:ash_postgres, "~> 1.0"}
2020-10-29 16:56:59 +13:00
```
2021-03-15 10:22:59 +13:00
To use this data layer, you need to chage your Ecto Repo's from `use Ecto.Repo`,
to `use AshPostgres.Repo`. because AshPostgres adds functionality to Ecto Repos.
2020-10-29 16:56:59 +13:00
2021-03-15 10:22:59 +13:00
Then, configure each of your `Ash.Resource` resources by adding `use Ash.Resource, data_layer: AshPostgres.DataLayer` like so:
2020-10-29 16:56:59 +13:00
```elixir
2021-03-15 10:22:59 +13:00
defmodule MyApp.SomeResource do
use Ash.Resource, data_layer: AshPostgres.DataLayer
postgres do
repo MyApp.Repo
table "table_name"
end
attributes do
# ... Attribute definitions
end
2020-10-29 16:56:59 +13:00
end
```
2020-12-27 19:20:12 +13:00
## Generating Migrations
2020-10-29 16:56:59 +13:00
See the documentation for `Mix.Tasks.AshPostgres.GenerateMigrations` for how to generate
migrations from your resources
# Contributors
Ash is made possible by its excellent community!
<a href="https://github.com/ash-project/ash_postgres/graphs/contributors">
<img src="https://contrib.rocks/image?repo=ash-project/ash_postgres" />
</a>
[Become a contributor](https://ash-hq.org/docs/guides/ash/latest/how_to/contribute.md)