Addon Database Query is returning empty results

Options

Hi there, I've set up an addon to query my video table, as you can see in the image below. The query is working, but it is returning the elements that aren't included as [] in the response. How can I fix this? I've tried changing the output from list to single, but it gave me the same result.


https://www.loom.com/share/4b6977e4c0bf40a8a89143caf58b443a


Tagged:

Best Answer

Answers

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hi @jack this is because your Addon is mapped to the id of your collection table and the input value of the platform. Addons aren't designed to remove entries from the parent query (your collections.video_id field). You could apply a filter_empty to that field but I'm wondering if there's another way to think about how you're getting the data?

  • jack
    jack Member
    Options

    Hi @Michael Udinski thank you for your time and response. My apologies, but I'm totally stumped with this one. I've just tried changing the data to an inner join rather than a query, but no luck there. I have also been trying to think of other ways I could access the data.

    I need the video id's to be within the collection object as is above - and separating that out is the only other way I can think to solve this problem (noted that I am very inexperienced with XANO).

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    What is the goal for the final outcome of the response to look like?

  • jack
    jack Member
    Options

    @Michael Udinski

    So currently, the video addon is returning 4 video items for the filter I've got set up, but three of those are just empty [0] items. I'd like it to return only video items that match the query, so in this case, it would return 1 video item.

    You can see below that, if the video filter doesn't match any videos, it still returns 4 items, but again, they're all empty. I'd like this to return nothing rather than these 4 empty items



  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hi @jack in this case, I would think about going about it in the reverse: I would query your videos table based on the two parameters. Then if you need to include the user info, I would use an Addon to pull the user details alongside the video record you want.

  • jack
    jack Member
    Options

    @Michael Udinski Hey Michael, I've implemented this solution and recorded a quick loom explaining the problem that I face with it https://www.loom.com/share/cbde7b3dd9c5491aacc8656f52497994

    TLDW: Essentially I need the data structure to remain the same as it is in the initial call, as this video fetch is just acting as a filter for the existing videos on the page, is there any other way to achieve that?

    I really appreciate you taking the time to help me with this issue

  • jack
    jack Member
    Options

    @Michael Udinski You have made my morning! Thank you so much, this is exactly what I was looking for. Again, thank you for your time and patience. Have a good weekend.