title: How do I allow a user to only fetch their own data? Swift
body: <p>I've already implemented Firebase in my app. I'm able to press a button and send the desired data to Firebase. I also set up a table view, so that the desired data is then added to the table view. However, when any user presses the butting to send data and update the table, all of the data is pulled, even from other users. It seems the entire database is being pulled, rather than the one specific to the user. I want a user to be able to get the hand drying options that they entered/saved based on their uid, not those of other users. I think it has something to do with this part of the code: let handDryLocations = [&quot;id&quot;:key</p>
  <p>I'm very new to all of this so any help would be very much appreciated. Here is the code:</p>
  <pre><code>import UIKit
  import Firebase
  import FirebaseDatabase
  
  class HandDrySaveViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
  
      var refHandrylocations: DatabaseReference!
      
      @IBOutlet weak var BestOption: UILabel!
      
      override func viewDidLoad() {
          super.viewDidLoad()
          
          NotificationCenter.default.addObserver(self, selector: #selector(didGetNotification4(_:)), name: Notification.Name(&quot;text4&quot;), object: nil)
  
          NotificationCenter.default.addObserver(self, selector: #selector(didGetNotification5(_:)), name: Notification.Name(&quot;text5&quot;), object: nil)
          
          if FirebaseApp.app() == nil {
              FirebaseApp.configure()
          }
          
          refHandrylocations = Database.database().reference().child(&quot;users&quot;);
          
          refHandrylocations.observe(DataEventType.value, with:{(snapshot) in
              if snapshot.childrenCount&gt;0{
                  self.handDryList.removeAll()
                  
                  for handDryOptions in snapshot.children.allObjects as![DataSnapshot]{
                      let handDryObject = handDryOptions.value as? [String: AnyObject]
                      let handDryLocation = handDryObject?[&quot;handrylocation&quot;]
                      let handDryBest = handDryObject?[&quot;handdrybest&quot;]
                      let handDryString = handDryObject?[&quot;handdryoption&quot;]
                      let handDryId = handDryObject?[&quot;id&quot;]
                      
                      let handDry = HandDryModel(id: handDryId as! String?, location: handDryLocation as! String?, best: handDryBest as! String?, options: handDryString as! String?)
                      
                      self.handDryList.append(handDry)
                  }
                  
                  self.handDryTable.reloadData()
              }
          })
          // Do any additional setup after loading the view.
      }
      
      @IBAction func BacktoHDCalcButton(_ sender: UIButton) {
          
          let storyboard = UIStoryboard(name: &quot;Main&quot;, bundle: nil)
          let vc = storyboard.instantiateViewController(identifier: &quot;TowelVDryer&quot;)
          vc.modalPresentationStyle = .overFullScreen
          present(vc, animated: true)
      }
      
      func addHandDryLocation(){
          let key = refHandrylocations.childByAutoId().key
          
          let handDryLocations = [&quot;id&quot;:key,
                                  &quot;handrylocation&quot;: HandDryLocation.text! as String,
                                  &quot;handdrybest&quot; : BestOption.text! as String,
                                  &quot;handdryoption&quot; : HandDryOptionsString.text! as String
                                      ]
          refHandrylocations.child(key!).setValue(handDryLocations)
          
          OptionSavedMessage.text = &quot;Location Saved&quot;        
      }    
      
      @IBOutlet weak var HandDryOptionsString: UILabel!
      @IBOutlet weak var HandDryLocation: UITextField!
      
      @IBOutlet weak var OptionSavedMessage: UILabel!
      @IBAction func BackButton(_ sender: UIButton) {
      }
      
      
      @objc func didGetNotification4(_ notification: Notification){
          let text = notification.object as! String?
          HandDryOptionsString.text = text
      }
      
      @objc func didGetNotification5(_ notification: Notification){
          let text = notification.object as! String?
          BestOption.text = text
      }
      
      @IBAction func SaveHandDryButton(_ sender: UIButton) {
          addHandDryLocation()
      }
      
      @IBOutlet weak var handDryTable: UITableView!
      
      var handDryList = [HandDryModel]()
      
      public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return handDryList.count
      }
      
      public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell&quot;, for: indexPath) as! HandDrySavedTableViewCell
          
          let handDry: HandDryModel
          
          handDry = handDryList[indexPath.row]
          
          cell.locationOfOption.text = handDry.location
          cell.bestOption.text = handDry.best
          cell.optionString.text = handDry.options
          
          return cell
      }
  }
  </code></pre>