views:

267

answers:

1

Hi,

I have a tableview with data, that i post to the app engine database. Whenever i delete an entry in the table, i want to delelte the item in the app engine database as well. How do i know which entry to delete?

I was thinking of this:

for every item i save in the GAE store, i make a reference to a model with the iphone unique device id. for every item i save in the GAE store, i insert a UUID for iphone db & app engine db.

So my query would be something like this ex:

del item where unique device id = ####
and item UUID = ####

I dont want to login to app engine, thats why i am using the unique device id.

My only concern is performance, GAE has to lookup device id and the UUID, i dont know if this wil be a problem?

Best solution would be if just could delete it by its db.Key(), but i dont know how to do that, because when i post the data to GAE i dont know what key it generated.

Could anyone give me some advice?

+1  A: 

The approach you suggest is reasonable. If you specify the UUID as your key name, you can delete it directly. To create an entity with a key name, do:

MyEntity(key_name=a_string, ...)

To delete an entity by key name (without fetching it first), do:

db.delete(db.Key.from_path("MyEntity", a_string))

There's no need to have both a UUID and a device ID - the UUID is sufficient to ensure uniqueness across all devices.

Nick Johnson
Thank you very much!
Ton