How to retrieve newly allocated uids after an add mutation in dgo?

The complete example in the Go docs assigns "_:alice" to Uid but does not explain what "alice" is. Because it’s later used as a key to retrieve the uid value from assigned.Uids I assume it’s arbitrary and meant to be used only for that purpose. The problem is, even though fmt.Println(assigned.Uids) indeed returns a populated map, assigned.Uids["alice"] comes up empty.

Code in Go’s Playground.

The mutation goes through and I can see the new entry in the database.

I have learned "_:<identifier>" is a facet, but I’m still not sure why it doesn’t function as expected.

The example should work. Not sure is failing for you.

Nope. A blank node is a temporary Identifier(that exists only in the context of the respective transaction). Not a facet. Facet is a totally different thing.

My guess is becuase uid is being mashalled to Entry.uid, I think it should just be uid? Dgraph is assiging its own blanknode instead as it cant find one (dg.244385078.11)

1 Like

Thanks! That was it.

1 Like

My bad; I may have wrongfully made the connection because I saw the same notation used in the facets page in the docs. Thanks for clearing it up.