SQL STRING_AGG function in groupBy
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.9k
- Forks
- 266
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 55
Description
new Query().from({ brand: brandsCollection })
.innerJoin({ productBrand: productBrandsCollection }, ({ productBrand, brand }) => eq(productBrand.brandId, brand.id))
.groupBy(({ productBrand }) => productBrand.productId)
.select(({ brand, productBrand }) => ({
id: productBrand.productId,
brands: stringAgg(brand.name, ", ", { orderBy: { val: productBrand.order, order: "asc" | "desc" }}),
}))
result
[
{ id: 1, brands: "coca, fanta" },
]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Query.groupBy entry point and the stringAgg usage shown in the issue, then trace how grouped selections are translated. Implement the requested ordered STRING_AGG behavior and verify that the example produces one row with the comma-separated brand names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql, typescript
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100