bogen
bogen

Reputation: 10422

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

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

Upvotes: 18

Views: 8323

Answers (1)

Jesse
Jesse

Reputation: 8393

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

Upvotes: 40

Related Questions