Prepping account members for enriching user data.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{
|
||||
@@ -47,6 +49,28 @@ where
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
pub async fn get_by_ids<'e, E>(
|
||||
executor: E,
|
||||
ids: &[Uuid],
|
||||
) -> Result<HashMap<Uuid, User>, RepositoryError>
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
if ids.is_empty() {
|
||||
return Ok(HashMap::new());
|
||||
}
|
||||
|
||||
let users = db::get_by_ids(executor, ids)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(decode)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let user_map = users.into_iter().map(|user| (user.id, user)).collect();
|
||||
|
||||
Ok(user_map)
|
||||
}
|
||||
|
||||
pub async fn upsert<'e, E>(executor: E, user: User) -> Result<Upsert<User>, RepositoryError>
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
|
||||
Reference in New Issue
Block a user