title: Firebase real time database access data array from deleted node
body: <p>I am deleting a FRTDB node, I want to access deleted data from that node. the functions looks as follow:</p>
  <pre><code>exports.events = functions.database.ref('/events/{eventId}').onWrite(async (change, context) =&gt; {
    const eventId = context.params.eventId
    if (!change.after.exists() &amp;&amp; change.before.exists()) {
      //data removed
      return Promise.all([admin.database().ref(`/events/${eventId}/dayofweek`).once('value')]).then(n =&gt; {
        const pms = []
        const days = n[0]
        days.forEach(x =&gt; {
          pms.push(admin.database().ref(`${change.before.val().active ? 'active' : 'inactive'}/${x.key}/${eventId}`).set(null))
        })
        return Promise.all(pms)
      });
     else {
      return null;
    }
  })
  </code></pre>
  <p>The probem I am having is that</p>
  <blockquote>
  <p>admin.database().ref(`/events/${eventId}/dayofweek</p>
  </blockquote>
  <p>do not loop the data because it seems data is no longer there so the forEach is not working. How can I get access to this data and get to loop the deleted data?</p>