datastore-to-sql
datastore-to-sql copied to clipboard
Get Key/ID from entity
Is there a way to get the key as int/string for the entity?
I'm curious to know about this as well.
@sromku Do you know how we might do this?
I just changed the main Load() function a bit to pass the string key through. Poking around with the pb object in there should yield your particular key type:
...
// Hacktacular get the key!!
key := pb.GetKey()
path := key.GetPath()
ele := path.GetElement()[0]
fmt.Printf("%s, %T %s \n", ele, ele, ele.GetName())
LoadEntity(dst, pb)
// In my case ele.GetName() had the datastore key i was interested in
onResult(dst, ele.GetName())