Using Polymerfire, I want to add new nodes to a Firebase without overwriting data. (I call this push
or put
behavior.)
In other words. I want to start with this:
State Amy-app
|
- emails
|
+ email1@example,com
+ email2@example,com
And finish with this.
State Bmy-app
|
- emails
|
+ email1@example,com
+ email2@example,com
+ email3@example,com
+ email4@example,com
But when I start with State A and do this:
<firebase-document
id="doc"
app-name="app"
data="{{data}}">
</firebase-document>
...
this.$.doc.save('/', 'emails');
I wind up with this:
State Bmy-app
|
- emails
|
+ email3@example,com
+ email4@example,com
Notice the starting data: email1@example,com
and email2@example,com
were deleted.
Here is the Polymerfire documentation. But it doesn't mention anywhere how to accomplish this type of push
or put
-type method to insert data into a node.
How can I accomplish this?
Edit
The answer by @motss suggests:
this.$.doc('/emails');
instead of
this.$.doc('/', 'emails');
But that does not work because it adds a random auto key as follows:
State Bmy-app
|
- emails
|
- -hvOxpxwjpWHBYGj-Pzqw
|
+ email3@example,com
+ email4@example,com
Note the added key: -hvOxpxwjpWHBYGj-Pzqw
thereby destroys the indexing feature of the data structure.