Boolean value is not stored on the node during creation

I am using below Golang code to create a node in the Dgraph. The node gets created but the “markfordeletion” doesn’t reflect in the Dgraph. All the other predicates are available expect the markfordeletion one.

func (s *DGraphRepo) CreateNamespace(ctx context.Context, name string) (id string, err error) {
ns := &Namespace{
		Node: Node{
			Type: "namespace",
			UID:  "_:namespace",
		Name:                 name,
		MarkForDeletion:      false,
		DeleteInitiationTime: "0000-01-01T00:00:00Z",

	txn := s.Dg.NewTxn()
	js, err := json.Marshal(&ns)
	if err != nil {
		return "", err

	assigned, err := txn.Mutate(ctx, &api.Mutation{
		SetJson:   js,
		CommitNow: true,
	if err != nil {
		return "", err
	return assigned.GetUids()["namespace"], nil

My aim is to make sure that when a node is created, it should have the markfordeletion flag and the default value should be false.

Note: The markfordeletion is of type bool in the Golang code and in the Dgraph schema.

Hi Ankit, Here is an example here.
I am pasting the corresponding code segment: Please note how the schema is constructed, and struct fields declared and mapped to json (Married → married).

	op.Schema = `
		age: int .
		married: bool .
		name: string @lang .
		location: string .
		Friends: [uid] .
		type Person {
		type Institution {
		type Institution {
			name: string

	ctx := context.Background()
	err := dg.Alter(ctx, op)
	if err != nil {

	type School struct {
		Uid   string   `json:"uid"`
		Name  string   `json:"name@en,omitempty"`
		DType []string `json:"dgraph.type,omitempty"`

	type Person struct {
		Uid      string    `json:"uid,omitempty"`
		Name     string    `json:"name,omitempty"`
		Age      int       `json:"age,omitempty"`
		Married  bool      `json:"married,omitempty"`
		Friends  []Person  `json:"friends,omitempty"`
		Location string    `json:"location,omitempty"`
		Schools  []*School `json:"schools,omitempty"`
		DType    []string  `json:"dgraph.type,omitempty"`

	// Lets add some data first.
	p := Person{
		Uid:      "_:alice",
		Name:     "Alice",
		Age:      26,
		Married:  true,
		DType:    []string{"Person"},
		Location: "Riley Street",
		Friends: []Person{{
			Name:  "Bob",
			Age:   24,
			DType: []string{"Person"},
		}, {
			Name:  "Charlie",
			Age:   29,
			DType: []string{"Person"},
		Schools: []*School{&School{
			Name:  "Crown Public School",
			DType: []string{"Institution"},

Could you please check your code against this example and see if it helps?

Thanks for the response. Here is my data structure for namespace

type Namespace struct {
	Name                 string `json:"name,omitempty"`
	MarkForDeletion      bool   `json:"markfordeletion,omitempty"`
	DeleteInitiationTime string `json:"deleteinitiationtime,omitempty"`

	Owns []*Object `json:"owns,omitempty"`

	AccessedBy         []Account `json:""`
	AccessToPermission string    `json:"|permission,omitempty"`

it is similar to your example but still I don’t get the value in Dgraph

Could you please share your schema as well? Also it would help if you could log and share the json you are creating for mutations.