How to delete all entities for NDB Model in Google App Engine for python?

bogen picture bogen · Sep 22, 2013 · Viewed 8k times · Source

I have a ndb model class:

class Game(ndb.Model):
    gameID = ndb.IntegerProperty()
    gameName = ndb.StringProperty()

Is there any way to quickly just delete all entities thats stored in the database for this class? Something like Game.deletAll()

Answer

Jesse picture Jesse · Sep 22, 2013

No, but you could easily do this with something like:

from google.appengine.ext import ndb

ndb.delete_multi(
    Game.query().fetch(keys_only=True)
)