Search code examples
google-app-enginegoogle-cloud-platformgoogle-cloud-datastore

Key.toUrlSafe() - how to get entity by urlSafeKey?


com.google.cloud.datastore.Key

has a toUrlSafe method()

how do I recreate the key from this url safe string? Key has only methods like getParent, getId, getName...

I tried with

com.google.cloud.datastore.Datastore

key factory, but I haven't found any methods that create key from url safe string.


Solution

  • It looks like you are using Java. In Java, the Key class has a static method fromUrlSafe (https://googleapis.dev/java/google-cloud-clients/latest/com/google/cloud/datastore/Key.html#fromUrlSafe-java.lang.String-).