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.
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 {
name
age
married
Friends
}
type Institution {
name
}
type Institution {
name: string
}
`
ctx := context.Background()
err := dg.Alter(ctx, op)
if err != nil {
log.Fatal(err)
}
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?