How to remove an object from the Google App Data Warehouse?

I created an object in the Google App Engine datastore.

How to delete this object?

+5
source share
4 answers

You did not specify which API you are using.

In Python, it is like this :

db.delete(modelId)

In Java, it should be like (I have not tested this):

PersistenceManager pm = PMF.get().getPersistenceManager();

MyModel entity = pm.getObjectById(MyModel.class, modelId);
pm.deletePersistent(entity);

pm.close();
+4
source

In python, if you know the key, it is very simple:

db.delete(key)
+3
source

, :

Somethingendpoint endpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build();

:

endpoint.remove<ModelName>(long ID); 
0

, - ( Python):

class MyClass(ndb.Model):
    myString = ndb.StringProperty(indexed=false)

def deleteAllEntities():
    entities = MyClass.query()
    for entity in entities:
        entity.key.delete()

, , , , .

More information here: https://cloud.google.com/appengine/docs/python/datastore/entities#Python_Deleting_an_entity

0
source

All Articles