4
0
Fork 0
mirror of https://github.com/zzzzDev4/ias-tea-axum.git synced 2025-04-21 07:41:21 +02:00

fix: naming convention

This commit is contained in:
zzzz 2024-04-28 22:14:27 +02:00
parent 79c245f5c8
commit b77cde24e1
2 changed files with 4 additions and 4 deletions

View file

@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS teas (
CREATE TABLE IF NOT EXISTS tea (
id serial PRIMARY KEY,
teaname TEXT NOT NULL
);

View file

@ -17,7 +17,7 @@ async fn retrieve(
State(state): State<MyState>,
) -> Result<impl IntoResponse, impl IntoResponse> {
println!("retrieve");
match sqlx::query_as::<_, Tea>("SELECT * FROM teas WHERE id = $1")
match sqlx::query_as::<_, Tea>("SELECT * FROM tea WHERE id = $1")
.bind(id)
.fetch_one(&state.pool)
.await
@ -31,7 +31,7 @@ async fn retrieve_all(
State(state): State<MyState>,
) -> Result<impl IntoResponse, impl IntoResponse> {
println!("retrieve all");
match sqlx::query_as::<_, Tea>("SELECT * FROM teas LIMIT 100")
match sqlx::query_as::<_, Tea>("SELECT * FROM tea LIMIT 100")
.fetch_all(&state.pool)
.await
{
@ -45,7 +45,7 @@ async fn add(
Json(data): Json<TeaNew>,
) -> Result<impl IntoResponse, impl IntoResponse> {
println!("add");
match sqlx::query_as::<_, Tea>("INSERT INTO teas (teaname) VALUES ($1) RETURNING id, teaname")
match sqlx::query_as::<_, Tea>("INSERT INTO tea (teaname) VALUES ($1) RETURNING id, teaname")
.bind(&data.teaname)
.fetch_one(&state.pool)
.await