KVNA
KVNA

Reputation: 907

dom-repeat Firebase data in Polymer

I have a template that returns an amount from a Firebase realtime database, and it is correctly mapped, and returns a value when the path="/orders". However, when I change the path to path="/orderHistory/[[user.uid]]" with the same data structure stored at the location, nothing is returned.

The user auth object is properly populated, as I have other elements that are returning data properly using this pattern.

  <firebase-auth user="{{user}}"></firebase-auth>
  <firebase-document path="/orders" data="{{orders}}"></firebase-document>

  <template is="dom-repeat" items="{{_toArray(orders)}}">
    <p3>{{item.amount}}</p3>
  </template>

...

_toArray: function (orders) {
     return Object.keys(orders).map(function (key) {
       return {
         date: Date(key),
         amount1: orders[key]['Item']['Amount']
       };
     });
   }

...

I am trying to store and return order data... and the JSON structure is as follows:

{
  "1473829170599" : {
    "0" : {
      "Item" : {
        "Amount" : 16,
        "QR" : "Bw16Bb14Ni17",
        "Quantity" : 2
      }
    },
  "hasFabbed" : 0,
  "hasPaid" : 0,
  "hasShipped" : 0
}

How can I return cart data for a user with Polymer's dom-repeat pattern?

Upvotes: 1

Views: 158

Answers (1)

KVNA
KVNA

Reputation: 907

Use <firebase-query> instead of <firebase-document>.

Upvotes: 0

Related Questions