Layer query simplification.

This commit is contained in:
2026-10-08 21:32:44 +02:00
parent c51e9425d6
commit 3709fcbe02
12 changed files with 82 additions and 232 deletions
+13 -28
View File
@@ -12,21 +12,13 @@ pub struct Query {
pub offset: Option<u64>,
}
impl Default for Query {
fn default() -> Self {
Self {
user_id: Uuid::nil(),
limit: None,
offset: None,
}
}
}
impl TryFrom<Query> for db::Query {
type Error = QueryConversionError;
fn try_from(query: Query) -> Result<Self, Self::Error> {
Ok(db::Query {
pub async fn list<'e, E>(executor: E, query: Query) -> Result<Vec<UserApp>, RepositoryError>
where
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
{
Ok(db::list(
executor,
db::Query {
user_id: query.user_id,
limit: query
.limit
@@ -38,19 +30,12 @@ impl TryFrom<Query> for db::Query {
i64::try_from(offset).map_err(|_| QueryConversionError::Offset(offset))
})
.transpose()?,
})
}
}
pub async fn list<'e, E>(executor: E, query: Query) -> Result<Vec<UserApp>, RepositoryError>
where
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
{
Ok(db::list(executor, query.try_into()?)
.await?
.into_iter()
.map(decode)
.collect())
},
)
.await?
.into_iter()
.map(decode)
.collect())
}
pub async fn get_by_id<'e, E>(