import deleteDbEntry from "../../backend/db/deleteDbEntry"; import varDatabaseDbHandler from "../../backend/varDatabaseDbHandler"; type Param = { dbFullName: string; deletedUserId: string | number; useLocal?: boolean; }; type Return = { success: boolean; result?: any; msg?: string }; /** * # Update API User Function */ export default async function apiDeleteUser({ dbFullName, deletedUserId, useLocal, }: Param): Promise { const existingUserQuery = `SELECT * FROM users WHERE id = ?`; const existingUserValues = [deletedUserId]; const existingUser = await varDatabaseDbHandler({ queryString: existingUserQuery, queryValuesArray: existingUserValues, database: dbFullName, useLocal, }); if (!existingUser?.[0]) { return { success: false, msg: "User not found", }; } const deleteUser = await deleteDbEntry({ dbContext: "Dsql User", paradigm: "Full Access", dbFullName, tableName: "users", identifierColumnName: "id", identifierValue: deletedUserId, useLocal, }); return { success: true, result: deleteUser, }; }