This commit is contained in:
JMARyA 2024-05-10 10:56:07 +02:00
parent e50b51c829
commit 39905f53c2
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 64 additions and 59 deletions

View file

@ -39,11 +39,10 @@ macro_rules! id_of {
pub struct ItemDB {
index: mdq::Index,
mongodb: mongodb::Client,
}
impl ItemDB {
pub async fn new(dir: &str, mongodb: &str) -> Self {
pub async fn new(dir: &str) -> Self {
// scan for markdown item entries
let index = mdq::Index::new(dir, true);
let mongodb = get_mongo!();
@ -53,13 +52,12 @@ impl ItemDB {
item.init_db(&mongodb).await;
}
Self { index, mongodb }
Self { index }
}
/// Retrieves an item by name
pub fn get_item(&self, item: &str) -> Option<Item> {
Some(Item::new(
self.mongodb.clone(),
self.index
.documents
.iter()