diff --git a/upub/core/src/ext.rs b/upub/core/src/ext.rs index bd2f78f7..b08651f4 100644 --- a/upub/core/src/ext.rs +++ b/upub/core/src/ext.rs @@ -1,4 +1,4 @@ -use sea_orm::ConnectionTrait; +use sea_orm::{ConnectionTrait, PaginatorTrait}; #[async_trait::async_trait] @@ -7,16 +7,19 @@ pub trait AnyQuery { } #[async_trait::async_trait] -impl AnyQuery for sea_orm::Select { +impl AnyQuery for sea_orm::Select +where + T::Model : Sync, +{ async fn any(self, db: &impl ConnectionTrait) -> Result { - Ok(self.one(db).await?.is_some()) + Ok(self.count(db).await? > 0) } } #[async_trait::async_trait] -impl AnyQuery for sea_orm::Selector { +impl AnyQuery for sea_orm::Selector { async fn any(self, db: &impl ConnectionTrait) -> Result { - Ok(self.one(db).await?.is_some()) + Ok(self.count(db).await? > 0) } }