wither icon indicating copy to clipboard operation
wither copied to clipboard

Using basic example

Open somehowchris opened this issue 4 years ago • 11 comments
trafficstars

Hey man,

I love the effort and the crate, but I seem to have a bit of trouble getting the basic things running.

I started using it with rocket the web framework since it will support tokio with 0.5.0, but the find method seems to run into a few compile issues.

error[E0599]: no method named `next` found for struct `ModelCursor<UserEntity>` in the current scope
  --> src/users/service.rs:20:25
   |
20 |   print!("{:?}", cursor.next().await);
   |                         ^^^^ method not found in `ModelCursor<UserEntity>`

To my knowledge, this is basically the same as your basic example, but it should just output the first one (if there is any).

This is the code I call before.

let mut cursor: ModelCursor<UserEntity> = UserEntity::find(db_connection, None, None).await.unwrap();

I have defined the model as followed

#[derive(Debug, Model, Serialize, Deserialize)]
#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
#[model(index(keys=r#"doc!{"name": 1}"#, options=r#"doc!{"unique": true}"#))]
pub struct UserEntity {
  #[serde(rename="_id", skip_serializing_if="Option::is_none")]
  pub id: Option<ObjectId>,
  pub name: String
}

Am I missing something out? I have also tried to run your exact example, but that neither worked

somehowchris avatar Apr 11 '21 20:04 somehowchris

I assume you figured it out but if not you would need futures::StreamExt.

dariusc93 avatar May 28 '21 21:05 dariusc93

Hey, thanks for the follow-up! I apologize about the complete lack of response. And yes, that is correct. The basic example in the readme is compiled and tested. Maybe you forgot to include the StreamExt trait during copy/paste?

thedodd avatar May 31 '21 17:05 thedodd

@thedodd Any chance of updating Tokio? Would be nice since rocket can handle Async things now

somehowchris avatar Aug 17 '21 16:08 somehowchris

@somehowchris hey, that's a good idea. Will do.

thedodd avatar Aug 18 '21 13:08 thedodd

@thedodd ever considered (or will you consider) to get synk, depenadabot or renovate? To get dependency updates and for security reasons

somehowchris avatar Aug 18 '21 15:08 somehowchris

Definitely, though in this case it wouldn't make any difference. The only reason I haven't already done so is due to time constraints, not because I was unaware of the Tokio updates and such :).

Wither was one of my first open source Rust projects ... and I personally do not use it much any more, only because I don't use MongoDB much anymore. So I definitely rely upon the community for update requests and the like.

I would love to have someone else actively using the project to join as a co-maintainer, which would be a boon to everyone involved.

thedodd avatar Aug 18 '21 16:08 thedodd

@somehowchris as it turns out, we are blocked on upgrading to Tokio 1.0 until the underlying MongoDB crate updates. Wither is just a lightweight dependency on top of the mongodb crate, so we do not actually specify any runtime deps in this crate.

thedodd avatar Aug 18 '21 19:08 thedodd

Note that mongodb has support for tokio 1.0 starting in 2.0.0-alpha (which is basically just the 1.x driver with tokio 1.0 support). Later 2.0 pre-releases (2.0.0-beta.3 being the most recent) also support tokio 1.0 along with a lot of new features and breaking changes. So if you're okay with depending on a pre-release, you don't need to wait any longer. For what it's worth, 2.0.0-beta.3 will be very similar to the actual 2.0.0 release and there shouldn't be any major breaking changes between the two of them.

patrickfreed avatar Aug 18 '21 20:08 patrickfreed

Definitely, though in this case it wouldn't make any difference. The only reason I haven't already done so is due to time constraints, not because I was unaware of the Tokio updates and such :).

Wither was one of my first open source Rust projects ... and I personally do not use it much any more, only because I don't use MongoDB much anymore. So I definitely rely upon the community for update requests and the like.

I would love to have someone else actively using the project to join as a co-maintainer, which would be a boon to everyone involved.

Hi, could you consider me as a co-mantainer? I work fulltime but in my spare time I'd like to keep this project alive, I believe it is one of the best Rust database projects!

simoneromano96 avatar Sep 02 '21 08:09 simoneromano96

@simoneromano96 I definitely need to get some other folks involved in keeping this project alive. I'll send you an invite!

thedodd avatar Sep 02 '21 15:09 thedodd

@thedodd Any chance of updating Tokio? Would be nice since rocket can handle Async things now

Hi, I would create a feature in wither to use the mongo client beta, WDYT?

simoneromano96 avatar Sep 05 '21 11:09 simoneromano96