title: Can you append a string to a Firebase array with swift
body: <p>I am keeping track of whether or not a user likes a restaurant in firebase but I am currently using a string to do this. I know its possible to update an array in Firebase but from what I have read in order to do this you need to rewrite the entire array every time you want to add a new element. Is there any way to just append a string to the end of the array? And if that's not possible does anyone know a better alternative then just using a string?</p>
  
  <p>This is what I'm using right now:</p>
  
  <pre class="lang-swift prettyprint-override"><code>var likedBarsGlobal: [String] = [] {
      didSet {
          var lb = ""
          for i in 1...likedBarsGlobal.count - 1 {
              if(i == likedBarsGlobal.count - 1){
                  lb += "\(likedBarsGlobal[i])"
              } else {
                  lb += "\(likedBarsGlobal[i]), "
              }
          }
  
          db.collection("users").document(userId).updateData(["likedBars": lb ]) { (error) in
              if error != nil {
                  print(error)
              }
          }
      }
  }
  </code></pre>