Delete certain edge


(Sebastian Walter) #1

Hi there,

I read through the examples of dgo here: https://github.com/dgraph-io/dgo/blob/master/examples_test.go 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


(Jerry You) #2

{
delete {
person_uid predicate friend_uid
}
}

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


(Sebastian Walter) #3

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?


(Umer) #4

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


(Prashant Shahi) #5

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,
    }

(Umer) #6

Thanks it worked ! :smiley:


(mehrdad mohammadiyan ) #7

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


(Michel Conrado) #8

Below is the answer.