Checkpoint: Correction de l'erreur "No procedure found on path formateurs.create" en ajoutant le routeur formateurs complet avec les procédures list, getById, create, update et delete, ainsi que les fonctions de base de données correspondantes
This commit is contained in:
45
server/db.ts
45
server/db.ts
@@ -23,7 +23,10 @@ import {
|
||||
Apprenant,
|
||||
Formation,
|
||||
EmailTemplate,
|
||||
InsertEmailTemplate
|
||||
InsertEmailTemplate,
|
||||
formateurs,
|
||||
InsertFormateur,
|
||||
Formateur
|
||||
} from "../drizzle/schema";
|
||||
import { ENV } from './_core/env';
|
||||
|
||||
@@ -674,3 +677,43 @@ export async function updateEmailConfig(id: number, data: Partial<InsertEmailCon
|
||||
})
|
||||
.where(eq(emailConfig.id, id));
|
||||
}
|
||||
|
||||
|
||||
// ==================== FORMATEURS ====================
|
||||
|
||||
export async function createFormateur(data: InsertFormateur) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Database not available");
|
||||
|
||||
const result = await db.insert(formateurs).values(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getFormateurs() {
|
||||
const db = await getDb();
|
||||
if (!db) return [];
|
||||
|
||||
return await db.select().from(formateurs);
|
||||
}
|
||||
|
||||
export async function getFormateurById(id: number): Promise<Formateur | undefined> {
|
||||
const db = await getDb();
|
||||
if (!db) return undefined;
|
||||
|
||||
const result = await db.select().from(formateurs).where(eq(formateurs.id, id)).limit(1);
|
||||
return result.length > 0 ? result[0] : undefined;
|
||||
}
|
||||
|
||||
export async function updateFormateur(id: number, data: Partial<InsertFormateur>) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Database not available");
|
||||
|
||||
await db.update(formateurs).set(data).where(eq(formateurs.id, id));
|
||||
}
|
||||
|
||||
export async function deleteFormateur(id: number) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Database not available");
|
||||
|
||||
await db.delete(formateurs).where(eq(formateurs.id, id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user