title: FIREBASE Database - Storing Unique Key to child node(Swift/IOS)
body: <p>I am attempting to store the generated <strong>Unique Key</strong> when childByAutoId is called. In theory it would help map updates or changes on a specified child that need to happen later on in my app. </p>
  
  <p>I am fairly new to Firebase's hierarchical database and if the approach described below isn't correct please do not hesitate to give an alternative. </p>
  
  <p>I'm fairly new to Firebase and have a multiplayer app, where my structure currently looks like the following:</p>
  
  <pre><code>"HTGames" : {
  
  "-KFGX5H3rLSnpPvupakm" : {
    {
      "Red" : 1,
      "Green" : 3,
      "Blue" : 2,
      "GameLimit" : 1,
      "P1Name" : 3,
      "P2Name" : 2,
      "P3Name" : 1,
      "P1Points" : 3,
      "P2Points" : 2,
      "P3Points": 3,
      "numberOfPlayers" : 1.
      "gameStart": true
    }
  },
     "-X5Hhgljh3rLSnpPvum" : {
    {
      "Red" : 1,
      "Green" : 3,
      "Blue" : 2,
      "GameLimit" : 1,
      "P1Name" : 3,
      "P2Name" : 2,
      "P3Name" : 1,
      "P1Points" : 3,
      "P2Points" : 2,
      "P3Points": 3,
      "numberOfPlayers" : 1.
      "gameStart": true
    }}}
  }
  </code></pre>
  
  <p>Swift method call below...</p>
  
  <pre><code>func startNewGame(){
  //Database reference object
      let databaseRef = FIRDatabase.database().reference()
  
      let gameTable : [String : AnyObject] = ["Green": "", "Red": "", "Blue": "", "GameTypePoint": "","P1Name": "",  "P2Name": "", "P3Name": "", "P1Points": "","P2Points": "", "P3Points": "","NumOfPlayers": "","GameStart": ""]
  
  //Auto generates unique ID and creates child under "HTGame" parent
      databaseRef.child("HTGame").childByAutoId().setValue(gameTable)
  
  //**********I would like to store key locally here*********//
      //let key =
  }
  </code></pre>