treojs / treo

Consistent API to IndexedDB
http://treojs.com
MIT License
258 stars 18 forks source link

Feature: `put` passes the key of the created/updated record to callback #20

Closed glsignal closed 9 years ago

glsignal commented 9 years ago

I've made use of this behaviour in the vanilla IndexedDB interface and found it very useful.

When creating/updating records on an object store using IDBObjectStore.put, the onsuccess event handler will be passed the record's key as result:

objectStore.put(record).onsuccess = function(evt) {
  console.log(evt.target.result); // record's key
};

It would be helpful, for myself at least, if treo implemented this behaviour perhaps something like this:

treoStore.put(record, function(key) {
  console.log(key); // record's key
});

What are your thoughts?

alekseykulikov commented 9 years ago

Agreed that it's useful. Especially with autoIncrement, will be implemented in 0.4.0

glsignal commented 9 years ago

:+1: Excellent :)