How to delete data from Google App Engine?

I created one table in the Google App Engine. I saved and received data from the Google App Engine. However, I do not know how to delete data from the Google App Engine data store.

+3
source share
3 answers

An application can delete an object from the data store using an instance of the model or key. The method for deleting an instance of a model instance () removes the corresponding object from the data store. The delete () function receives a key or a list of keys and deletes an entity (or entities) from the data store:

q = db.GqlQuery("SELECT * FROM Message WHERE msg_date < :1", earliest_date)
results = q.fetch(10)
for result in results:
    result.delete()

# or...

q = db.GqlQuery("SELECT __key__ FROM Message WHERE msg_date < :1", earliest_date)
results = q.fetch(10)
db.delete(results)

Source and further reading:

, :

+4

, .

, python

q = db.GqlQuery("SELECT __key__ FROM Message WHERE create_date < :1", earliest_date)
results = q.get()
db.delete(results)

Java

pm.deletePersistent(results);

URL- :

http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Deleting_an_Object http://code.google.com/appengine/docs/python/datastore/creatinggettinganddeletingdata.html#Deleting_an_Entity

+1

In java

I assume you have an endpoint:

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

And then:

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

Source: https://habr.com/ru/post/1735776/


All Articles