mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Optimize request
This commit is contained in:
		@@ -70,7 +70,8 @@ pub fn get_user_by_login_token(token: &str, client: &APIClient) -> ResultBoxErro
 | 
			
		||||
    database::query_row(
 | 
			
		||||
        QueryInfo::new(USER_ACCESS_TOKENS_TABLE)
 | 
			
		||||
            .cond_u32("service_id", client.id)
 | 
			
		||||
            .cond("token1", token),
 | 
			
		||||
            .cond("token1", token)
 | 
			
		||||
            .add_field("user_id"),
 | 
			
		||||
        |res| res.get_int64("user_id"),
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
@@ -60,6 +60,8 @@ pub struct QueryInfo {
 | 
			
		||||
    pub limit: u64,
 | 
			
		||||
 | 
			
		||||
    /// Queried arguments
 | 
			
		||||
    ///
 | 
			
		||||
    /// If this attribute is empty, all the columns of the table set are fetched
 | 
			
		||||
    pub fields: Vec<String>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -88,6 +90,12 @@ impl QueryInfo {
 | 
			
		||||
        self.conditions.insert(key.to_string(), val.to_string());
 | 
			
		||||
        self
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Append a field to the list of selected fields
 | 
			
		||||
    pub fn add_field(mut self, key: &str) -> QueryInfo {
 | 
			
		||||
        self.fields.push(key.to_string());
 | 
			
		||||
        self
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Struct used to read the result of a request
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user