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)
}
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.