简体   繁体   中英

GOOGLE APP ENGINE - NDB - KEY

I have table A and AEXT.

I would like to use the same KEY/ID for AEXT as the relationship between table A and table AEXT are 1-1 and as the name suggests AEXT has extended/additional attributes of A.

Can someone please let me know how can I do this in NDB/Python.

Thanks in advance

Two "tables" (really entity types) can have the same key name as long as they have different paths in the datastore. A path is the kind/name of the entity and all of its ancestors. So for example you could do:

a_key = ndb.Key(A, 'mykey')
aext_key = ndb.Key(AEXT, 'mykey')

Now these keys would be different, but you could construct them again using the same key name , 'mykey' . And once you have the keys, you can grab the entities themselves.

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM