//! Versions of the entry. use serde::Deserialize; use serde::Serialize; #[derive(Deserialize, Serialize)] pub struct IncomingEntry { title: String, content: String, source: String, meta: Vec, attachments: Vec, } impl IncomingEntry { pub async fn save( &self, transaction: &mut sqlx::Transaction<'_, sqlx::Sqlite>, ) -> Result { let id: String = uuid::Uuid::new_v4() .hyphenated() .encode_lower(&mut uuid::Uuid::encode_buffer()) .into(); sqlx::query( r#"INSERT INTO entry (id, title, content, source) VALUES (?, ?, ?, ?)"#, ) .bind(&id) .bind(&self.title) .bind(&self.content) .bind(&self.source) .execute(transaction) .await?; Ok(id.into()) } } #[derive(Serialize)] pub struct OutgoingEntry { pub id: String, }