Travis Beck
03/17/2022, 9:18 PMselect
user_id,
sum(coalesce((properties->>'duration')::integer, 0)) as connection_duration
from
events
where
doc_id = '123'
and event = 'disconnect'
group by
user_id
I guess an interface I would want is something like this, but I think prisma would need to know more about the types in the json to be able to give it back to me:
const events = await this.prisma.event.groupBy({
by: ['userId'],
where: {
docId: '123',
event: 'disconnect',
},
_sum: {
'properties->>duration': true
},
})
Are there any reasonable workaround here, or do I just need to use a raw query?andrewicarlson
03/21/2022, 8:00 PMTravis Beck
03/21/2022, 8:26 PMTravis Beck
03/21/2022, 8:26 PM