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

与世无争的帅哥 提交于 2019-12-03 15:35:49

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/18945109/how-to-delete-all-entities-for-ndb-model-in-google-app-engine-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!