Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filterBy - OR operator for multiple conditions #204

Open
danitag78 opened this issue Sep 13, 2021 · 0 comments
Open

filterBy - OR operator for multiple conditions #204

danitag78 opened this issue Sep 13, 2021 · 0 comments

Comments

@danitag78
Copy link

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request

I have this json:

"users" : [
{
  "id": 1,
  "email": "[email protected]",
  "admin": false,
  "disabled": true
}, {
  "id": 2,
  "email": "[email protected]",
  "admin": true,
  "disabled": true
}, {
  "id": 3,
  "email": "[email protected]",
  "admin": false,
  "disabled": false
}, {
  "id": 4,
  "email": "[email protected]",
  "admin": false,
  "disabled": false
}, {
  "id": 5,
  "email": "[email protected]",
  "admin": false,
  "disabled": true
}, {
  "id": 6,
  "email": "[email protected]",
  "admin": false,
  "disabled": false
}
]

I need to filter all users with admin: true OR disabled: false
If I use
{{ users | filterBy: ['admin', 'disabled']: [true, false] }}"
it prints all users because condition is admin is true or false OR disabled is true or false.
If I use
{{ users | filterBy: ['admin']: true | filterBy: ['disabled']: false }}"
it prints none because nothing has admin: true AND disabled: false

My expected output is:

"users" : [
{
  "id": 2,
  "email": "[email protected]",
  "admin": true,
  "disabled": true
}, {
  "id": 3,
  "email": "[email protected]",
  "admin": false,
  "disabled": false
}, {
  "id": 4,
  "email": "[email protected]",
  "admin": false,
  "disabled": false
}, {
  "id": 6,
  "email": "[email protected]",
  "admin": false,
  "disabled": false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant