Home App Docs Blog Github

Content API - How to query a list's attributes

In the Data content models, it’s possible to set up a model that can have a list attribute, that refers to other models.

I was wondering how to query for this in the content API?

I know I can query for direct attributes of the model, by adding the URL param &query.data.active=true for example.

In my example, I have a model that has a List referring to another model, so I assume the query should be something like query.data.meatTypes.[].meatType.value.data.name=Beef, but I’m not sure what operator to put in the middle. I tried [] and $ne, but it doesn’t appear to have any effect.

So far I found I am able to do this on a List’s model’s id, eg. I can do

query.data.meatTypes.meatType.id=<id>

This suggests there is no need for a specific operator when running into an array.

However, I am unable to filter on any of the values of the reference model. e.g. query.data.meat_types.meatType.value.data.name=Beef still doesn’t work

Is this a platform limitation? Could this be made to be possible?

Hey @jballo You can query the reference id, but the reference itself is not loaded, so you’re not able to query through the references. We would recommend not using a list of references for this field, and instead use a list of strings and querying for the value.