0

I have created the following functions:

It has been deployed and is there on the firebase hosting, but it just doesn't ever get called (usage is 0)...

It should be called when a user document is changed and then update a field to null if it wasn't already null.

Can anyone see why this is not running?

exports.deleteField = functions.database.ref('/Users/{userID}') .onUpdate((change, context) => { const overrideTag = change.after.data().overrideTag if (overrideTag !== null) { const db = admin.firestore() db.collection('Users').doc(userID).set({ overrideTag: null }) } }) 

Kind Regards, Josh

3
  • Please edit the question to be very specific about what you're doing that should trigger this function. It's not possible to see just from the code why it's not being triggered. Commented Apr 6, 2020 at 19:52
  • As I have said above, the function should be trigger when a document in Users is changed. Commented Apr 6, 2020 at 19:54
  • In the absence of specific information, I can only take a guess. Ideally, your question includes the specific steps you take to modify the document, perhaps also showing a screenshot of what it is you're working with. Commented Apr 6, 2020 at 19:57

1 Answer 1

1

Your function is configured to trigger on changes to a node called "Users" in Realtime Database. Realtime Database doesn't have "documents". However, Firestore does have documents. If you meant to trigger when a document is changed in Firestore, you will have to write a Firestore trigger instead. It will use functions.firestore instead of functions.database.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your response, clearly was enough detail as this gave me the answer.
So, we still needed to know that you were adding the document to the correct collection - that is also a common mistake. It's never a bad idea to be very specific. Screenshots help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.