I'm trying to query for an entity User in a Google cloud datastore with a key, using Googles developers console query filter. (Google Cloud Developer Console -> Cloud Datastore -> Query)
I fail to decipher the example syntax and am always prompted with the following error message:
Error: Keys for datastore operations must be in the format Key('kind0', 'name0'/id0, 'kind1', 'name1'/id1, ...)
On appengine.google.com I used to query for a specific key on a User like this:
SELECT * FROM User WHERE __key__ = Key('User','XXXXX')
I tried Key('User','XXXXX')
in the Google developers console but was always pointed to the error message above. Any ideas what the correct syntax would be?
Thanks in advance!
Data objects in Google Cloud Datastore are known as entities. An entity has one or more named properties, each of which can have one or more values. Entities of the same kind do not need to have the same properties, and an entity's values for a given property do not all need to be of the same data type.
Select Query by kind. Select a kind from the Kinds menu. If your datastore has multiple namespaces, you will see a Namespace menu that you can choose from as well. Click Filter entities to add a key filter row.
The full key (including the automatically assigned ID) of the entity will be returned when an entity with the incomplete key is saved to Datastore mode: To learn how to install and use the client library for Cloud Datastore, see Cloud Datastore client libraries .
Each entity in a Datastore mode database has a key that uniquely identifies it. The key consists of the following components: An application can fetch an individual entity from the database using the entity's key, or it can retrieve one or more entities by issuing a query based on the entities' keys or property values.
The parser seems to be overly strict. As a workaround, you can add a space between the arguments to Key():
SELECT * FROM User WHERE __key__ = Key('User', 'XXXXX')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With