1use crate::db::connect::DatabaseConnection;
4use surrealdb::Result;
5use uuid::Uuid;
6
7pub struct Creator<'a> {
8 db: &'a DatabaseConnection,
9}
10
11impl<'a> Creator<'a> {
12 pub fn new(db: &'a DatabaseConnection) -> Self {
13 Self { db }
14 }
15
16 pub async fn add_cat(&self, imie: &str, kolor: &str) -> Result<String> {
19 let new_id = Uuid::now_v7();
20
21 let sql = format!(
23 "CREATE kot:`{}` SET imie = '{}', kolor = '{}', zrodlo = 'Editor Window';",
24 new_id, imie, kolor
25 );
26
27 self.db.client.query(&sql).await?;
29
30 Ok(new_id.to_string())
31 }
32}