Sharing the same Key between 2 entities

27 views
Skip to first unread message

Rajesh Bhardwaj

unread,
Nov 15, 2022, 6:27:11 PM11/15/22
to Google Cloud Datastore
Hello,
Is it ok to generate ID key for 1 entity and then use it to store data into more than 1 entity.
My use case is - I store data into multiple entities based on data recvd from 1 entity.
I understand , I can use the ID as a key , but this makes things much simpler

Patrice Bertrand

unread,
Nov 16, 2022, 3:11:39 PM11/16/22
to Google Cloud Datastore
Your use case is not clear at all to me.   Two different entities may not have the same key, that is for sure, that is in the definition of a key.  Two entities of different kinds could have the same Id, but they will not have the same key.  That is one way to implement a 1-1 relationship between entities of different kinds, by reusing the Id of one entity into the other.  Don't know if that is what you need.  If you have many entities that are *related* to the same parent entity, you should use parenting.  You cannot "use the Id as a key", you can only "build a key with a given Id". 
Reply all
Reply to author
Forward
0 new messages