Skip to content

Update does not add uid to api.Assigned uid map, but does update in database #6

@nikkon226

Description

@nikkon226

When I try to update, the update does not add the uid to the api.Assigned map, but does update the database.

// type model {
//     UID string `json:"uid,omitempty"`
//     Name string `json:"name,omitempty"`
// }
input := &model{
     UID: "0x1234",
        Name: "Test",
}
inputJson, err := json.Marshal(input)
if err != nil {
	log.Println("error handing json marshal")
	return nil
}
mu := &api.Mutation{
	SetJson:   inputJson,
	CommitNow: true,
}
log.Println("mutation object:", mu)
 // mutation object: set_json:"{\"uid\":\"0x1234\",\"name\":\"Test\"}" commit_now:true

txn := o.graph.NewTxn()
defer txn.Discard(ctx)
assigned, err := txn.Mutate(ctx, mu)
if err != nil {
	log.Println("error handing mutation for update")
	return nil
}
log.Println("assigned:", assigned.Uids)
// assigned: map[]
// the database has changed the name to "Test"
if _, ok := assigned.GetUids()[input.ID]; !ok {
	log.Println("update unsuccessful")
	return nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions