https://github.com/coryodaniel/phoenix-demo-project
Just a demo project for Phoenix
https://github.com/coryodaniel/phoenix-demo-project
Last synced: 2 months ago
JSON representation
Just a demo project for Phoenix
- Host: GitHub
- URL: https://github.com/coryodaniel/phoenix-demo-project
- Owner: coryodaniel
- Created: 2016-08-04T19:20:14.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-07T00:07:18.000Z (almost 10 years ago)
- Last Synced: 2026-01-01T16:33:06.208Z (6 months ago)
- Language: JavaScript
- Size: 67.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# An elixir app for demonstrating JSONAPI (JaSerializer) with Phoenix
## Set up
```
psql postgres
CREATE USER postgres SUPERUSER;
mix deps.get
mix ecto.create
mix ecto.migrate
mix run priv/repo/seeds.exs
```
## To start your Phoenix app:
* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Start Phoenix endpoint with `mix phoenix.server`
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
## Example Queries
### JSONAPI Queries
* [x] http://localhost:4000/api/users
* [x] http://localhost:4000/api/users?page[page_number]=10
* [x] http://localhost:4000/api/users?page[page_number]=10&page[page_size]=1000
* [x] http://localhost:4000/api/users?page[page_number]=10&page[page_size]=1000&fields[users]=email
* [x] http://localhost:4000/api/users?page[page_number]=10&page[page_size]=1000&fields[users]=email&include=teams
* [x] http://localhost:4000/api/users?page[page_number]=10&page[page_size]=1000&fields[users]=email&include=teams&fields[teams]=name
### Download all users
```bash
curl -X GET -H "Accept: application/vnd.api+json" -H "Cache-Control: no-cache" -H "Postman-Token: 0b58cf44-dc23-578e-7ed2-c4dcab7ed87a" "http://localhost:4000/api/users?page%5Bpage_size%5D=100000" -o users.html
```
### List users and team names
```sql
SELECT
email, teams.name
FROM
users
LEFT JOIN teams_users ON teams_users.user_id = users.id
INNER JOIN teams ON teams_users.team_id = teams.id
ORDER BY email;
```