kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.82k stars 275 forks source link

eb.fn.jsonAgg(...).orderBy is not a function #1215

Closed tapz closed 1 week ago

tapz commented 1 week ago

When I try to sort a json_agg array I get this error:

eb.fn.jsonAgg(...).orderBy is not a function

eb.selectFrom('my_media as lsm')
  .where('sm.my_location_id', '=', eb.ref('sl.id'))
  .select(
    eb.fn.jsonAgg(
      jsonBuildObject({
        ...
    })
    ).orderBy('lsm.order_number')
  )
SELECT json_agg(
  jsonb_build_object(
    'id', lsm.id,
    'type', lsm.media_type,
    'url', lsm.media_url,
    'description', lsm.media_description
  ) ORDER BY lsm.order_number ASC
)
FROM my_media lsm 
WHERE 
  lsm.my_location_id = sl.id
igalklebanov commented 1 week ago

Hey 👋

This is a yet-to-released feature.