-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: reformat docs and revisit certain guides
improvement: support `mix ash.rollback` with interactive rollback
- Loading branch information
1 parent
a02653e
commit 38eec0b
Showing
22 changed files
with
277 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# AshPostgres Documentation | ||
|
||
Welcome! This documentation is for `AshPostgres`, the PostgreSQL data layer for [Ash Framework](https://hexdocs.pm/ash). If you have not yet, please see the [Ash Framework documentation](https://hexdocs.pm/ash). | ||
|
||
## Dive In | ||
|
||
- [Get Started](documentation/tutorials/get-started-with-postgres.md) | ||
|
||
--- | ||
|
||
## Tutorials | ||
|
||
- [Get Started](documentation/tutorials/get-started-with-postgres.md) | ||
|
||
## Topics | ||
|
||
### Resources | ||
|
||
- [References](documentation/topics/resources/references.md) | ||
- [Polymorphic Resources](documentation/topics/resources/polymorphic-resources.md) | ||
|
||
### Development | ||
|
||
- [Migrations and tasks](documentation/topics/development/migrations-and-tasks.md) | ||
- [Testing](documentation/topics/development/testing.md) | ||
- [Upgrading to 2.0](documentation/topics/development/upgrading-to-2.0.md) | ||
|
||
### Advanced | ||
|
||
- [Expressions](documentation/topics/advanced/expressions.md) | ||
- [Manual Relationships](documentation/topics/advanced/manual-relationships.md) | ||
- [Schema Based Multitenancy](documentation/topics/advanced/schema-based-multitenancy.md) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Expressions | ||
|
||
In addition to the expressions listed in the [Ash expressions guide](https://hexdocs.pm/ash/expressions.html), AshPostgres provides the following expressions | ||
|
||
# Fragments | ||
|
||
Fragments allow you to use arbitrary postgres expressions in your queries. Fragments can often be an escape hatch to allow you to do things that don't have something officially supported with Ash. | ||
|
||
### Examples | ||
|
||
#### Simple expressions | ||
|
||
```elixir | ||
fragment("? / ?", points, count) | ||
``` | ||
|
||
#### Calling functions | ||
|
||
```elixir | ||
fragment("repeat('hello', 4)") | ||
``` | ||
|
||
#### Using entire queries | ||
|
||
```elixir | ||
fragment("points > (SELECT SUM(points) FROM games WHERE user_id = ? AND id != ?)", user_id, id) | ||
``` | ||
|
||
> ### a last resport {: .warning} | ||
> | ||
> Using entire queries as shown above is a last resort, but can sometimes be the best way to accomplish a given task. | ||
#### In calculations | ||
|
||
```elixir | ||
calculations do | ||
calculate :lower_name, :string, expr( | ||
fragment("LOWER(?)", name) | ||
) | ||
end | ||
``` | ||
|
||
#### In migrations | ||
|
||
```elixir | ||
create table(:managers, primary_key: false) do | ||
add :id, :uuid, null: false, default: fragment("UUID_GENERATE_V4()"), primary_key: true | ||
end | ||
``` | ||
|
||
## Like and ILike | ||
|
||
These wrap the postgres builtin like and ilike operators. | ||
|
||
Please be aware, these match *patterns* not raw text. Use `contains/1` if you want to match text without supporting patterns, i.e `%` and `_` have semantic meaning! | ||
|
||
For example: | ||
|
||
```elixir | ||
Ash.Query.filter(User, like(name, "%obo%")) # name contains obo anywhere in the string, case sensitively | ||
``` | ||
|
||
```elixir | ||
Ash.Query.filter(User, ilike(name, "%ObO%")) # name contains ObO anywhere in the string, case insensitively | ||
``` | ||
|
||
## Trigram similarity | ||
|
||
To use this expression, you must have the `pg_trgm` extension in your repos `installed_extensions` list. | ||
|
||
This calls the `similarity` function from that extension. See more https://www.postgresql.org/docs/current/pgtrgm.htmlhere: https://www.postgresql.org/docs/current/pgtrgm.html | ||
|
||
For example: | ||
|
||
```elixir | ||
Ash.Query.filter(User, trigram_similarity(first_name, "fred") > 0.8) | ||
``` |
2 changes: 1 addition & 1 deletion
2
...ation/how_to/join-manual-relationships.md → ...n/topics/advanced/manual-relationships.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
documentation/how_to/test-with-postgres.md → documentation/topics/development/testing.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
documentation/how_to/upgrade.md → ...on/topics/development/upgrading-to-2.0.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.