mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-03 17:14:03 +00:00 
			
		
		
		
	Simplify future database requests
This commit is contained in:
		@@ -53,8 +53,8 @@ pub fn login_user(email: &str, password: &str, client: &APIClient) -> ResultBoxE
 | 
				
			|||||||
fn get_client_tokens(user_id: UserID, client: &APIClient) -> ResultBoxError<UserAccessToken> {
 | 
					fn get_client_tokens(user_id: UserID, client: &APIClient) -> ResultBoxError<UserAccessToken> {
 | 
				
			||||||
    database::query_row(
 | 
					    database::query_row(
 | 
				
			||||||
        QueryInfo::new(USER_ACCESS_TOKENS_TABLE)
 | 
					        QueryInfo::new(USER_ACCESS_TOKENS_TABLE)
 | 
				
			||||||
            .cond("user_id", user_id.to_string().as_ref())
 | 
					            .cond_i64("user_id", user_id)
 | 
				
			||||||
            .cond("service_id", client.id.to_string().as_ref()),
 | 
					            .cond_u32("service_id", client.id),
 | 
				
			||||||
        |res| {
 | 
					        |res| {
 | 
				
			||||||
            Ok(UserAccessToken {
 | 
					            Ok(UserAccessToken {
 | 
				
			||||||
                user_id: res.get_int64("user_id")?,
 | 
					                user_id: res.get_int64("user_id")?,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,6 +78,16 @@ impl QueryInfo {
 | 
				
			|||||||
        self.conditions.insert(key.to_string(), val.to_string());
 | 
					        self.conditions.insert(key.to_string(), val.to_string());
 | 
				
			||||||
        self
 | 
					        self
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub fn cond_u32(mut self, key: &str, val: u32) -> QueryInfo {
 | 
				
			||||||
 | 
					        self.conditions.insert(key.to_string(), val.to_string());
 | 
				
			||||||
 | 
					        self
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub fn cond_i64(mut self, key: &str, val: i64) -> QueryInfo {
 | 
				
			||||||
 | 
					        self.conditions.insert(key.to_string(), val.to_string());
 | 
				
			||||||
 | 
					        self
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Struct used to read the result of a request
 | 
					/// Struct used to read the result of a request
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user