title: Update a Parent Title in Firebase Realtime DB in Swift
body: <p>I am trying to update one of the parents in my database. However, I am unsuccessful. Here is what the DB looks like:</p>
  <p><a href="https://i.stack.imgur.com/tGx0G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tGx0G.png" alt="enter image description here" /></a></p>
  <p>I am able to <code>Update</code> the <strong>description</strong> and <strong>due date</strong> like so:</p>
  <pre><code>    taskRef = Database.database().reference(withPath: &quot;Tasks&quot;).child(titleOfTask)
  
      taskRef?.updateChildValues([&quot;Due Date&quot;: date_time])
      taskRef?.updateChildValues([&quot;Description&quot;: taskDescription])
  </code></pre>
  <p>However, I am trying to figure out how to update the name of the task. For example, if the user is trying to update the description of task &quot;Alpha&quot; and also decides to rename the task as well, how can I update the name?</p>
  <p>I first tried to do this, but it didn't work, it just created and another key, value pair under the &quot;Alpha&quot; parent.</p>
  <pre><code>    newTaskRef?.updateChildValues([titleOfTask: taskTitle])
  </code></pre>
  <p>Then I realized that my database reference is to the Task Title already, so it wouldn't have worked. Then I thought about creating another database reference to just &quot;Tasks&quot;, and updating the title like so:</p>
  <pre><code>    newTaskRef = Database.database().reference(withPath: &quot;Tasks&quot;)
      newTaskRef?.updateChildValues([titleOfTask: taskTitle])
  </code></pre>
  <p>But this didn't work either. Not sure what else I could try, or where I am going wrong.</p>
  <hr />
  <p><strong>Important Things:</strong></p>
  <ul>
  <li>taskTitle holds the new input the user enters</li>
  <li>titleOfTask is the old name of the task. (i.e, used as a reference to read from DB)</li>
  </ul>
  <p><em><strong>in other words:</strong></em></p>
  <p>If the user wants to edit the &quot;<code>Alpha</code>&quot; Task, we would have to pass the STRING &quot;Alpha&quot; to the <code>database.reference</code> so we can read its values and update the description and/or due date. So the original Title of Task is stored in &quot;titleOfTask&quot;, and the new task title would be stored in &quot;taskTitle&quot;</p>
  <hr />