superfeedr / indexeddb-backbonejs-adapter

An indexedDB adapter for Backbonejs
http://blog.superfeedr.com/indexeddb-backbonejs-adapter/
MIT License
248 stars 61 forks source link

delete does not handle keyPath #50

Closed yoann-antoviaque closed 10 years ago

yoann-antoviaque commented 10 years ago

The delete function does not check if a keypath is specified, therefore tries to remove the entry using the id attribute making the state incoherent: the object is correctly removed from the backbone collection but not from indexeddb

changing

var deleteRequest = store.delete(json.id);

to

var deleteRequest;
if (!store.keyPath)
      deleteRequest = store.delete(json.id);
else
      deleteRequest = store.delete(object.get(store.keyPath)); 

fix this issue

julien51 commented 10 years ago

Please, submit a pull requests with passing tests :)