appengine datastore id and key

In Google appengine datastore, Is it possible to define both id and key_name for one entry?

The documantation of Key.from_path says that only can define id or key_name for it, so which means that an entry can has id or key_name, right?


No. You can one or the other, but not both.

See http://code.google.com/appengine/docs/python/datastore/entities.html#Kinds_IDs_and_Names


The entity ID is part of the key. This can be an arbirary string specified by the app, or it can be generated automatically by the datastore. The API calls an entity ID given by the app a key name, and an entity ID generated by the datastore an ID. An entity has either a key name or an ID, but not both. The ID is populated when the entity object is saved to the datastore for the first time.

链接地址: http://www.djcxy.com/p/57826.html

上一篇: 恢复appengine数据存储数据的选项?

下一篇: appengine数据存储ID和密钥