Polymer 1.x: $key throws error when saving to Firebase

186 Views Asked by At

I want to save a firebase-document to Firebase. But I encounter the following error.

error.log

Uncaught (in promise) Error: Firebase.push failed: first argument contains an invalid key ($key) in property 'xxxxxxxxxxxx.items'. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"

Here is the relevant code.

my-element.html
<firebase-document id="document" ... ></firebase document>
...
save: function() {
  var doc = this.$.document;
  console.log('Saved', doc.data);
  return doc.save(this.itemsPath).then(function() {
    console.log('Saved:', doc);
    doc.reset();
  }.bind(this));
  return Promise.resolve();
},

The data object contains a key label containing the $ character. But this is automatically introduced by Firebase, not a programming decision.

console.log
Saved: {
  $key: "foo" // This is the object key in Firebase
  ...
}

What edits can I make to save my data?

0

There are 0 best solutions below