Add WIP relays to database and api

This commit is contained in:
Tobias Reisinger 2023-11-26 00:54:03 +01:00
parent 4e3df272c3
commit 734f8b291c
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
14 changed files with 387 additions and 88 deletions
emgauwa-lib/src/db

View file

@ -1,12 +1,11 @@
use serde_derive::{Deserialize, Serialize};
use serde_derive::Serialize;
use std::ops::DerefMut;
use sqlx::pool::PoolConnection;
use sqlx::Sqlite;
use crate::db::errors::DatabaseError;
use crate::db::model_utils::Period;
use crate::db::tag::Tag;
use crate::db::Tag;
use crate::db::types::ControllerUid;
#[derive(Debug, Serialize, Clone)]
@ -18,9 +17,6 @@ pub struct Controller {
pub active: bool,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
pub struct Periods(pub Vec<Period>);
impl Controller {
pub async fn get_all(
conn: &mut PoolConnection<Sqlite>,
@ -117,6 +113,6 @@ impl Controller {
.execute(conn.deref_mut())
.await?;
Controller::get_by_uid(conn, &self.uid).await
Self::get(conn, self.id).await
}
}