Change Over to new derive

This commit is contained in:
2025-09-15 21:40:31 +03:00
parent 771be89260
commit 6252ec87b9
14 changed files with 97 additions and 179 deletions

View File

@@ -1,4 +1,5 @@
use anyhow::Result;
use persmgr_derive::TableMeta;
use sqlx::prelude::FromRow;
use crate::db::{
@@ -6,7 +7,8 @@ use crate::db::{
tables::{ForeignKey, TableMeta, assignables::awards::Award, user::User},
};
#[derive(Debug, Default, Clone, FromRow)]
#[derive(Debug, Default, Clone, FromRow, TableMeta)]
#[meta(table = "records_awards")]
pub struct AwardRecord {
pub id: i64,
pub user_id: ForeignKey<User>,
@@ -15,11 +17,6 @@ pub struct AwardRecord {
pub created_at: i64,
}
impl TableMeta for AwardRecord {
type PrimaryKey = i64;
const TABLE: &'static str = "records_awards";
}
impl AwardRecord {
pub async fn insert_new(&self, pool: &CurrPool) -> Result<Self> {
let session = sqlx::query_as!(