Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to child datastore objects after deleting the ancestor?

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

like image 475
tmoore Avatar asked Sep 08 '15 11:09

tmoore


2 Answers

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

like image 114
tx802 Avatar answered Sep 22 '22 01:09

tx802


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

child_entity.key.parent().get()

will return None.

like image 32
Omair Shamshir Avatar answered Sep 18 '22 01:09

Omair Shamshir