use super::MemoryConfigStore;
use crate::storage::Error;
use pbbson::Model;
use std::fmt::Debug;
use std::str::FromStr;
pub async fn perform<B: Clone + Debug + FromStr + Send + Sync + ToString>(
this: &MemoryConfigStore<B>,
bucket: B,
id: &str,
) -> Result<Model, Error> {
let doc_holder = this.doc_holder(&bucket)?;
let docs = doc_holder
.docs
.lock()
.map_err(|e| Error::failed_precondition(e.to_string()))?;
let model = match docs.get(id) {
None => return Err(Error::not_found("No such record")),
Some(model) => model,
};
Ok(model.clone())
}