Query all records

Options

Hello everyone, I hope you are well. I have an order database table with a line_items field which is a list of objects. These objects contain the field product_id. I then want to query all order records where line_items has an item with product_id=xxx.
How can I do this? I haven't found any filters to help me (most seem to be restricted for query operations).

Best Answer

Answers

  • ribotmaximus
    ribotmaximus Member
    Options

    I found that a custom query using the following syntax might help:

    WHERE input:product_id IN databaseName.line_items

    line_items being a field which can accommodate a list of integers (rather than a list of JSON objects as you might have at the moment).

    Hope that helps

  • Leo Med
    Leo Med Member
    Options

    I thought about that, but it doesn't make sense to me for the line_items to be a list of integers. But if that's the only way to do it, I'll create a new field and migrate all the necessary data to that field.

    Any other solution would be welcome. Thanks tho! @ribotmaximus

  • Leo Med
    Leo Med Member
    Options

    🎉 That's it, that's wonderfull @Chris Coleman , thank you a lot🙏.

  • Leo Med
    Leo Med Member
    Options

    Hey @Chris Coleman , I'm back, with another one. Is there any we can go deeper in joining tables ?

    Like I also want to query my table based on a particular store the product is sold from.

    Is it directly possible ?