is it possible to have keyname and an id for an entity in Appengine?
I'm building a facebook app, and my users table's keyName is set to the Uid of the facebook user. I found this to be effi开发者_C百科cient because I can use db.Key.from_path() to efficiently query the datastore for a particular user instead of doing a query (where uid = x, limit = 1). This is actually my first time using key names.
But when I did this in the sdk, the key().id() is set to None. Is there a way have an id as well?
I'd like an id for use as a primary key is because it's shorter and an integer which makes it faster when I'm storing users in a listProperty (i.e a seperate Buddies entity with a list of friends the user has in the app).
I hope this makes sense :)
thanks a ton!
No. An entity's Key is composed of the application ID, the Kind, the path of the parent entity (if any) and either a key name or an auto-generated ID. It's not possible to have both. The entire Key is the "primary key".
精彩评论