How to update a predicate and node using go client

Hi @teja,

so I want to get the schema and alter the name to person_name using go client

I wrote a simple go program which change the “name” to “person_name” for the schema that you provided, similarly you can do it for company_name or in general for any predicate.


import (
	"context"
	"log"
	"google.golang.org/grpc"
	"github.com/dgraph-io/dgo/v200"
	"github.com/dgraph-io/dgo/v200/protos/api"
)

func main() {
	conn, err := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
	if err != nil {
		log.Fatal("While trying to dial gRPC")
	}

	dc := dgo.NewDgraphClient(api.NewDgraphClient(conn))
	ctx := context.Background()

	q := `
		query {
	  		user as var(func: type(Person)){
	  			n as name
	  		}
	  	}`

	mu := &api.Mutation{
  		SetNquads: []byte(`uid(user) <person_name>  val(n) .`),
  		DelNquads: []byte(`uid(user) <name> * .`),
	}

	req := &api.Request{
	  Query: q,
	  Mutations: []*api.Mutation{mu},
	  CommitNow:true,
	}
	if _, err := dc.NewTxn().Do(ctx, req); err != nil {
  		log.Fatal(err)
	}
}