Jorge Guberte
Jorge Guberte

Reputation: 11064

Which one is better to use when fetching from the datastore: key or id?

My mind is still impregnated with SQL thoughts... i'm used to retrieve from the database using the id as the main key, but in App Engine i'm unsure whether i should favor one over the other. What is recommended?

Upvotes: 1

Views: 119

Answers (1)

Robert Kluin
Robert Kluin

Reputation: 8292

If you are talking about the App Engine generated id, it is effectively the same as using the key. A key is just an encoded version of the kind, namespace, and id or name.

Model.get_by_id simply converts the id to a key before fetching the entity.

Upvotes: 2

Related Questions