title: swift Firebase adding key:value pair to a child
body: <p><strong>EDITED</strong></p>
  
  <p>i have to add a new pair of key:values in the node utenti in my Firebase database structured as below, but without deleting previous pairs already stored in db
  <a href="https://i.stack.imgur.com/RokQW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RokQW.png" alt="enter image description here"></a></p>
  
  <p>I get those pair from an array of custom objects where I have stored all user I have to add </p>
  
  <p>so with for cycle:</p>
  
  <pre><code>for user in self.usersarray {
  
  let utentiRef = root.child("groups").child(groupId!).child("utenti")
              let refToAdd = utentiRef.child(user.id!)
              refToAdd.setValue(true)
     }
  </code></pre>
  
  <p>it works and add all the users in the array but it overwrite previous users already stored on firebase.</p>
  
  <p>I noticed that when from another view controller i run </p>
  
  <p><code>root.child("groups").child(groupId!).child("utenti").updateChildValues([user.id!: true])</code></p>
  
  <p>the single user is added without overwriting, so where is the problem??</p>