How to use WHERE after SPLIT

Dear Wapplers,

I need a help with WHERE operators for arrays.
I have a variable test which contains: test,apple,apple juice
I have another variable list with test.split(',')
And now list is an array.
I would like to return all entries where value contains apple, but question is - Data Binging - what Property should I type? Selection is unavailable.

.where('$value', 'contains', 'apple') - won’t work
.where($value, 'contains', 'apple') - won’t work
.where(value, 'contains', 'apple') - won’t work

Server model: NodeJS

For server side WHERE, the parameters are as below:

.where('column_name_in_array', 'operator', 'value_to_compare')

The first example that you have posted should work… the only problem is that there is no CONTAINS operator for where.

The main problem is actually that if you are splitting a string, it results in a string array, and not an object array.
WHERE formatter can be used only on object arrays.
For string array, you can only do ddd.contains('apple'), which will return true/false.

I’ve tried different way around.
I’m splitting string as an example as an output to my “frontend” and then I do: <p>{{serverconnect1.data.output.where('$value', 'apple', 'contains')}}</p> the only problem is output of such operation is [object Object],[object Object] (which is 2 object with apple and apple juice) and I can’t figure it out how to display it value.

I’ve tried {{serverconnect1.data.output.where('$value', 'apple', 'contains').values()}}, {{serverconnect1.data.output.where('$value', 'apple', 'contains').$value}}

Oh. This is on client side. What I wrote was for server side.
Also, did not know where could work on a string array.

You should use a repeat children, and set its expression as serverconnect1.data.output.where('$value', 'apple', 'contains').
Then inside this, just print {{$value}} to print the value part.

I follow your idea, but unfortunately it still return two [object Object] [object Object]

But If I change inside to {{$value.values()}} it returns a,p,p,l,e,0,0,apple and a,p,p,l,e, ,j,u,i,c,e,1,1,apple juice

The correct expression inside repeat would be {{$value.$value}}
And {{serverconnect1.data.output.where('$value', 'apple', 'contains').values('$value')}} if you want to display it without repeat.
Thank you very much @sid for helping me with this tricky case!

These new expressions are tricky! Did not know where could work with string array, and when it does, the binding becomes {{$value.$value}}. :laughing:
Thank you for sharing the final outcome. Haven’t had a use case like this yet, but maybe in future it will help.

1 Like