Delete certain edge

Hi there,

I read through the examples of dgo here: dgo/examples_test.go at master · dgraph-io/dgo · GitHub but I am still not sure how I can delete certain edges.

Say I have a person with two friends. How can I delete just one of them by using the uid of the friend but without removing that friend in general, just cut the relation.

Thanks in advance!
Sebastian

1 Like

{
delete {
person_uid predicate friend_uid
}
}

you can read this more carefully and try it
https://docs.dgraph.io/mutations/#deleting-edges

1 Like

Thanks for the answer. The question though is how do I do this with the go client.

The method DeleteEdges looks like this:
dgo.DeleteEdges(mu, uid, edge)

So there is no way to specify the uid of the edge or do I miss something?

1 Like

Did you found any solution to specify uid of other node ?

The following snippet should delete the edge between first_node and second_node.

    d := map[string]interface{}{
        "uid": uid_of_first_node,
        "edge": map[string]string{
            "uid": uid_of_second_node,
        },
    }
    pb, err = json.Marshal(d)
    if err != nil {
        log.Fatal(err)
    }

    mu = &api.Mutation{
        CommitNow:  true,
        DeleteJson: pb,
    }
2 Likes

Thanks it worked ! :smiley:

Hi
How to delete a specific edge between two node ?!

Below is the answer.