File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1414
1515use tracing:: debug;
1616
17- use crate :: { database:: Database , model:: JsonWebKey , repository:: Result } ;
17+ use crate :: {
18+ database:: Database ,
19+ model:: { JsonWebKey , UserModel } ,
20+ repository:: Result ,
21+ } ;
1822
1923/// Repository for managing user-related operations in the database.
2024pub struct UserRepository ;
@@ -27,4 +31,14 @@ impl UserRepository {
2731 sqlx:: query_as :: < _ , JsonWebKey > ( "SELECT * FROM jwks" ) . fetch_all ( db. pool ( ) ) . await ?;
2832 Ok ( keys)
2933 }
34+
35+ /// Fetch a user by their ID.
36+ pub async fn get_by_id ( db : & Database , id : & str ) -> Result < UserModel > {
37+ let row = sqlx:: query_as :: < _ , UserModel > ( r#"SELECT * FROM users WHERE id = $1"# )
38+ . bind ( id)
39+ . fetch_one ( db. pool ( ) )
40+ . await ?;
41+
42+ Ok ( row)
43+ }
3044}
You can’t perform that action at this time.
0 commit comments