A digital life memoir of your life
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1023 B

//! Versions of the entry.
use serde::Deserialize;
use serde::Serialize;
#[derive(Deserialize, Serialize)]
pub struct IncomingEntry {
title: String,
content: String,
source: String,
meta: Vec<super::meta::IncomingMeta>,
attachments: Vec<super::attachment::IncomingAttachment>,
}
impl IncomingEntry {
pub async fn save(
&self,
transaction: &mut sqlx::Transaction<'_, sqlx::Sqlite>,
) -> Result<String, sqlx::Error> {
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,
}