drizzle-team / drizzle-team/drizzle-orm
[FEATURE]:Port Kysely jsonArrayFrom to Drizzle
Open
db/mysql
db/postgres
enhancement
qb/crud
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
I am trying to port this functionality from kysley to Drizzle, but I am struggling getting the typing to work.
Kysely function:
```
export function jsonArrayFrom(
expr: Expression
): RawBuilder[]> {
return sql`(select coalesce(json_agg(agg), '[]') from ${expr} as agg)`
}
```
Drizzle function:
```
export function jsonArrayFrom(subquery) {
return sql`(select coalesce(json_agg(agg), '[]') from ${subquery} as agg)`;
}
```
Usage example:
```
ctx.db.select({
id: plan,
displayName: plan.displayName,
deductibles: jsonArrayFrom(ctx.db.select().from(deductible)),
}).from(plan)
```
Contributor guide
Assessment
This issue has not been assessed yet.