libZoteroJS
libZoteroJS copied to clipboard
Question: How can I download the collections in a library?
Hi, I was looking through the examples, tests, and the source but couldn't figure out how, given a Library object, I retrieve the data of the collections in that library. Thanks for any pointers.
Ok, figured out that much:
var library = new Zotero.Library(...)
library
.loadUpdatedCollections()
.then(function(result){
var collectionObjects = library.collections.collectionObjects;
var collections = {};
var colllection;
for( var key in collectionObjects )
{
colllection = library.collections.getCollection(key);
collections[key]= {
key: key,
name: colllection.apiObj.data.name,
parent: colllection.apiObj.data.parentCollection };
}
Can this be written more efficiently and API-compliant? It would be great if you could add an example how to work with collections and to edit them.