How do I delete a single uid type object using dgo?

using the offical tour data for example, say there are 3 person, Mike, Sam and Jim, for Mike he has friends:[
{
uid: xxx1,
name: Sam
},{
uid: xx2,
name: Jim
}
]
now I want to delete Sam as Mike’s friend, but still keep Jim, I know it’s probably very easy using ratel & GraphQL commands, but how do I do that using dgo? the golang client, many thanks~

It depends

PS: All delete op are Mutations.

If you’re using RDF https://docs.dgraph.io/mutations/#delete
If you’re using JSON https://docs.dgraph.io/mutations/#deleting-edges

thanks, problem solved, I used the code below:

d = Knowledge{
			Uid: srcId,
			RelatedTo: []Knowledge{{
				Uid: targetId,
			}},
		}
	}
	pb, err := json.Marshal(d)
	mu := &api.Mutation{
		CommitNow:  true,
		DeleteJson: pb,
	}

it’s just that the dgo documentation is not so complete

1 Like