i have this struct for store a program.
type StoreProgram struct {
Uid string `json:"uid,omitempty"`
CreatorId string `json:"Program.creatorId,omitempty"`
OwnerId string `json:"Program.ownerId,omitempty"`
Title string `json:"Program.title,omitempty"`
Categories []string `json:"Program.categories,omitempty"`
Publish bool `json:"Program.publish,omitempty"`
CreatedAt time.Time `json:"Program.createdAt,omitempty"`
UpdatedAt time.Time `json:"Program.updatedAt,omitempty"`
Channel StoreChannel `json:"Program.channel,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
}
my StoreChannel schema is :
type StoreChannel struct {
Uid string `json:"uid,omitempty"`
CreatorId string `json:"Channel.creatorId,omitempty"`
OwnerId string `json:"Channel.ownerId,omitempty"`
Title string `json:"Channel.title,omitempty"`
Description string `json:"Channel.description,omitempty"`
Publish bool `json:"Channel.publish,omitempty"`
CreatedAt time.Time `json:"Channel.createdAt,omitempty"`
UpdatedAt time.Time `json:"Channel.updatedAt,omitempty"`
Programs []Program `json:"Channel.programs,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
}
my problem is when i create a program with follow code my program create a channel while channel is empty
conn := db.(dgo.Dgraph)
program := StoreProgram{
Uid: programObj.Uid,
CreatorId: programObj.CreatorId,
OwnerId: programObj.OwnerId,
Title: programObj.Title,
Description: programObj.Description,
Categories: programObj.Categories,
Publish: false,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DType: []string{"Program"},
}
mu := &api.Mutation{
CommitNow: true,
}
pb, err := json.Marshal(program)
if err != nil {
log.Fatal(err)
}
mu.SetJson = pb
_, err = conn.NewTxn().Mutate(c, mu)
fmt.Println(mu)
if err != nil {
log.Fatal(err)
}
return nil
Does anyone have an idea how I should solve this issue ?