Practical Rust Web Development - CI Travis Werner Echezuría on July 24, 2019 Tools like Travis can be really helpful to figure it out the stability of our software, specially when we have a huge codebase that requires a lot ... Read full post Submit Preview Dismiss Collapse Expand LayNath242 LayNath242 LayNath242 Follow Joined Jul 2, 2019 • Jul 25 '19 • Edited on Jul 25 • Edited Dropdown menu Copy link Hide hello teacher.i have user table and role table. select fullname, roles.title from users inner join roles on roles.id = users.role_id; how to write this in rust. thank you. Collapse Expand Andrew Andersen Andrew Andersen Andrew Andersen Follow Pronouns he/him Joined May 14, 2019 • Jul 25 '19 • Edited on Jul 25 • Edited Dropdown menu Copy link Hide Probably you need this diesel.rs Collapse Expand LayNath242 LayNath242 LayNath242 Follow Joined Jul 2, 2019 • Jul 25 '19 Dropdown menu Copy link Hide thank you, but i'm so beginner i still don't understand. Andrew Andersen Andrew Andersen Andrew Andersen Follow Pronouns he/him Joined May 14, 2019 • Jul 25 '19 Dropdown menu Copy link Hide Do you know Rust? LayNath242 LayNath242 LayNath242 Follow Joined Jul 2, 2019 • Jul 26 '19 Dropdown menu Copy link Hide know but not much. Collapse Expand Ben Lovy Ben Lovy Ben Lovy Follow Just this guy, you know? Email ben@deciduously.com Location Boston, MA, USA Education Currently enrolled @ Champlain College Online Work Rust Developer @ Tangram.dev Joined Mar 19, 2018 • Jul 25 '19 Dropdown menu Copy link Hide Check out include_sql. Diesel is a full featured ORM. Not all projects need it, you can of course write SQL directly. Collapse Expand LayNath242 LayNath242 LayNath242 Follow Joined Jul 2, 2019 • Jul 29 '19 • Edited on Jul 29 • Edited Dropdown menu Copy link Hide 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 Expand Werner Echezuría Werner Echezuría Werner Echezuría Follow Ruby on Rails developer and Rust enthusiast. Location Buenos Aires Joined May 2, 2019 • Jul 29 '19 Dropdown menu Copy link Hide Hi, like SQL you can use a select clause, for example: github.com/practical-rust-web-deve... Collapse Expand LayNath242 LayNath242 LayNath242 Follow Joined Jul 2, 2019 • Jul 30 '19 Dropdown menu Copy link Hide thank you Collapse Expand Comment deleted Collapse Expand Werner Echezuría Werner Echezuría Werner Echezuría Follow Ruby on Rails developer and Rust enthusiast. Location Buenos Aires Joined May 2, 2019 • Aug 6 '19 Dropdown menu Copy link Hide Hi, you need to register an user, for example: ➜ mystore git:(master) curl -i --request POST \ <<< --url http://localhost:8088/register \ --header 'content-type: application/json' \ --data '{ "email": "name@domain.com", "company": "My Company", "password":"password", "password_confirmation": "password" }' HTTP/1.1 200 OK content-length: 92 content-type: application/json date: Tue, 06 Aug 2019 12:38:34 GMT {"email":"name@domain.com","company":"My Company","created_at":"2019-08-06T09:38:41.833136"}% Then you need to login: ➜ mystore git:(master) curl -i --request POST \ <<< --url http://localhost:8088/auth \ --header 'content-type: application/json' \ --data '{ "email": "name@domain.com", "password":"password" }' HTTP/1.1 200 OK content-length: 92 content-type: application/json x-csrf-token: 41130a33c627781f7dd0f81d95a33ca4223b8d85b322386793aacb97aa13833115b85913951dafceead03516e870f682d077e300c0ceb030371984d9133ca002991aec8fad22c391 set-cookie: mystorejwt=4LKhublDMvdz0/tU/lZVLQAwj8pSqNLsRl8heiOM8LMyH3pekc7PSdEit09j4eXYFCMcLt+2h+Wxf2U1aoDN2/8J+3hVt/61z3EXTBnGNe/oig3qh0Ftz2mt6OBXjwot5EjogsXtFEbje4TSMby0zE3yy+xOLhejEseBdABz0F6YhNls8zPw2UA7bH+RZ6Fa471Ph83IU0XVhqHDcgz9uQAtlgTs/BnX6EorDK2xTmIDgiWRWr6DCNB005sf76rT4emFbV6DlORe95s8Hh702Q==; HttpOnly; Path=/; Domain=localhost; Max-Age=86400 date: Tue, 06 Aug 2019 12:40:04 GMT {"email":"name@domain.com","company":"My Company","created_at":"2019-08-06T09:38:41.833136"}% You copy the cookie and csrf token and pass them through the request: curl -v --cookie "mystorejwt=4LKhublDMvdz0/tU/lZVLQAwj8pSqNLsRl8heiOM8LMyH3pekc7PSdEit09j4eXYFCMcLt+2h+Wxf2U1aoDN2/8J+3hVt/61z3EXTBnGNe/oig3qh0Ftz2mt6OBXjwot5EjogsXtFEbje4TSMby0zE3yy+xOLhejEseBdABz0F6YhNls8zPw2UA7bH+RZ6Fa471Ph83IU0XVhqHDcgz9uQAtlgTs/BnX6EorDK2xTmIDgiWRWr6DCNB005sf76rT4emFbV6DlORe95s8Hh702Q==; Path=/; Domain=localhost; Max-Age=86400" --header "x-csrf-token: 41130a33c627781f7dd0f81d95a33ca4223b8d85b322386793aacb97aa13833115b85913951dafceead03516e870f682d077e300c0ceb030371984d9133ca002991aec8fad22c391" -H "Content-Type: application/json" http://localhost:8088/products\?search\="products" Code of Conduct • Report abuse
hello teacher.i have user table and role table.
select fullname, roles.title from users inner join roles on roles.id = users.role_id;
how to write this in rust.
thank you.
Probably you need this diesel.rs
thank you, but i'm so beginner i still don't understand.
Do you know Rust?
know but not much.
Check out include_sql. Diesel is a full featured ORM. Not all projects need it, you can of course write SQL directly.
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;
}
Hi, like SQL you can use a select clause, for example: github.com/practical-rust-web-deve...
thank you
Hi, you need to register an user, for example:
Then you need to login:
You copy the cookie and csrf token and pass them through the request: