work
This commit is contained in:
parent
e50b51c829
commit
39905f53c2
5 changed files with 64 additions and 59 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue