tledoux
tledoux
Explore posts from servers
DTDrizzle Team
Created by tledoux on 3/12/2024 in #help
Astro DB: using count() and countDistinct()?
I was using a Postgres database before, and there I could use the count() and countDistinct() functions from Drizzle. I now switched to Astro DB, but I noticed the count() and countDistinct() functions aren't exported from astro:db and when using the functions from Drizzle directly, I get all kinds of TS errors. This is the query I'd like to do:
const viewsQuery = db
.select({
url: PageView.url,
pageviews: count(),
})
.from(PageView)
.where(and(...conditions))
.limit(pageSize)
.offset(offset)
.groupBy(PageView.url)
.orderBy(desc(count()));
const viewsQuery = db
.select({
url: PageView.url,
pageviews: count(),
})
.from(PageView)
.where(and(...conditions))
.limit(pageSize)
.offset(offset)
.groupBy(PageView.url)
.orderBy(desc(count()));
Any help is appreciated! I'm guessing it has something to do with how SQLite works, but I can't find any good docs on this.
1 replies