mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-19 06:21:15 +00:00
feat: admin query
This commit is contained in:
parent
05fe04ca96
commit
8b3305dae7
2 changed files with 19 additions and 0 deletions
18
core/src/database/query/admin.rs
Normal file
18
core/src/database/query/admin.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use crate::Query;
|
||||
|
||||
use ::entity::{candidate, candidate::Entity as Admin};
|
||||
use sea_orm::*;
|
||||
|
||||
impl Query {
|
||||
pub async fn find_admin_by_id(db: &DbConn, id: i32) -> Result<Option<candidate::Model>, DbErr> {
|
||||
Admin::find_by_id(id).one(db).await
|
||||
}
|
||||
|
||||
pub async fn get_all_admin_public_keys(db: &DbConn) -> Result<Vec<String>, DbErr> {
|
||||
let admins = Admin::find().all(db).await?;
|
||||
|
||||
let public_keys = admins.iter().map(|admin| admin.public_key.clone()).collect();
|
||||
|
||||
Ok(public_keys)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
pub struct Query;
|
||||
|
||||
pub mod candidate;
|
||||
pub mod admin;
|
||||
pub mod session;
|
||||
Loading…
Reference in a new issue