开发者

is it possible to have keyname and an id for an entity in Appengine?

开发者 https://www.devze.com 2023-01-17 10:54 出处:网络
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 t

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".

0

精彩评论

暂无评论...
验证码 换一张
取 消