Modelle hinzugefügt
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
pub mod hersteller;
|
||||
pub mod modell;
|
||||
pub mod modell_temp;
|
||||
pub mod typ;
|
||||
|
||||
use async_graphql::MergedObject;
|
||||
@@ -9,6 +8,5 @@ use async_graphql::MergedObject;
|
||||
pub struct Query(
|
||||
typ::TypQuery,
|
||||
modell::ModellQuery,
|
||||
modell_temp::ModellTempQuery,
|
||||
hersteller::HerstellerQuery,
|
||||
);
|
||||
|
||||
@@ -10,25 +10,16 @@ pub struct ModellQuery {
|
||||
|
||||
#[Object(extends)]
|
||||
impl ModellQuery {
|
||||
// #[graphql(external)]
|
||||
// async fn id(&self) -> &i32 {
|
||||
// &self.id
|
||||
// }
|
||||
|
||||
async fn modelle<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Modell>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let rows = Modell::read_all(pool).await?;
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
async fn modell<'a>(&self, ctx: &'a Context<'_>, id: i32) -> FieldResult<Modell> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let row = Modell::read_one(pool, &id).await?;
|
||||
Ok(row)
|
||||
}
|
||||
|
||||
// #[graphql(entity)]
|
||||
// async fn find_modell_by_id(&self, id: i32) -> Modell {
|
||||
// Modell { id }
|
||||
// }
|
||||
async fn modelle<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Modell>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let output = Modell::read_all(pool).await?;
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
use async_graphql::{Context, FieldResult, Object};
|
||||
use sqlx::postgres::PgPool;
|
||||
|
||||
use crate::models::modell_temp::ModellTemp;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ModellTempQuery {}
|
||||
|
||||
#[Object(extends)]
|
||||
impl ModellTempQuery {
|
||||
// async fn modelle<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<ModellTemp>> {
|
||||
// let pool = ctx.data::<PgPool>()?;
|
||||
// let rows = ModellTemp::read_all(pool).await?;
|
||||
// Ok(rows)
|
||||
// }
|
||||
|
||||
async fn modell_temp<'a>(&self, ctx: &'a Context<'_>, id: i32) -> FieldResult<ModellTemp> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let row = ModellTemp::read_one(pool, &id).await?;
|
||||
Ok(row)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user