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>,
|
account_name: impl Into<String>,
|
||||||
db: &DatabaseConnection,
|
db: &DatabaseConnection,
|
||||||
) -> crate::Result<Option<Model>> {
|
) -> crate::Result<Option<Model>> {
|
||||||
Self::find()
|
Self::find_by_id((user_id, account_name.into()))
|
||||||
.filter(Column::UserId.eq(user_id))
|
|
||||||
.filter(Column::Name.eq(account_name.into()))
|
|
||||||
.one(db)
|
.one(db)
|
||||||
.await
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
|
@ -62,10 +62,9 @@ impl Entity {
|
|||||||
|
|
||||||
/// Checks if the master password for the user exists
|
/// Checks if the master password for the user exists
|
||||||
pub async fn exists(user_id: u64, db: &DatabaseConnection) -> crate::Result<bool> {
|
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()
|
.select_only()
|
||||||
.column(Column::UserId)
|
.column(Column::UserId)
|
||||||
.filter(Column::UserId.eq(user_id))
|
|
||||||
.into_tuple::<u64>()
|
.into_tuple::<u64>()
|
||||||
.one(db)
|
.one(db)
|
||||||
.await?;
|
.await?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user