fengcen / arthas

[ABANDONED] An in-memory structure database for Rust.
MIT License
18 stars 1 forks source link

Where is id stored? #3

Closed pyrossh closed 7 years ago

pyrossh commented 7 years ago

I have a user struct which is used to create a user and a user has comments. How do I query the Comments for this user since the id is not stored in the User struct by you and is instead returned. Wouldn't it be better if you stored the id in the struct instead of returning it or else I have to manually update the struct again in the same fn.

pub struct User {
    pub id: String,
    pub email: String,
    pub name: String,
}

pub struct Comments {
   pub id: String,
   pub user_id: String,
   pub message: String,
}

fn getUser(email: String) {
  let user = User::session().field("email").eq(email).find_one().unwrap();
  // how do I query the Comments for this user since the id is not stored by you instead returned.
}

fn main() {
    User::session().insert(user)
}
fengcen commented 7 years ago

Arthas use the name "_id" instead of "id“. See Document.

pyrossh commented 7 years ago

ohh .. didn't know thanks...