Cleaned up imports.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{
|
||||
DecodeError, Delete, QueryConversionError, RepositoryError, Upsert,
|
||||
DecodeError, QueryConversionError, RepositoryError,
|
||||
dtos::{Delete, Upsert},
|
||||
encoding::{decode_direction, encode_direction},
|
||||
};
|
||||
use crate::{
|
||||
database::{dtos::transaction::TransactionRow, transactions as db},
|
||||
database::{dtos::TransactionRow, transactions as db},
|
||||
domain::{Cents, Transaction},
|
||||
};
|
||||
|
||||
@@ -35,7 +36,7 @@ pub async fn list<'e, E>(executor: E, query: Query) -> Result<Vec<Transaction>,
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
let transactions = db::query_transactions(executor, query.try_into()?)
|
||||
let transactions = db::query(executor, query.try_into()?)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(decode)
|
||||
@@ -48,10 +49,7 @@ pub async fn get<'e, E>(executor: E, id: Uuid) -> Result<Option<Transaction>, Re
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
let transaction = db::get_transaction_by_id(executor, id)
|
||||
.await?
|
||||
.map(decode)
|
||||
.transpose()?;
|
||||
let transaction = db::get_by_id(executor, id).await?.map(decode).transpose()?;
|
||||
|
||||
Ok(transaction)
|
||||
}
|
||||
@@ -63,18 +61,18 @@ pub async fn upsert<'e, E>(
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
let transaction = db::upsert_transaction(executor, encode(transaction))
|
||||
let transaction = db::upsert(executor, encode(transaction))
|
||||
.await?
|
||||
.try_map(decode)?;
|
||||
|
||||
Ok(transaction)
|
||||
Ok(transaction.into())
|
||||
}
|
||||
|
||||
pub async fn delete<'e, E>(executor: E, id: Uuid) -> Result<Delete, RepositoryError>
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
Ok(db::delete_transaction_by_id(executor, id).await?)
|
||||
Ok(db::delete_by_id(executor, id).await?.into())
|
||||
}
|
||||
|
||||
fn decode(row: TransactionRow) -> Result<Transaction, DecodeError> {
|
||||
|
||||
Reference in New Issue
Block a user