Skip to content

Using basic example #81

@somehowchris

Description

@somehowchris

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions