How to delete an entity including all children

前端 未结 1 1644
别那么骄傲
别那么骄傲 2021-01-20 12:32

I would like to do a cascading delete on an entity in the datastore. By this I mean all children and indirect children will also be deleted. I initially assumed this would b

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-20 12:53

    For kindless ancestor queries create the query from the query class

    ndb.delete_multi(ndb.Query(ancestor=key).iter(keys_only = True))
    

    I wouldn't use the cascading delete for all child entities. If you have a lot then it will be much slower (unless you want to run the delete in a task).

    0 讨论(0)
提交回复
热议问题