[Question] How do we query to filter based on 2+ array items on the front-end?
See original GitHub issueConsidering a simple use case where I have the following records of Books loaded into Vuex store of the Books Service. Each book contains a list of tags
.
Book 1 Coding
Javascript
Education
Book 2 Javascript
Coding
FeathersJS
Book 3 Javascript
FeathersVuex
FeathersJS
Coding
How do I query for books that have Coding
& FeathersJS
tags?
query: {
tag: {
$in: ['Coding', 'FeathersJS']
}
}
This gives results for the books that have the Coding
or FeathersJS
tags as expected. (Book1, Book2, Book3)
I am not sure how to query for books that contain both the tags.
On the backend with mongoose, I can use the $all
operator to achieve this - but how do I go about doing this on the frontend?
Currently, my workaround was to have a custom getter on the service which executes the $in
query and then loops through the results to find the items where both tags are present.
Is there a better way to do this? Did I miss something w.r.t querying?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
I would really appreciate a PR if this will benefit users. I’m a bit strapped for time for the next week or so, but I can review PRs and do releases. Thanks guys!
@kshitizshankar thanks for the details in your last comment. I was able to make the PR and have published it as
feathers-vuex@3.12.1
. Please reopen this issue if you still find that there’s a problem.