Cannot read property 'previous' of undefined : <p>Functions in firebase throws me this error:</p>

<pre><code>TypeError: Cannot read property 'previous' of undefined
at exports.sendNotifications.functions.database.ref.onWrite (/srv/index.js:5:19)
at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:131:23)
at /worker/worker.js:825:24
at &lt;anonymous&gt;
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
</code></pre>

<p>And my code is this:</p>

<pre><code>exports.sendNotifications=functions.database.ref('/notifications/{notificationId}').onWrite((event)=&gt;{
if(event.data.previous.val()){
  return;
}
if(!event.data.exists()){
  return;
}
})
</code></pre>

<p>Any idea how to fix this?</p>
