Delete an item if another item in the same document meets a condition #1621
-
I have multiple documents that need to be processed at the same time, for example: metadata:
name: apple
spec
allow:
logins:
- one
- two
- four
---
metadata:
name: pear
spec
allow:
logins:
- three
- four Now, I need to remove Expected output: metadata:
name: apple
spec
allow:
logins:
- one
- two
- four
---
metadata:
name: pear
spec
allow:
logins:
- three To remove Thanks in advance! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! Here's the expression you need to run:
It's very similar to what you had, but it first has To do two conditions, you can use "and", so for instance: select(.metadata.name == "pear" and .some.thing == "dog") |
Beta Was this translation helpful? Give feedback.
Hi!
Here's the expression you need to run:
It's very similar to what you had, but it first has
select(.metadata.name == "pear")
to select only the documents that have metadata.name == "pear" :)To do two conditions, you can use "and", so for instance: select(.metadata.name == "pear" and .some.thing == "dog")