datastore-to-sql icon indicating copy to clipboard operation
datastore-to-sql copied to clipboard

Get Key/ID from entity

Open sanbornm opened this issue 8 years ago • 3 comments

Is there a way to get the key as int/string for the entity?

sanbornm avatar Aug 12 '17 17:08 sanbornm

I'm curious to know about this as well.

robksawyer avatar Apr 29 '19 06:04 robksawyer

@sromku Do you know how we might do this?

wrunk avatar Feb 19 '20 00:02 wrunk

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())

wrunk avatar Feb 19 '20 00:02 wrunk