1
0
mirror of https://github.com/actix/examples synced 2025-06-27 01:27:43 +02:00

chore: tweaks to diesel-async

This commit is contained in:
Rob Ede
2025-04-09 23:49:30 +01:00
parent f2c51a8713
commit 3f2186ef19
5 changed files with 12 additions and 22 deletions

View File

@ -24,7 +24,7 @@ docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}"
cd databases/diesel-async
cargo install diesel_cli --no-default-features --features postgres
echo DATABASE_URL=postgres://test-user:password@localhost:5432/test_db > .env
echo DATABASE_URL=postgres://test-user:password@localhost:5432/actix_example_diesel_async > .env
diesel setup
diesel migration run
```
@ -32,7 +32,7 @@ diesel migration run
The database will now be created in your PostgreSQL instance.
```sh
docker exec -i postgresql psql -U test-user -c "\l"
docker exec -i postgresql psql -U test-user -l
```
### Running Server
@ -68,16 +68,16 @@ On success, a response like the following is returned:
<details>
<summary>Client Examples</summary>
Using [HTTPie]:
Using [HTTPie] / [xh]:
```sh
http POST localhost:8080/items name=thingamajig
http POST :8080/items name=thingamajig
```
Using cURL:
```sh
curl -S -X POST --header "Content-Type: application/json" --data '{"name":"thingamajig"}' http://localhost:8080/items
curl --show-error -X POST --header "Content-Type: application/json" --data '{"name":"thingamajig"}' http://localhost:8080/items
```
</details>
@ -89,7 +89,7 @@ Gets an item from the DB using its UID (returned from the insert request or take
<details>
<summary>Client Examples</summary>
Using [HTTPie]:
Using [HTTPie] / [xh]:
```sh
http localhost:8080/items/9e46baba-a001-4bb3-b4cf-4b3e5bab5e97
@ -98,7 +98,7 @@ http localhost:8080/items/9e46baba-a001-4bb3-b4cf-4b3e5bab5e97
Using cURL:
```sh
curl -S http://localhost:8080/items/9e46baba-a001-4bb3-b4cf-4b3e5bab5e97
curl --show-error http://localhost:8080/items/9e46baba-a001-4bb3-b4cf-4b3e5bab5e97
```
</details>
@ -106,11 +106,8 @@ curl -S http://localhost:8080/items/9e46baba-a001-4bb3-b4cf-4b3e5bab5e97
### Explore The PostgreSQL DB
```sh
docker exec -i postgresql psql -U test-user -d test_db -c "select * from public.items"
docker exec -i postgresql psql -U test-user -d actix_example_diesel_async -c "SELECT * from public.items"
```
## Using Other Databases
You can find a complete example of Diesel + PostgreSQL at: [https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Rust/actix](https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Rust/actix)
[xh]: https://httpie.io/cli
[httpie]: https://httpie.io/cli