I'm currently working on a Firebase cloud function and I need to check the user ID is the same as the currently logged in user before proceeding. How would I be able to check the userID in the node before accessing the posts underneath it.
I've been attempting to use a database trigger as I want to check on write to the database.
So far i've written the function but
exports.sendPushNotification = functions.database.ref('/competitions').onWrite(event => {
const collectionRef = event.data.ref.parent;
snapshot.forEach(function () {
const countRef = collectionRef.parent.child('posts');
});
});
I just don't know how to access the user id as a variable