Counting rows in Drizzle ORM

Hi,

I was wondering what the best way to count rows in drizzle is. Thanks for the help!
Solution
import { sql } from 'drizzle-orm'
import { __YOUR_TABLE__ } from 'schema'
 
const { count } = await db.select({
    count: sql<number>`count(*)`.mapWith(Number) 
}).from(__YOUR_TABLE__)
Was this page helpful?