1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 08:55:16 +00:00

Can get a user id included in a POST request

This commit is contained in:
2020-05-29 18:15:24 +02:00
parent 8e2a4a8b71
commit cf2d9606d9
4 changed files with 31 additions and 1 deletions

View File

@ -107,6 +107,11 @@ impl QueryInfo {
-> Result<Vec<E>, Box<dyn Error>> {
query(self, process_function)
}
/// Execute count query
pub fn exec_count(self) -> ResultBoxError<usize> {
count(self)
}
}
/// Struct used to read the result of a request

View File

@ -52,4 +52,11 @@ fn exec_get_user_query(query: database::QueryInfo) -> ResultBoxError<User> {
account_image_visibility,
})
})
}
/// Check out whether a given id maps to a user or not
pub fn exists(id: UserID) -> ResultBoxError<bool> {
Ok(database::QueryInfo::new(USERS_TABLE)
.cond_i64("ID", id)
.exec_count()? > 0)
}