I have the following function:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.myFunction = functions.database.ref('/my_node/{myId}/status').onCreate(event => {
const data = event.data.val();
if (data == 'STATE01') {
return event.data.ref.set('STATE02');
}
});
I'm using onCreate
, so the function should only be called once, not twice. Why is this happening?
See the logs:
9: 29: 27.975 PM myFunction Function execution took 33 ms, finished with status: 'ok'
9: 29: 27.943 PM myFunction Function execution started
9: 29: 27.875 PM myFunction Function execution took 1059 ms, finished with status: 'ok'
9: 29: 26.818 PM myFunction Function execution started