如何在Google App Engine中为Python删除NDB模型的所有实体? [英] How to delete all entities for NDB Model in Google App Engine for python?
本文介绍了如何在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)
)
这篇关于如何在Google App Engine中为Python删除NDB模型的所有实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文