DEV Community

Discussion on: Practical Rust Web Development - CI Travis

Collapse
 
laynath242 profile image
LayNath242 • Edited

Hello. I do this and got all data. but i only need only username and title. How to do this.Thank you.

[derive(Serialize, Deserialize)]

pub struct UserRoleList(pub Vec<(Role, User)>);

impl UserRoleList {
pub fn list(connection: &PgConnection) -> Self {
use crate::schema::{roles,users};
use diesel::RunQueryDsl;
use diesel::QueryDsl;

    let result = roles::table.inner_join(users::table)
                .load::<(Role, User)>(connection)
                .expect("Error loading ");
        UserRoleList(result)
}

}

Collapse
 
werner profile image
Werner Echezuría

Hi, like SQL you can use a select clause, for example: github.com/practical-rust-web-deve...

Collapse
 
laynath242 profile image
LayNath242

thank you