implement contents method

This commit is contained in:
yggverse 2026-01-07 21:28:01 +02:00
parent 9269ec2a9e
commit 4af10ee153

View file

@ -93,6 +93,16 @@ impl Mysql {
Ok(self.connection.last_insert_id()) Ok(self.connection.last_insert_id())
} }
pub fn contents(&mut self, limit: Option<usize>) -> Result<Vec<Content>, Error> {
self.connection.query_map(
format!(
"SELECT `content_id`, `channel_item_id`, `source_id`, `title`, `description` FROM `content` LIMIT {}",
limit.unwrap_or(DEFAULT_LIMIT)
),
|(content_id, channel_item_id,source_id, title, description)| Content { content_id, channel_item_id, source_id, title, description },
)
}
pub fn contents_by_channel_item_id_source_id( pub fn contents_by_channel_item_id_source_id(
&mut self, &mut self,
channel_item_id: u64, channel_item_id: u64,