feat!(database): adding the database Db* type

This commit is contained in:
Raphael 2026-02-13 19:50:36 +01:00 committed by Raphaël
parent 9303e8dd7f
commit 5ffb334130
5 changed files with 50 additions and 21 deletions

View file

@ -1,5 +1,5 @@
use sqlx::{PgPool, query, query_as};
use crate::models::bot::{Bot, BotPresence, BotActivity};
use crate::models::bot::{DbBot, BotPresence, BotActivity};
const BOT_ID: i32 = 1;
@ -11,8 +11,8 @@ pub async fn init(db: &PgPool) -> Result<(), sqlx::Error> {
Ok(())
}
pub async fn get(db: &PgPool) -> Result<Option<Bot>, sqlx::Error> {
let bot = query_as::<_, Bot>(
pub async fn get(db: &PgPool) -> Result<Option<DbBot>, sqlx::Error> {
let bot = query_as::<_, DbBot>(
"SELECT * FROM bots WHERE id = $1",
)
.bind(BOT_ID)