0

Polymer syncs an empty dynamically generated id with the data then syncs the data with the data binded key. How do i stop this from happening.

<firebase-document
    path="/users/[[authenticatedUser.id]]/token"
    data="[[messagingAPI_TOKEN]]">
</firebase-document>

expected outcome:

{
   "users" : {
       "57f49f8ffaf7e800116e96e2" : {
          "token" : reallyLongToken
       }
    }
 }

actual outcome:

{
   "-KhitjHsZDTjsIezQBiZ" : reallyLongToken,
   "users" : {
       "57f49f8ffaf7e800116e96e2" : {
          "token" : reallyLongToken
       }
    }
 }

Looks like the "ghost" data is created as a result of null return from [[authenticatedUser.id]]. Because it is dynamic and not from my system is is wasteful and fills the database with unwanted data.

user3533087
  • 53
  • 2
  • 7

1 Answers1

0

Can you try to put your firebase-document element inside a template dom-if like below:

<template is="dom-if" if="[[authenticatedUser.id]]">
  <firebase-document
    path="/users/[[authenticatedUser.id]]/token"
    data="[[messagingAPI_TOKEN]]">
  </firebase-document>
</template>
Phani
  • 1,851
  • 2
  • 15
  • 28
  • Glad it worked, can you please accept the answer so that anyone else having the same problem can get benefited! – Phani Apr 18 '17 at 04:36