Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Datastore - What is the correct syntax to filter by Key in the Developer Console?

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)

enter image description here

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!

like image 232
lluft Avatar asked Jun 25 '14 19:06

lluft


People also ask

What is an entity in Google Cloud Datastore?

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.

How do I add a key filter to a datastore?

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.

What happens when an incomplete key is saved to datastore?

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 .

What is a datastore key?

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.


1 Answers

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')
like image 113
Ed Davisson Avatar answered Oct 20 '22 05:10

Ed Davisson