https://github.com/elonsoft/pg_case
Elixir helper macros to work with PostgreSQL `case` expression
https://github.com/elonsoft/pg_case
ecto elixir postgresql
Last synced: 8 months ago
JSON representation
Elixir helper macros to work with PostgreSQL `case` expression
- Host: GitHub
- URL: https://github.com/elonsoft/pg_case
- Owner: Elonsoft
- License: mit
- Created: 2020-12-18T13:23:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T13:30:21.000Z (over 5 years ago)
- Last Synced: 2025-09-19T16:02:38.945Z (9 months ago)
- Topics: ecto, elixir, postgresql
- Language: Elixir
- Homepage: https://hexdocs.pm/pg_case/0.1.0
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PgCase
`ecto` and `postgrex` Elixir extension to work with PostgreSQL `case`
expression.
## Example
```elixir
import Ecto.Query, only: [from: 2]
import PgCase, only: [pg_case: 1]
def query do
from e in Entity,
select: %{
value: pg_case do
e.x < 0 -> "negative"
e.x > 0 -> "positive"
else
"zero"
end
}
end
```
## Installation
Docs are [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `pg_case` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:pg_case, "~> 0.1.0"}
]
end
```