Return account details.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{
|
||||
@@ -66,6 +68,29 @@ where
|
||||
Ok(account)
|
||||
}
|
||||
|
||||
pub async fn get_by_ids<'e, E>(
|
||||
executor: E,
|
||||
ids: &[Uuid],
|
||||
) -> Result<HashMap<Uuid, Account>, RepositoryError>
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
if ids.is_empty() {
|
||||
return Ok(HashMap::new());
|
||||
}
|
||||
|
||||
let accounts = db::get_by_ids(executor, ids)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(decode)
|
||||
.collect::<Result<Vec<_>, DecodeError>>()?;
|
||||
|
||||
Ok(accounts
|
||||
.into_iter()
|
||||
.map(|account| (account.id, account))
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub async fn upsert<'e, E>(
|
||||
executor: E,
|
||||
account: Account,
|
||||
|
||||
Reference in New Issue
Block a user