More specifically: should the code below do the job, and how do I tell Zotero to drop the collections/items cache (in toto is OK, there will not be other libraries in my tests):
Zotero.Promise.coroutine(function*() {
yield Zotero.DB.executeTransaction(function*() {
yield Zotero.DB.queryAsync("DELETE FROM itemData WHERE itemID in (SELECT itemID from items WHERE libraryID=?)", [Zotero.Libraries.userLibraryID]);
yield Zotero.DB.queryAsync("DELETE FROM itemDataValues WHERE valueID NOT IN (SELECT valueID from itemData)");
yield Zotero.DB.queryAsync("DELETE FROM items WHERE libraryID = ?", [Zotero.Libraries.userLibraryID]);
yield Zotero.DB.queryAsync("DELETE FROM deletedItems WHERE itemID NOT IN (SELECT itemID FROM items)");
yield Zotero.DB.queryAsync("DELETE FROM collections WHERE libraryID = ?", [Zotero.Libraries.userLibraryID]);
/*
notify Zotero that items for Zotero.Libraries.userLibraryID must be uncached
notify Zotero that collections for Zotero.Libraries.userLibraryID must be uncached
*/
});
})();