Query transformer

Hi All,

already sorry for my question, I am not a developer but I love to learn stuff and I am a bit stuck now. I have added my restapi to my query and that's working fine. My api is very limited in filtering and I want to add a filter through the transformer field. My filter would be the following

data --> category --> label --> "text value"

From the documentation I see the following but really not sure how to use that for my filter

Any help would be much appreciated

const data = {{query1.data}}

return data.filter(f => f.fieldToFilterBy.toLowerCase().indexOf(textInput3.value.toLowerCase()) !== -1 )

Schermafbeelding 2022-11-23 165223

Since I can't test this, I'm not confident, but I think it would be something like this:

const data = {{query1.data}}

return data.filter(f => f.category[0].label.toLowerCase().indexOf({{ textInput3.value.toLowerCase() }}) !== -1 )

Assuming there is only one category per item.

thanks a lot, did some more testing and figured a few error out, but now I am stuck with

data.filter is not a function

I'm not exactly sure why you're getting that error. However, it looks like you're trying to put the transformer on the query itself, and I don't think that will work.

I would recommend create the transfomer separately.

Here is a an app you can import that works for me.
test3.json (11.4 KB)

Of course, this is setup to filter against my own database, so the query and transformer would need to be updated to reference your specific data.

thanks for that, I will give it a try, and I did. Same issue :slight_smile:

  • message:"data.filter is not a function"

maybe this just doesn't work when using a rest api

Works fine for me with a rest api.

Working example:
filter.json (12.6 KB)

Finally got some time to check it again. I got it to work now with some basic fields, thanks for that. Main issue I now still have is that there is another subset of data in the same query which I am not able to use when I try to use the same code. Anybody know how I can do this?

Working OK

How can I get a filter on this data?

Hey @Sander! Happy to help here. How are you trying to filter with that value that you circled?

data.data.filter(obj => obj.category[0].value == 2834)

would let you match the rows that have a value of 2834

Also, does every category array only ever have 1 object, or might there be multiple?

Wauw, you are good :slight_smile: finally I got something that works haha.

Amazing!!! So glad to hear it :blush: