diff --git a/chrome/content/zotero/xpcom/data/collections.js b/chrome/content/zotero/xpcom/data/collections.js index 8b3a6a57c2..05b2e8b7b2 100644 --- a/chrome/content/zotero/xpcom/data/collections.js +++ b/chrome/content/zotero/xpcom/data/collections.js @@ -182,23 +182,6 @@ Zotero.Collections = function() { } } - - this.erase = function(ids) { - ids = Zotero.flattenArguments(ids); - - return Zotero.DB.executeTransaction(function* () { - for each(var id in ids) { - var collection = yield this.getAsync(id); - if (collection) { - yield collection.erase(); - } - collection = undefined; - } - - this.unload(ids); - }.bind(this)); - }; - Zotero.DataObjects.call(this); return this; diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 52d196d554..7c83ef3816 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -518,6 +518,31 @@ Zotero.DataObjects.prototype.getPrimaryDataSQLPart = function (part) { } +/** + * Delete one or more objects from the database and caches + * + * @param {Integer|Integer[]} ids - Object ids + * @param {Object} [options] - See Zotero.DataObject.prototype.erase + * @return {Promise} + */ +Zotero.DataObjects.prototype.erase = Zotero.Promise.coroutine(function* (ids, options = {}) { + ids = Zotero.flattenArguments(ids); + yield Zotero.DB.executeTransaction(function* () { + for (let i = 0; i < ids.length; i++) { + let obj = yield this.getAsync(ids[i]); + if (!obj) { + continue; + } + yield obj.erase(options); + } + this.unload(ids); + }.bind(this)); +}); + + + + + Zotero.DataObjects.prototype._load = Zotero.Promise.coroutine(function* (libraryID, ids, options) { var loaded = {}; diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index b5c99444bc..a9d4990067 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -597,29 +597,6 @@ Zotero.Items = function() { } - /** - * Delete item(s) from database and clear from internal array - * - * @param {Integer|Integer[]} ids - Item ids - * @return {Promise} - */ - this.erase = function (ids) { - return Zotero.DB.executeTransaction(function* () { - ids = Zotero.flattenArguments(ids); - - for (let i=0; i