0

I am having a problem with using Polymer's firebase-collection component. After following the todo-app example, I am able to access data from specific users, however I would like to do more advanced things such as denormalizing the data to have more flattened JSON data that many users can access globally see here for firebase guidelines. My firebase data is set up in the following way:

{
    "users":{
        "uid1":{...}
    }, 

    "sharedDoc":{
        "section 1":{
             "0" : {"title": "Blah0"},
             "1" : {"title": "Blah1"}
             .
             .
             .
    }, 

}

after authentication, polymer's firebase-collection works fine with this URL location:

<firebase-collection location="https://(url-stuff)/(url-stuff).firebaseio.com/users/uid1"
                     data="{{userStuff}}"
                     >
</firebase-collection>

and within the scope of my element, this.userStuff is a variable that has everything in the uid1 branch

however, when I use this the URL to access non-user information like below:

<firebase-collection location="https://(url-stuff)/(url-stuff).firebaseio.com/sharedDoc"
                     data="{{sharedDoc}}"
                     >
</firebase-collection>

this.sharedDoc is empty.

Even after populating sharedDoc beforehand with "dummy" data, sharedDoc becomes empty afterward.

Does anyone have any resources that they can recommend to figure out how I can fix this code so that the sharedDoc URL location returns the associated JSON from firebase (as above)?

  • Update! for some reason using firebase-document works, I am not sure why... – user2752391 Mar 20 '16 at 19:10
  • It looks like "sharedDoc" doesn't have a collection, rather "section 1" does. Try using that as your location. – sfeast Mar 21 '16 at 03:41
  • @sfeast I think the problem may be coming from a lac of understanding with the definition of a "collection." Would you mind expanding on what makes "section 1" a collection? (I suspect it has something to do with it being similar to an array) – user2752391 Mar 24 '16 at 19:18
  • Right - firebase-collection expects the data to be in an array like structure & firebase-document will just take whatever is at the firebase location you give it. It's not actually clear here what you have under "sharedDoc" in firebase so re-reading my comment I could have been incorrect depending on the structure under sharedDoc. – sfeast Mar 25 '16 at 23:06

0 Answers0