Сара Ревез
Сара Ревез

Reputation: 11

Mutation in the Dgraph database on Golang

Run a mutation
txn.Mutate would run the mutation. It takes in a api.Mutation object, which provides two main ways to set data: JSON and RDF N-Quad. You can choose whichever way is convenient.

To use JSON, use the fields SetJson and DeleteJson, which accept a string representing the nodes to be added or removed respectively (either as a JSON map or a list). To use RDF, use the fields SetNquads and DeleteNquads, which accept a string representing the valid RDF triples (one per line) to added or removed respectively. This protobuf object also contains the Set and Del fields which accept a list of RDF triples that have already been parsed into our internal format. As such, these fields are mainly used internally and users should use the SetNquads and DeleteNquads instead if they are planning on using RDF. We’re going to continue using JSON. You could modify the Go structs parsed from the query, and marshal them back into JSON.

I looked at the client libraries on the official Graph website.
I looked at the solution on github.
I often visit [1]: https://dgraph.io/docs/dql/clients/go/`your text I often visit [2]: https://git.histb.com/dgraph-io/dgo/blob/master/example_set_object_test.goyour text`

I often visit https://blog.knoldus.com/lets-start-exploring-dgraph-mutations-using-json

Upvotes: 1

Views: 39

Answers (0)

Related Questions