Files
test/server/api/todos/stats.ts
AlucardDev 7d4ff5962c
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
first commit
2026-08-28 23:32:07 +03:00

13 lines
330 B
TypeScript

import { db, schema } from 'hub:db'
import { sql } from 'drizzle-orm'
export default eventHandler(async () => {
// Count the total number of todos
const result = await db.select({
todos: sql<number>`count(*)`,
users: sql<number>`count(distinct(${schema.todos.userId}))`
}).from(schema.todos)
return result[0]
})