//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 use sea_orm::{entity::prelude::*, QuerySelect}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "master_pass")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub user_id: u64, #[sea_orm(column_type = "Binary(BlobSize::Blob(Some(64)))")] pub salt: Vec, #[sea_orm(column_type = "Binary(BlobSize::Blob(Some(64)))")] pub password_hash: Vec, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} impl Entity { /// Gets the master password from the database #[inline] pub async fn get(user_id: u64, db: &DatabaseConnection) -> crate::Result> { Self::find_by_id(user_id).one(db).await } /// 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()) } /// Removes a master password of the user from the database pub async fn remove(user_id: u64, db: &DatabaseConnection) -> Result<(), DbErr> { Self::delete_by_id(user_id).exec(db).await?; Ok(()) } }