Unclear About This Use Case On Firebase Cloud Functions

I am working on some feature using firebase and I need to send notification to the user on this scenario:

First-> User registers a value (not unique) let's say ABCDEFG which can also be registered by another user. So I save this in a table in Firebase Realtime Db.

Second -> I have another table which one of the fields is the field mentioned on the first step (so relation is many to many)

Third -> Once a new record is inserted, on my second step table, I want to send notification only to users which have this ABCDEFG field.

I don't really care who added the record, I just care that if that ABCDEFG is mentioned on the table, I want to send message to the user who has this one saved.

How can I achieve this in Firebase Cloud Messaging?

Optional: I prefer not to make a login to user at all, is it doable in this case?



You can do this using Firebase Functions. Create a Trigger function that listens for data to be added to your database. In your case, onCreate would work - when a record is created in the database, your function would then run a query to find the matching records and send out your message (email via Sendgrid, push notification, whatever).

No login needed, though you may want to consider it so you get the correct details of whomever you're sending messages to.