const data = await db
.select({
...getTableColumns(songHistory),
count: sql<number>`cast(count(${songHistory.id}) as int)`,
})
.from(songHistory)
.where(and(eq(songHistory.user_id, user!).if(typeof user === 'number'), gte(songHistory.played_at, from!).if(!!from)))
.groupBy(songHistory.song_title)
.orderBy(desc(songHistory.played_at));
const data = await db
.select({
...getTableColumns(songHistory),
count: sql<number>`cast(count(${songHistory.id}) as int)`,
})
.from(songHistory)
.where(and(eq(songHistory.user_id, user!).if(typeof user === 'number'), gte(songHistory.played_at, from!).if(!!from)))
.groupBy(songHistory.song_title)
.orderBy(desc(songHistory.played_at));