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()
You can delete from multiple data store entities in one transaction by creating an array of type EntityDataIdentifiers. All entities defined in the array must be of the same data store.
The Google Datastore NDB Client Library allows App Engine Python apps to connect to Datastore. The NDB client library builds on the older DB Datastore library adding the following data store features: The StructuredProperty class, which allows entities to have nested structure.
To update an existing entity, modify the attributes of the Entity object, then pass it to the DatastoreService. put() method. The object data overwrites the existing entity. The entire object is sent to Datastore with every call to put() .
An entity has one or more named properties, each of which can have one or more values. Entities of the same kind do not need to have the same properties, and an entity's values for a given property do not all need to be of the same data type.
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)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With