thedodd/wither

Wither not working with mongodb operating in async-std

Closed this issue · 3 comments

I have mongodb specified in Cargo as follows:

mongodb ={ version= "2.2.1", features = ["async-std"] }
wither = { git = "https://github.com/thedodd/wither", branch = "master" }

My model is specified with implementation as follows:

#[model(collection_name = "foo")]
pub struct Foo {
 ...
}


impl Foo {
    pub(crate) async fn fetch(db: &Database, f: Option<Document>) -> Result<Self, ResError> {
        if let Some(t) = Self::find_one(&db, f, None).await? {
            return Ok(t);
        }
        Err(ResError::NotFound)
    }
}

Unfortunately the call to find_one does not seems to get executed. Any ideas what I might be doing wrong guys? thanks.

I have added wither Cargo definition.

I am going to close this issue as I believe it has nothing to do with wither due to trying to use native mongodb to perform the same classic task and yet the same problem.

FYI for anyone who comes across this issue in the future:

  • the feature flag needs to be specified as async-std-runtime, not just async-std
  • since tokio-runtime is a default flag, in order to use async-std, you also need to pass in default-features = false