libZoteroJS icon indicating copy to clipboard operation
libZoteroJS copied to clipboard

Question: How can I download the collections in a library?

Open cboulanger opened this issue 7 years ago • 1 comments

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.

cboulanger avatar Feb 03 '17 22:02 cboulanger

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.

cboulanger avatar Feb 04 '17 11:02 cboulanger