# How can I delete an parent node based on a child condition?

**URL:** <https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098>\
**Category:** General\
**Tags:** entity-transformers\
**Created:** [April 25, 2024, 1:42pm UTC](https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098 "2024-04-25T13:42:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rickvzanden](https://forum.alumio.com/user_avatar/forum.alumio.com/rickvzanden/32/247_2.png) [@Rickvzanden](https://forum.alumio.com/u/Rickvzanden)\
**Post date:** [April 25, 2024, 1:42pm UTC](https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098/1 "2024-04-25T13:42:22Z")

</div>

Hi all,

I’m having struggles realizing something in Alumio and I am hoping someone has a handy tip for this.

I am trying to remove a parent node based on a child condition.  
Here is my example data:

```auto
"data" : [
  0:{
    "check" : "good",
    "data" : "more data"
  }
  1:{
    "check" : "bad",
    "data" : "more data"
  }
  2:{
    "check" : "good",
    "data" : "more data"
  }
]

```

I want to delete node with where the value of check == bad.  
So in this case node 1 should be removed.

An PHP equivalent would be:

```auto
<?php
	$array = [
		0 => [
			"check" => "good",
			"data" => "more data"
		],
		1 => [
			"check" => "bad",
			"data" => "more data"
		],
		2 => [
			"check" => "good",
			"data" => "more data"
		]
	];
	
	foreach($array as $key => $value){
		if($value['check'] == "bad"){
			unset($array[$key]);
		}
	}
	
	print_r($array);
?>

```

Results:

```auto
Array
(
    [0] => Array
        (
            [check] => good
            [data] => more data
        )

    [2] => Array
        (
            [check] => good
            [data] => more data
        )

)

```

It looks so trivial to do, but I cannot seem to find a way to do this in Alumio.  
I must be overlooking something that can do this trick.  
Anyone that has pointers in this case?

---

<div class="post-metadata">

**Author:** ![mko](https://forum.alumio.com/user_avatar/forum.alumio.com/mko/32/1735_2.png) [@mko](https://forum.alumio.com/u/mko)\
**Post date:** [April 25, 2024, 2:00pm UTC](https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098/2 "2024-04-25T14:00:11Z")

</div>

Hi Rick!

Just played around with this and i think i have a solution for you.

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/3/3f423ed143c93940135415acf7c3edbc0e19318c.png)

Output looks like this.  
You can just filter “data” so you are left with “newData”

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/9/98259783b979d0e3256b27047027e85e8f1f2060.png)

I hope this helps!

---

<div class="post-metadata">

**Author:** ![Rickvzanden](https://forum.alumio.com/user_avatar/forum.alumio.com/rickvzanden/32/247_2.png) [@Rickvzanden](https://forum.alumio.com/u/Rickvzanden)\
**Post date:** [April 25, 2024, 2:19pm UTC](https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098/3 "2024-04-25T14:19:08Z")

</div>

Hi mko!

Thanks for the quick response, your solution look great but I do not like to compromise on the explicitly of the check.  
In this case if another key happens to contain the work “bad” I would filter that out as well, which I do not want to happen.

But great way of thinking, I was trying things with the filter options forgetting that copy/move using a pattern is available in these cases as well.

---

<div class="post-metadata">

**Author:** ![mko](https://forum.alumio.com/user_avatar/forum.alumio.com/mko/32/1735_2.png) [@mko](https://forum.alumio.com/u/mko)\
**Post date:** [April 25, 2024, 2:26pm UTC](https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098/4 "2024-04-25T14:26:21Z")

</div>

Ah yes!

That makes sense, then i think this will do the trick

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/7/73ec51636c0210d055182df44dcb78a86a9d6bb9.png)

Output:

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/7/7c045435b8651dedcb9d4b2325796bf5ade86999.png)

---

<div class="post-metadata">

**Author:** ![Rickvzanden](https://forum.alumio.com/user_avatar/forum.alumio.com/rickvzanden/32/247_2.png) [@Rickvzanden](https://forum.alumio.com/u/Rickvzanden)\
**Post date:** [April 25, 2024, 2:32pm UTC](https://forum.alumio.com/t/how-can-i-delete-an-parent-node-based-on-a-child-condition/1098/5 "2024-04-25T14:32:40Z")

</div>

Ah yes, just what I needed indeed.  
Thank you for the solution!

I should really try to do more with JMESPath, I keep forgetting that this is an option within Alumio as well.
