Counting rows in Drizzle ORM
Hi,
I was wondering what the best way to count rows in drizzle is. Thanks for the help!
I was wondering what the best way to count rows in drizzle is. Thanks for the help!
import { sql } from 'drizzle-orm'
import { __YOUR_TABLE__ } from 'schema'
const { count } = await db.select({
count: sql<number>`count(*)`.mapWith(Number)
}).from(__YOUR_TABLE__)