treojs / treo

Consistent API to IndexedDB

Home Page:http://treojs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

glsignal opened this issue · comments

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?

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

👍 Excellent :)