diff --git a/entity/src/account.rs b/entity/src/account.rs index 5edc8b5..d702986 100644 --- a/entity/src/account.rs +++ b/entity/src/account.rs @@ -59,13 +59,10 @@ impl Entity { account_name: impl Into, db: &DatabaseConnection, ) -> crate::Result { - let result = Self::find_by_id((user_id, account_name.into())) - .select_only() - .column(Column::UserId) - .into_tuple::() - .one(db) + let count = Self::find_by_id((user_id, account_name.into())) + .count(db) .await?; - Ok(result.is_some()) + Ok(count != 0) } /// Gets the account from the DB diff --git a/entity/src/master_pass.rs b/entity/src/master_pass.rs index c853353..af20b61 100644 --- a/entity/src/master_pass.rs +++ b/entity/src/master_pass.rs @@ -1,6 +1,6 @@ //! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 -use sea_orm::{entity::prelude::*, QuerySelect}; +use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "master_pass")] @@ -28,13 +28,8 @@ impl Entity { /// Checks if the master password for the user exists #[inline] pub async fn exists(user_id: u64, db: &DatabaseConnection) -> Result { - let id = Self::find_by_id(user_id) - .select_only() - .column(Column::UserId) - .into_tuple::() - .one(db) - .await?; - Ok(id.is_some()) + let count = Self::find_by_id(user_id).count(db).await?; + Ok(count != 0) } /// Removes a master password of the user from the database