What happens to child datastore objects after deleting the ancestor?

僤鯓⒐⒋嵵緔 提交于 2020-01-03 09:07:10

问题


I want to understand the parent/child (ancestor paths) relationship found in the Google AppEngine datastore that wasn't mentioned in the online documentation. What happens to children objects when the parent is deleted? Do child objects also get deleted? Do they become orphaned without a parent? If so how would you query for them?

Google Help Doc regarding Ancestor Paths: https://cloud.google.com/appengine/docs/go/datastore/entities#Go_Ancestor_paths

Thanks! ~Todd


回答1:


Child entities do not get deleted when the ancestor is deleted: there's no 'cascade on delete' behaviour. In fact, an ancestor entity doesn't even have to exist when defining an entity group (only its Key).




回答2:


They will remain unaffected, you will just be unable to get their parent entity. i.e.

child_entity.key.parent().get()

will return None.



来源:https://stackoverflow.com/questions/32456497/what-happens-to-child-datastore-objects-after-deleting-the-ancestor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!