Slightly more expressive expressions.
This commit is contained in:
@@ -5,7 +5,7 @@ use super::{
|
|||||||
RepositoryError, dtos::Upsert,
|
RepositoryError, dtos::Upsert,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, account_members as db, dtos::AccountMemberRow},
|
database::{self, Constraint, DatabaseError, dtos::AccountMemberRow},
|
||||||
domain::AccountMember,
|
domain::AccountMember,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ pub async fn list<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::account_members::Query {
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
.map(|limit| i64::try_from(limit).map_err(|_| QueryConversionError::Limit(limit)))
|
.map(|limit| i64::try_from(limit).map_err(|_| QueryConversionError::Limit(limit)))
|
||||||
@@ -34,7 +34,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let members = db::list(executor, user_id, account_id, query)
|
let members = database::account_members::list(executor, user_id, account_id, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -52,7 +52,7 @@ pub async fn get_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let member = db::get_by_id(executor, user_id, account_id, id)
|
let member = database::account_members::get_by_id(executor, user_id, account_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -68,7 +68,7 @@ pub async fn upsert<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let member = db::upsert(executor, user_id, encode(member))
|
let member = database::account_members::upsert(executor, user_id, encode(member))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?
|
.map_err(classify_upsert_error)?
|
||||||
.map(|upserted| upserted.try_map(decode))
|
.map(|upserted| upserted.try_map(decode))
|
||||||
@@ -88,7 +88,7 @@ pub async fn insert_initial<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let row = db::insert_initial(executor, encode(member))
|
let row = database::account_members::insert_initial(executor, encode(member))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?;
|
.map_err(classify_upsert_error)?;
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ pub async fn delete_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let member = db::delete_by_id(executor, user_id, account_id, id)
|
let member = database::account_members::delete_by_id(executor, user_id, account_id, id)
|
||||||
.await
|
.await
|
||||||
.map_err(classify_delete_error)?
|
.map_err(classify_delete_error)?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use super::{
|
|||||||
dtos::Upsert,
|
dtos::Upsert,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, accounts as db, dtos::AccountRow},
|
database::{self, Constraint, DatabaseError, dtos::AccountRow},
|
||||||
domain::Account,
|
domain::Account,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ pub async fn list<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::accounts::Query {
|
||||||
name: query.name,
|
name: query.name,
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
@@ -37,7 +37,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let accounts = db::list(executor, user_id, query)
|
let accounts = database::accounts::list(executor, user_id, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -54,7 +54,7 @@ pub async fn get_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let account = db::get_by_id(executor, user_id, id)
|
let account = database::accounts::get_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -74,7 +74,7 @@ where
|
|||||||
return Ok(HashMap::new());
|
return Ok(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let accounts = db::get_by_ids(executor, user_id, ids)
|
let accounts = database::accounts::get_by_ids(executor, user_id, ids)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -96,7 +96,7 @@ pub async fn upsert<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let upserted = db::upsert(executor, user_id, encode(account))
|
let upserted = database::accounts::upsert(executor, user_id, encode(account))
|
||||||
.await?
|
.await?
|
||||||
.map(|upserted| upserted.try_map(decode))
|
.map(|upserted| upserted.try_map(decode))
|
||||||
.transpose()?
|
.transpose()?
|
||||||
@@ -113,7 +113,7 @@ pub async fn delete_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let account = db::delete_by_id(executor, user_id, id)
|
let account = database::accounts::delete_by_id(executor, user_id, id)
|
||||||
.await
|
.await
|
||||||
.map_err(classify_delete_error)?
|
.map_err(classify_delete_error)?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ use super::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{
|
database::{self, Constraint, DatabaseError, dtos::RecurringTransactionRow},
|
||||||
Constraint, DatabaseError, dtos::RecurringTransactionRow, recurring_transactions as db,
|
|
||||||
},
|
|
||||||
domain::{Cents, Recurrence, RecurrenceInterval, RecurringTransaction, Schedule},
|
domain::{Cents, Recurrence, RecurrenceInterval, RecurringTransaction, Schedule},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,7 +26,7 @@ pub async fn list<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::recurring_transactions::Query {
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
.map(|l| i64::try_from(l).map_err(|_| QueryConversionError::Limit(l)))
|
.map(|l| i64::try_from(l).map_err(|_| QueryConversionError::Limit(l)))
|
||||||
@@ -39,7 +37,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let transactions = db::list(executor, user_id, query)
|
let transactions = database::recurring_transactions::list(executor, user_id, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -56,7 +54,7 @@ pub async fn get_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let transaction = db::get_by_id(executor, user_id, id)
|
let transaction = database::recurring_transactions::get_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -72,7 +70,7 @@ pub async fn upsert<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let upserted = db::upsert(executor, user_id, encode(transaction))
|
let upserted = database::recurring_transactions::upsert(executor, user_id, encode(transaction))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?
|
.map_err(classify_upsert_error)?
|
||||||
.map(|upserted| upserted.try_map(decode))
|
.map(|upserted| upserted.try_map(decode))
|
||||||
@@ -109,7 +107,7 @@ pub async fn delete_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let transaction = db::delete_by_id(executor, user_id, id)
|
let transaction = database::recurring_transactions::delete_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use chrono::{DateTime, Utc};
|
|||||||
|
|
||||||
use super::RepositoryError;
|
use super::RepositoryError;
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{dtos::TokenRow, tokens as db},
|
database::{self, dtos::TokenRow},
|
||||||
domain::Token,
|
domain::Token,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ pub async fn get_by_access_token_hash<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let token = db::get_by_access_token_hash(executor, access_token_hash)
|
let token = database::tokens::get_by_access_token_hash(executor, access_token_hash)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -25,7 +25,7 @@ pub async fn issue<'e, E>(executor: E, token: Token) -> Result<(), RepositoryErr
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
db::issue(executor, encode(token)).await?;
|
database::tokens::issue(executor, encode(token)).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ pub async fn rotate_refresh_token<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let rotated = db::rotate_refresh_token(
|
let rotated = database::tokens::rotate_refresh_token(
|
||||||
executor,
|
executor,
|
||||||
old_refresh_hash,
|
old_refresh_hash,
|
||||||
access_token_hash,
|
access_token_hash,
|
||||||
@@ -58,7 +58,7 @@ pub async fn revoke<'e, E>(executor: E, token_hash: &[u8]) -> Result<(), Reposit
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
db::revoke(executor, token_hash).await?;
|
database::tokens::revoke(executor, token_hash).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use super::{
|
|||||||
encoding::{decode_direction, encode_direction},
|
encoding::{decode_direction, encode_direction},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, dtos::TransactionRow, transactions as db},
|
database::{self, Constraint, DatabaseError, dtos::TransactionRow},
|
||||||
domain::{Cents, Transaction},
|
domain::{Cents, Transaction},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ pub async fn list<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::transactions::Query {
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
.map(|l| i64::try_from(l).map_err(|_| QueryConversionError::Limit(l)))
|
.map(|l| i64::try_from(l).map_err(|_| QueryConversionError::Limit(l)))
|
||||||
@@ -34,7 +34,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let transactions = db::list(executor, user_id, query)
|
let transactions = database::transactions::list(executor, user_id, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -51,7 +51,7 @@ pub async fn get_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let transaction = db::get_by_id(executor, user_id, id)
|
let transaction = database::transactions::get_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -67,7 +67,7 @@ pub async fn upsert<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let upserted = db::upsert(executor, user_id, encode(transaction))
|
let upserted = database::transactions::upsert(executor, user_id, encode(transaction))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?
|
.map_err(classify_upsert_error)?
|
||||||
.map(|upserted| upserted.try_map(decode))
|
.map(|upserted| upserted.try_map(decode))
|
||||||
@@ -99,7 +99,7 @@ pub async fn delete_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let transaction = db::delete_by_id(executor, user_id, id)
|
let transaction = database::transactions::delete_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use super::{
|
|||||||
QueryConversionError, ReferenceRelation, ReferenceViolationKind, RepositoryError, dtos::Upsert,
|
QueryConversionError, ReferenceRelation, ReferenceViolationKind, RepositoryError, dtos::Upsert,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, dtos::UserAppSecretRow, user_app_secrets as db},
|
database::{self, Constraint, DatabaseError, dtos::UserAppSecretRow},
|
||||||
domain::UserAppSecret,
|
domain::UserAppSecret,
|
||||||
repository::DecodeError,
|
repository::DecodeError,
|
||||||
};
|
};
|
||||||
@@ -23,7 +23,7 @@ pub async fn list<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::user_app_secrets::Query {
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
.map(|limit| i64::try_from(limit).map_err(|_| QueryConversionError::Limit(limit)))
|
.map(|limit| i64::try_from(limit).map_err(|_| QueryConversionError::Limit(limit)))
|
||||||
@@ -34,7 +34,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let secrets = db::list(executor, user_id, app_id, query)
|
let secrets = database::user_app_secrets::list(executor, user_id, app_id, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -52,7 +52,7 @@ pub async fn get_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let secret = db::get_by_id(executor, user_id, app_id, id)
|
let secret = database::user_app_secrets::get_by_id(executor, user_id, app_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -68,7 +68,7 @@ pub async fn upsert<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let secret = db::upsert(executor, user_id, encode(secret))
|
let secret = database::user_app_secrets::upsert(executor, user_id, encode(secret))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?
|
.map_err(classify_upsert_error)?
|
||||||
.map(|upserted| upserted.try_map(decode))
|
.map(|upserted| upserted.try_map(decode))
|
||||||
@@ -100,7 +100,7 @@ pub async fn verify<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let is_valid = db::verify(executor, app_id, secret_hash).await?;
|
let is_valid = database::user_app_secrets::verify(executor, app_id, secret_hash).await?;
|
||||||
|
|
||||||
Ok(is_valid)
|
Ok(is_valid)
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ pub async fn delete_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let secret = db::delete_by_id(executor, user_id, app_id, id)
|
let secret = database::user_app_secrets::delete_by_id(executor, user_id, app_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use super::{QueryConversionError, RepositoryError, dtos::Upsert};
|
use super::{QueryConversionError, RepositoryError, dtos::Upsert};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, dtos::UserAppRow, user_apps as db},
|
database::{self, Constraint, DatabaseError, dtos::UserAppRow},
|
||||||
domain::UserApp,
|
domain::UserApp,
|
||||||
repository::DecodeError,
|
repository::DecodeError,
|
||||||
};
|
};
|
||||||
@@ -20,7 +20,7 @@ pub async fn list<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::user_apps::Query {
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
.map(|limit| i64::try_from(limit).map_err(|_| QueryConversionError::Limit(limit)))
|
.map(|limit| i64::try_from(limit).map_err(|_| QueryConversionError::Limit(limit)))
|
||||||
@@ -31,7 +31,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let apps = db::list(executor, user_id, query)
|
let apps = database::user_apps::list(executor, user_id, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -48,7 +48,7 @@ pub async fn get_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let app = db::get_by_id(executor, user_id, id)
|
let app = database::user_apps::get_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -63,7 +63,7 @@ pub async fn get_by_id_unscoped<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let app = db::get_by_id_unscoped(executor, id)
|
let app = database::user_apps::get_by_id_unscoped(executor, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -78,7 +78,7 @@ pub async fn upsert<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let app = db::upsert(executor, encode(app))
|
let app = database::user_apps::upsert(executor, encode(app))
|
||||||
.await
|
.await
|
||||||
.map_err(classify_upsert_error)?
|
.map_err(classify_upsert_error)?
|
||||||
.map(|upserted| upserted.try_map(decode))
|
.map(|upserted| upserted.try_map(decode))
|
||||||
@@ -110,7 +110,7 @@ pub async fn delete_by_id<'e, E>(
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let app = db::delete_by_id(executor, user_id, id)
|
let app = database::user_apps::delete_by_id(executor, user_id, id)
|
||||||
.await?
|
.await?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use super::{
|
|||||||
dtos::Upsert,
|
dtos::Upsert,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{Constraint, DatabaseError, dtos::UserRow, users as db},
|
database::{self, Constraint, DatabaseError, dtos::UserRow},
|
||||||
domain::User,
|
domain::User,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ pub async fn list<'e, E>(executor: E, query: Query) -> Result<Vec<User>, Reposit
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let query = db::Query {
|
let query = database::users::Query {
|
||||||
limit: query
|
limit: query
|
||||||
.limit
|
.limit
|
||||||
.map(|l| i64::try_from(l).map_err(|_| QueryConversionError::Limit(l)))
|
.map(|l| i64::try_from(l).map_err(|_| QueryConversionError::Limit(l)))
|
||||||
@@ -31,7 +31,7 @@ where
|
|||||||
.transpose()?,
|
.transpose()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let users = db::list(executor, query)
|
let users = database::users::list(executor, query)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -44,7 +44,10 @@ pub async fn get_by_id<'e, E>(executor: E, id: Uuid) -> Result<Option<User>, Rep
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let user = db::get_by_id(executor, id).await?.map(decode).transpose()?;
|
let user = database::users::get_by_id(executor, id)
|
||||||
|
.await?
|
||||||
|
.map(decode)
|
||||||
|
.transpose()?;
|
||||||
|
|
||||||
Ok(user)
|
Ok(user)
|
||||||
}
|
}
|
||||||
@@ -60,7 +63,7 @@ where
|
|||||||
return Ok(HashMap::new());
|
return Ok(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let users = db::get_by_ids(executor, ids)
|
let users = database::users::get_by_ids(executor, ids)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(decode)
|
.map(decode)
|
||||||
@@ -75,7 +78,7 @@ pub async fn upsert<'e, E>(executor: E, user: User) -> Result<Upsert<User>, Repo
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let user = db::upsert(executor, encode(user))
|
let user = database::users::upsert(executor, encode(user))
|
||||||
.await?
|
.await?
|
||||||
.try_map(decode)?
|
.try_map(decode)?
|
||||||
.into();
|
.into();
|
||||||
@@ -87,7 +90,7 @@ pub async fn delete_by_id<'e, E>(executor: E, id: Uuid) -> Result<Option<User>,
|
|||||||
where
|
where
|
||||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||||
{
|
{
|
||||||
let user = db::delete_by_id(executor, id)
|
let user = database::users::delete_by_id(executor, id)
|
||||||
.await
|
.await
|
||||||
.map_err(classify_delete_error)?
|
.map_err(classify_delete_error)?
|
||||||
.map(decode)
|
.map(decode)
|
||||||
|
|||||||
Reference in New Issue
Block a user