Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve entity from key value in GQL

I am using Google App Engine's datastore and wants to retrieve an entity whose key value is written as

ID/Name

id=1

Can anyone suggest me a GQL query to view that entity in datastore admin console and also in my python program?

like image 959
niteshb Avatar asked Feb 22 '11 11:02

niteshb


People also ask

What is an entity in Datastore?

Data objects in 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.

What is @KEY in GraphQL?

The @key directive creates the table structures and also generates resolvers that inject composite key values for you during queries and mutations. Using this schema, you can query the primary index to get IN_TRANSIT items created in 2019 for a given order.


1 Answers

From your application use the get_by_id() class method of the Model:

entity = YourModel.get_by_id(1)

From Datastore viewer you should use the KEY function:

SELECT * FROM YourModel WHERE __key__ = KEY('YourModel',1)
like image 162
systempuntoout Avatar answered Oct 19 '22 05:10

systempuntoout