add: change default avatar
This commit is contained in:
parent
8dfd307919
commit
959a125992
6 changed files with 92 additions and 13 deletions
|
@ -75,6 +75,26 @@ impl DataManager {
|
|||
|
||||
Ok(res.unwrap())
|
||||
}
|
||||
|
||||
pub async fn get_table_row_count_where(&self, table: &str, r#where: &str) -> Result<i32> {
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
||||
let res = query_row!(
|
||||
&conn,
|
||||
&format!("SELECT COUNT(*)::int FROM {} {}", table, r#where),
|
||||
params![],
|
||||
|x| Ok(x.get::<usize, i32>(0))
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
Ok(res.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue