add `/<uuid> route + backend handling
This commit is contained in:
@@ -1,15 +1,30 @@
|
||||
use crate::Backend;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::FromRow;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct Camera {
|
||||
pub uuid: String,
|
||||
pub desc: String,
|
||||
pub desc: Option<String>,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl Backend {
|
||||
pub(crate) async fn camera_by_uuid(&self, uuid: Uuid) -> Option<Camera> {
|
||||
let uuid = uuid.to_string();
|
||||
match self {
|
||||
Backend::Sqlite(db) => sqlx::query_as!(
|
||||
Camera,
|
||||
"SELECT uuid, desc, name FROM camera WHERE uuid = ?",
|
||||
uuid
|
||||
)
|
||||
.fetch_optional(db)
|
||||
.await
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn amount_total_cameras(&self) -> i64 {
|
||||
match self {
|
||||
Backend::Sqlite(db) => {
|
||||
|
Reference in New Issue
Block a user