We want to return the number of objects deleted when we call IDBObjectStore.delete(range). Currently we return 'undefined'. See the issue here on github: https://github.com/w3c/IndexedDB/issues/32 It would look like: var request = store.delete(range); request.onsuccess(function() { console.log('Deleted num: ' + request.result); }); The operation sits here: https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/indexed_db/indexed_db_database.cc&q=indexed_db_database.cc&l=1408&pv=1 where we'll be calling OnSuccess with a number instead of no arguements. We'll be modifying the following methods to return (probably through an argument pointer) the number of records deleted: https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/indexed_db/indexed_db_backing_store.cc&l=1992&pv=1&rcl=1462980034 https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/indexed_db/indexed_db_backing_store.cc&l=1363&pv=1&rcl=1462980034
We plan to launch this behind the experimental web platform features flag, and see what others think.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/dbb2725b92683d709296e19fb107ceb483180729 commit dbb2725b92683d709296e19fb107ceb483180729 Author: palakj <palakj@google.com> Date: Thu Jun 09 19:01:24 2016 Modify leveldb::DeleteRangeBasic function to return number of values deleted by IDBObjectStore.delete(range) with modifications to other functions as needed. BUG= 611201 Review-Url: https://codereview.chromium.org/1996443003 Cr-Commit-Position: refs/heads/master@{#398974} [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/indexed_db_backing_store.cc [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/indexed_db_backing_store.h [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/indexed_db_backing_store_unittest.cc [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/indexed_db_callbacks.h [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/indexed_db_database.cc [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/indexed_db_database.h [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/leveldb/leveldb_transaction.cc [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/content/browser/indexed_db/leveldb/leveldb_transaction.h [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete-expected.png [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete-expected.txt [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete2-expected.png [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete2-expected.txt [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete3-expected.png [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete3-expected.txt [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete4-expected.png [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete4-expected.txt [add] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/storage/indexeddb/delete-range-count.html [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/storage/indexeddb/mozilla/delete-result-expected.txt [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt [modify] https://crrev.com/dbb2725b92683d709296e19fb107ceb483180729/third_party/WebKit/LayoutTests/storage/indexeddb/objectstore-basics-workers-expected.txt
Discussion on the github issue it seems like we should make this an option instead of the default behavior for delete(): https://github.com/w3c/IndexedDB/issues/32 e.g. delete(query, {returnNumberOfRecordsDeleted: true})
Can there be an alternative smaller name in place of 'returnNumberOfRecordsDeleted' like 'countRecordsDeleted' or something better?
Yes, please suggest better names (on github)! I used something intentionally terrible so we wouldn't ship it. :)
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e0966a9bc1b272bf35987de5d39411b87a90c930 commit e0966a9bc1b272bf35987de5d39411b87a90c930 Author: jsbell <jsbell@chromium.org> Date: Wed Oct 19 23:29:28 2016 Indexed DB: Remove experimental delete-returns-count change We implemented an experimental change where IDBObjectStore.delete() yielded the number of records deleted. Standards discussion converged on making this opt-in via an option to the method. Back out the change (and test) until we have further consensus on what the option would be. (This was only enabled with the --experimental-... flag.) BUG= 611201 ,435727 Review-Url: https://chromiumcodereview.appspot.com/2433223002 Cr-Commit-Position: refs/heads/master@{#426333} [modify] https://crrev.com/e0966a9bc1b272bf35987de5d39411b87a90c930/content/browser/indexed_db/indexed_db_database.cc [modify] https://crrev.com/e0966a9bc1b272bf35987de5d39411b87a90c930/content/browser/indexed_db/indexed_db_database.h [delete] https://crrev.com/726532184d7cad941c4a05e7970080fe4d7acc89/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete-expected.txt [delete] https://crrev.com/726532184d7cad941c4a05e7970080fe4d7acc89/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete2-expected.txt [delete] https://crrev.com/726532184d7cad941c4a05e7970080fe4d7acc89/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete3-expected.txt [delete] https://crrev.com/726532184d7cad941c4a05e7970080fe4d7acc89/third_party/WebKit/LayoutTests/imported/wpt/IndexedDB/idbobjectstore_delete4-expected.txt [delete] https://crrev.com/726532184d7cad941c4a05e7970080fe4d7acc89/third_party/WebKit/LayoutTests/storage/indexeddb/delete-range-count.html [modify] https://crrev.com/e0966a9bc1b272bf35987de5d39411b87a90c930/third_party/WebKit/LayoutTests/storage/indexeddb/mozilla/delete-result-expected.txt [modify] https://crrev.com/e0966a9bc1b272bf35987de5d39411b87a90c930/third_party/WebKit/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt [modify] https://crrev.com/e0966a9bc1b272bf35987de5d39411b87a90c930/third_party/WebKit/LayoutTests/storage/indexeddb/objectstore-basics-workers-expected.txt
Archiving for now, pending further activity.
Comment 1 by dmu...@chromium.org
, May 11 2016