Database queries - topics

  • I've added a couple of hooks which add a new node on to topic data, which is either true or false depending on other some logic I've written.

        "hook": "filter:topic.create",
        "method": "createTopic"
        "hook": "filter:topic.edit",
        "method": "editTopic"

    When topics are loaded onto a category page, I want to return only those which have the new node === true

    In src > categories > topics.js, there's a function Categories.buildTopicsSortedSet. In it, topics can be ordered by 'most_posts' like so set = 'cid:' + cid + ':tids:posts'

    Is there a way that I can manipulate this to look for my new node condition? (I need to be able to fetch these topics at this point in the query because of pagination. If I fetch 5 topics at a time and filter them after this point, I could end up with 0 matched topics. I always want to fetch the maximum number of matching topics).


    Edit: I should also mention I'm using a Postgres DB

  • Admin Staff

    Take a look at, you either have to create and manage new sorted sets for topics that have node === true, or just add a tag to topics that have node === true, then you can display the category pages with `/category/1/my-category?tag=<my_tag>

  • Thanks @baris, the latter approach works so I'll go with that 🙂

Suggested Topics

| |