【发布时间】:2018-09-02 23:54:45
【问题描述】:
是否可以使用github.com/dgraph-io/dgo/protos/api 中的api.NQuad 从给定节点中删除与谓词匹配的所有边?
我正在尝试实现相当于delete {0x1234 <test.likes> * }
func TestDeleteQuad(t *testing.T) {
subject := "0x01"
ctx := context.TODO()
d, err := grpc.Dial(testEndpoint, grpc.WithInsecure())
if err != nil {
panic(err)
}
client := dgo.NewDgraphClient(api.NewDgraphClient(d))
txn := client.NewTxn()
defer txn.Discard(ctx)
if _, err := txn.Mutate(ctx, &api.Mutation{Del: []*api.NQuad{
&api.NQuad{
Subject: subject,
Predicate: "test.likes",
ObjectId: "*",
ObjectValue: nil,
},
}}); nil != err {
panic(err)
}
err = txn.Commit(ctx)
assert.NoError(t, err)
}
我尝试使用 "*" "" x.Star 作为 ObjectId,但这些解决方案都不起作用
【问题讨论】:
标签: go dgraph dgraph-dgo