I am using the firebase functions on the firebase database to try and pull data but I am not being successful.
The data I want to search is structured like this:
The logic of what I want to do is the following: when a record is written to the 'jobs' collection, I want to then search the 'status' collection for availableStatus (stored as true/false).
For records that are true, I need to get the push IDs ('__zone_symbol__value') which are stored in the same 'status' collection.
In the path to the data I am after, there are two items that I will not know and need to use a wildcard, {time} and {uId}.
Here is my code I am using:
exports.notifyPeople = functions.database.ref('/jobs/{uId}/status')
.onWrite(event => {
var dbRead = admin.database().ref('status/worker/{time}/{uId}/pushToken').orderByChild('availableStatus').equalTo('true').on("child_added", function(snapshot) {
console.log(snapshot.val());
});
const getPushTokens = dbRead.child;
}
What am I doing wrong?