Added Account::get method

This commit is contained in:
2023-05-06 20:37:26 +03:00
parent 71940762ff
commit 4a0760d711
2 changed files with 21 additions and 7 deletions

View File

@ -129,4 +129,17 @@ impl Entity {
.await?;
Ok(result.is_some())
}
pub async fn get(
user_id: u64,
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()))
.one(db)
.await
.map_err(Into::into)
}
}