Currently, I am utilizing the Firebase real-time database and attempting to establish a trigger for when a field named ignore
is added to my DB. However, before proceeding with this trigger, I need to access another set of data within the database in order to incorporate it into my function. The function I have written looks something like this:
exports.dbTest2 = functions.database.ref('/{uid}/ignore')
.onCreate((snapshot, context) => {
const uid = context.params.uid
console.log(`Current User ${uid}`)
// Grasping the newly added data from the specified location
const ignoreData = snapshot.val()
const endTime = new Date(ignoreData.endTime).toString()
const scheduleRef = snapshot.ref.parent.child('schedule')
console.log(scheduleRef)
let scheduleArr = [ /*something*/ ]
return snapshot.ref.parent.child('schedule').set(scheduleArr)
});
Here's how my database structure appears:
https://i.sstatic.net/iOaNE.png
From the reference path {uid}/ignore
, my objective is to obtain the first element present at the schedule
reference (highlighted in the image provided). While debugging the code above, I attempted to log the reference but couldn't find a direct way to retrieve the value from that object.
Is there any approach to accessing the object highlighted in the image within my cloud function?