title: Firebase update or set
body: <p>After adding a post about a person to a Firebase database, I want to add the reference to the new post to the person. However the person may or may not already exist.</p>
  <p>I have:</p>
  <pre><code>var ref = new Firebase(&quot;https://mydatabase.firebaseio.com/&quot;);
  var _person = document.getElementById(&quot;Person&quot;).value;
  var _remark = document.getElementById(&quot;Remark&quot;).value;
  
  var postsRef = ref.child(&quot;remarks&quot;);
  var newPostRef = postsRef.push({
      person: _person,
      remark: _remark
  });
  
  var postID = newPostRef.key();
  
  var personRef = ref.child(&quot;person&quot;);
  personRef.update({
      _person: postID
  });
  </code></pre>
  <p>However that creates a node called <code>_person</code> in child person instead of the value of the <code>_person</code> variable. Using <code>set()</code> would overwrite an existing person.</p>
  <p>Example:
  First a node <code>remarks/-JlkbxAKpQs50W7r84gf</code> is created with child node <code>person/123456</code></p>
  <p>After that I want to create a node <code>person/123456</code> (only if it doesn't already exist) and than add a child node <code>remark/-JlkbxAKpQs50W7r84gf</code> to it. The post-id is automatically generated (Firebase) but the person's id is to be taken from a html form.</p>
  <p>How do I do that?</p>