I create entity:
import (
dataBaseAPI "github.com/dgraph-io/dgraph/protos/api"
dataBaseClient "github.com/dgraph-io/dgraph/client"
)
transaction := client.NewTxn() // *dataBaseClient.Dgraph
encodedCategory, err := json.Marshal(category)
if err != nil {
log.Println(err)
return category, ErrCategoryCantBeCreated
}
mutation := &dataBaseAPI.Mutation{
SetJson: encodedCategory,
CommitNow: true,
}
assigned, err := transaction.Mutate(context.Background(), mutation)
category.ID = assigned.Uids["blank-0"]
How I can now delete that entity?
I try this:
transaction := client.NewTxn() // *dataBaseClient.Dgraph
encodedCategory, err := json.Marshal(category)
mutation := dataBaseAPI.Mutation{
DeleteJson: encodedCategory,
CommitNow: true,
}
assigned, err := transaction.Mutate(context.Background(), &mutation)
and I get error:
“Transaction has been aborted. Please retry.”
In previous version i use:
request := dataBaseClient.Req{}
err = request.DeleteObject(&category)
_, err = client.Run(context.Background(), &request)