Expression to aggregate
Option to specify whether to wrap with COALESCE
SQLBuilderConditionExpressionPort
Create JSON_ARRAYAGG expression.
import { createBuilder, json_array_aggregate, json_object } from 'coral-sql'
const [sql, bindings] = createBuilder()
.from('orders')
.column(
json_array_aggregate(
json_object({ id: 'id', total: 'total_amount' }),
'with_coalesce'
)
)
.toSQL()
// sql: SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT('id', `id`, 'total', `total_amount`)), '[]') FROM `orders`
Expression to aggregate
SQLBuilderConditionExpressionPort
Create JSON_ARRAYAGG expression.