Forum Discussion

Akenefick's avatar
Akenefick
Genius
3 years ago

Get A Topic and ALL Replies

Is there a way to get a Topic and all its replies not just the direct 1st level replies. For example if I do this query with a replies subquery I only get replies to the topic, not replies to replie...
  • MattV's avatar
    3 years ago

    The hard part will be guaranteeing the messages are grouped by topic. The API doesn't actually guarantee any particular sort order without the ORDER BY clause (and there is no ORDER BY topic).

    But, your best luck is probably to get the topic id's you need from a board (select id from messages where board.id = 'foo' and depth=0).

    Collect those ID's in a string, formatted like '1','2','3','4'

    Then make another rest call SELECT id,subject FROM messages WHERE topic.id IN (topic_ids_collected)

    That might be the closest you get, but again, order isn't guaranteed. You may just have to sort through it in Freemarker, which isn't performant either.