WorkshopTasker/server/api/clients/count.get.ts

13 lines
366 B
TypeScript
Raw Normal View History

2023-05-11 06:03:22 +02:00
/* global defineEventHandler, createError */
import { database, data } from "~/server/utils/database";
export default defineEventHandler(async (e) => {
const [[data]] = await database.query(
"SELECT COUNT(*) as `count` FROM `clients`",
) as unknown as data<{count: number}>;
if (!data) throw createError("Database returned no rows");
return data;
});