Let's say that a dstore
has records with First name, Last name and Age. Now, I want records with First name as "Name1" OR Age= 25. How can I do this in dstore
?
If I do,
recordStore.filter({name: 'Name1'}, {age: 25});
then it returns the records having name as "Name1" AND Age=25.
Another question, in the records of my dstore
, there is an array also (comprising of colours). I want to filter the results based on the colours selected by the user. The problem that I face is that dstore.filter()
checks for the complete matching of the value, but I want to retain the record if even one value in the array matches with the selected value. How to do this?
Finally figured it out!
Filter
objects can be created from thestore
and then used as arguments tofilter
method of thestore
.For doing OR/ AND of two queries:
To match one value from an array:
For more, see here.
You will need to extend the filter function like this: