Reduced the amount of filters by using find_by_id
This commit is contained in:
parent
2c69882b13
commit
e973116df4
@ -141,9 +141,7 @@ impl Entity {
|
||||
account_name: impl Into<String>,
|
||||
db: &DatabaseConnection,
|
||||
) -> crate::Result<Option<Model>> {
|
||||
Self::find()
|
||||
.filter(Column::UserId.eq(user_id))
|
||||
.filter(Column::Name.eq(account_name.into()))
|
||||
Self::find_by_id((user_id, account_name.into()))
|
||||
.one(db)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
|
@ -62,10 +62,9 @@ impl Entity {
|
||||
|
||||
/// Checks if the master password for the user exists
|
||||
pub async fn exists(user_id: u64, db: &DatabaseConnection) -> crate::Result<bool> {
|
||||
let id = Self::find()
|
||||
let id = Self::find_by_id(user_id)
|
||||
.select_only()
|
||||
.column(Column::UserId)
|
||||
.filter(Column::UserId.eq(user_id))
|
||||
.into_tuple::<u64>()
|
||||
.one(db)
|
||||
.await?;
|
||||
|
Loading…
Reference in New Issue
Block a user