title: How to get the key of a child value with Cloud Functions for Firebase?
body: <p>I have code that triggers when a user_course is added</p>
  
  <pre><code>export const writePesertaMatkul = functions.database
  .ref('/user_course/{user_uid}/') // query child yg dipantau
  .onCreate((snapsot, context) =&gt; {   // on create trigered
      const user_uid = context.params.user_uid;
      const matkulData = snapsot.val(); //dataSnapshot
  
      });
  </code></pre>
  
  <p>The log value is <code>{ courses_5: 'PEMROGRAMAN GUI' }</code> its doing great, but one problem here. I just want to store <code>courses_5</code>. How to achieve it?</p>
  
  <p>SOLUTION</p>
  
  <pre><code>export const writePesertaMatkul = functions.database
  .ref('/user_course/{user_uid}/{matkul_id}') // query child yg dipantau
  .onCreate((snapsot, context) =&gt; {   // on create trigered
      const user_uid = context.params.user_uid;
      const matkulData = snapsot.val(); //dataSnapshot
      const matkulID = context.params.matkul_id;
  
  
      // const matkulKey = snapsot.key;
      console.log("keynya :", snapsot.key);
      console.log("uidnya  :", user_uid);
  
  
      const updates = {}; 
      updates[snapsot.key + "/" + user_uid] = "true";
  
      return admin.database().ref('/course_peserta/').update(updates);;
      });
  </code></pre>
  
  <p>use this code for get the parent <code>snapsot.key</code></p>