This question is locked. New answers and comments are not allowed.
Hi,
Sorry if this has been asked before, I did try searching first but didn't find anything.
I am creating a filter for a list screen. The contains a number of fields, currently 7, that the user may or may not assign a value too. For each filter field given a value, the data should be filtered to only show the matching records.
The app is NativeScript Angular . I tried the code below but only one where() is respected. I need to chain more than one together as an AND. I see in the docs the syntax for this is to do filter.where().eq("Field1", "Value1").eq("Field2", "Value2")... but how do I best do this in the case where I need Field 1, 3 and 5 without creating very verbose code to cover every combination of the 7.
getFilter () {
let filter =
this
._provider.newQuery;
if
(
this
._priorityFilter) {
filter.where().eq(
"Priority"
,
this
._priorityFilter);
}
if
(
this
._jobTypeFilter) {
filter.where().eq(
"JobType"
,
this
._jobTypeFilter);
}
if
(
this
._statusFilter) {
filter.where().eq(
"Status"
,
this
._statusFilter);
}
if
(
this
._referredToFilter) {
filter.where().eq(
"ReferredTo"
,
this
._referredToFilter);
}
return
filter;
}
Thanks in advance,
David