0

Is it possible to use dom-repeat to perform multiple <firebase-query> and aggregate the results in an array using Observers? Such as:-

<template is="dom-repeat" items="[[queryUser]]">
  <firebase-query id="queryDetail_[[index]]"
    path="/users/[[item.$key]]/detail"
    start-at="2017-01-01"
    order-by-child="timestamp"
    data="{{queryDetail.[[index]]}}">
  </firebase-query>
</template>
observers: [
  '_queryDetailChanged(queryDetail.*)',
]

The above code obviously doesn't work, it's just to demostrate the idea. Thanks!

Andrew See
  • 1,062
  • 10
  • 21
  • I don't think this would be a good idea. You will have access to the global `firebase` object which will enable you to get a reference to your data. You could then aggregate the results of these into a single array. You'll want to have a look at the firebase documentation for how to do this. – Ben Thomas Jun 15 '17 at 08:48
  • I know you can perform that programatically with script, I am just wondering if there is an easy way to do it declaritively using Polymer template/data-binding as it's quite a common use case to query the same query over multiple node and aggregate the result. Anyway, thanks for your suggestion. – Andrew See Jun 16 '17 at 16:30
  • You could potentially not bind the data attribute and listen for the `data-changed` event on the `firebase-query` element to call a function which aggregates your data. I've not tried this so I'm only going on what the docs say. – Ben Thomas Jun 19 '17 at 08:41

0 Answers0