Skip to main content
Question

Cognite Data Fusion Python SDK - how to delete edges that lead to a node with a specific target_edge_id?


I am using the [Cognite Data Fusion Python SDK](https://cognite-sdk-python.readthedocs-hosted.com/en/latest/data_modeling.html#delete-instances). 

While deleting a node, e.g....

```python
client.data_modeling.instances.delete(NodeId(space='some-space', external_id=deleted_node_id))
```

I want to also delete the edge(s) from the parent in order to avoid leaving orphan edges in the database.

**Problem**: how can I look-up such edges? 

I know how to get all edges (and then filter by the `end_node` attribute), but that would be very inefficient:

```python
edges = client.data_modeling.instances.list(
    instance_type="edge", limit=-1)
```

How could I construct the `Filter` for the `end_node` (to match the `deleted_node_id`) and ideally the `type` (to equal `Child` type)? E.g.


```python
edges = client.data_modeling.instances.list(
    instance_type="edge", 
    filter=And(Equal(???), Equal(???)),
    limit=-1)
```

Because then I could just delete all those edges with one `client.data_modeling.instances.delete(edges)` call.

Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings