views:

34

answers:

2

I created entity in google App Engine datastore.I know how to create entity and remove data from table.My constraints is how to delete entity from google App engine Datastore?

Thanks in advance

+3  A: 

You haven't specified which API you're using.

In Python it's like so:

db.delete(modelId)

In Java it should be like (I haven't tested this):

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

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

pm.close();
Brian McKenna
The Python example is incorrect - 'key' is a reserved field name, so can't be used as a property. It should either be filtering on another property, or using MyModel.get to get by key. In the former case, a batch delete such as db.delete(MyModel.all().fetch(500)) is _much_ more efficient.
Nick Johnson
+1  A: 

In python if you know the key it really simple:

db.delete(key)
Ilian Iliev