Antony
June 13, 2020, 11:41pm
1
I use .where() a lot to select lists of things - contacts for example.
Often I am saying something like:
repeat contacts.data.where('age_range', input_age_range.value, "==")
So this will show me the contacts in the age range selected by input_age_range
.
However, if input_age_range
has nothing selected, then I want to show contacts of all age ranges… but that doesn’t work this .where type of function.
Is there an easy way around what I am looking to do…?
Best wishes,
Antony.
1 Like
Teodor
June 14, 2020, 5:31am
2
Hi Antony,
The equals operator always expects a value. An empty string (what an empty inputs returns) is also a value.
You can do this like:
input_age_range.value ? contacts.data.where(`age_range`, input_age_range.value, "==") : contacts.data
But it’s much better to filter your data source directly instead of doing it for the repeat.
Antony
June 14, 2020, 6:01pm
3
Thanks Teodor!
Why do you say this?
I have 200 lookups and I read them once and store them in the local storage to save database access, so it seems much easier to filter them with .where()...
I'm a big .where() fan.
I remember Patrick telling me there is another function I can use too... Is that .filter ()?
JonL
June 14, 2020, 6:49pm
4
Not being secure storage would be my number one concern.
Antony
June 14, 2020, 7:29pm
5
But it’s not secure data… just values like “Card Payment”, “Male”, “Female”, “Over 60”, dull stuff like that!
JonL
June 14, 2020, 11:08pm
6
Oh. Then it is ok. If you are storing labels and things like that. As long as it’s not data bound to changing often.