Data API search constraints for list field

Hi Bubblelers!

There’s a limitation on the current Bubble Data API which I am trying to find a workaround, but so far I did not solve it nicely. The use case:

  • Let’s say we have in the databaseFruit.colors, where Fruit is a Thing and colors is a string list field of Fruit containing the possible fruit colors.
  • From our backend I want to retrieve using Bubble Data API the fruits that have at least one color of a color list introduced by the user, let’s say [yellow, red].

In order to create the search constraint, I could do:

[ { "key": "colors", "constraint_type": "contains", "value": "yelow" } 
, { "key": "site", "constraint_type": "contains", "value": "red" } ]

But this search will only return Fruits that have as color yellow AND red.

Another possibility then is to do two calls to Data API, one each with one search constraint I defined above. But this is not scalable when the Thing (in our case the amazing Fruits), has more list fields you want to search for. For example, I want to search fruits that accomplish:

  • Fruits.colors contains ANY of [yellow, red]
  • Fruits.size contains ANY of [small, medium]

Thanks in advance!
Opground team

Create a Backend Workflow exposed as an API that returns a JSON string that you build with Do a search for things : formatted as text

This will give you all the flexibility you need.

Details here:

1 Like