Added the ability to get tags from the database.
Also fixed the way the example was compiling so it didn't act weird on other features.
This commit is contained in:
@ -274,6 +274,27 @@ impl Database
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(any(not(feature = "publisher"), feature = "tester"))]
|
||||
pub async fn get_all_tags(&self) -> Result<Vec<String>>
|
||||
{
|
||||
let mut tx = self.pool.begin().await?;
|
||||
|
||||
let rows = sqlx::query!(
|
||||
"SELECT name FROM tags ORDER BY name ASC"
|
||||
)
|
||||
.fetch_all(&mut *tx)
|
||||
.await?;
|
||||
|
||||
tx.commit().await?;
|
||||
|
||||
let tags = rows
|
||||
.into_iter()
|
||||
.filter_map(|row| Some(row.name))
|
||||
.collect();
|
||||
|
||||
Ok(tags)
|
||||
}
|
||||
|
||||
#[cfg(any(not(feature = "publisher"), feature = "tester"))]
|
||||
pub async fn get_tales_summary(&self, categories: &[String])
|
||||
-> Result<Vec<Lore>>
|
||||
|
||||
Reference in New Issue
Block a user