如何在Google App Engine中为Python删除NDB模型的所有实体?

如何在Google App Engine中为Python删除NDB模型的所有实体?

问题描述:

我有一个ndb模型类:

I have a ndb model class:

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

有什么办法可以快速删除存储在数据库中的这个类的所有实体?例如 Game.deletAll()

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

不,但您可以轻松做到这一点:

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