I have a scenario where I need to fetch specific values under {id} in the .onUpdate() method. Var3 is a nested object, while var2 is a single variable. Is there a way to extract {id} from onUpdate and pass it as an argument to customMethod so that I can utilize it in admin.ref()?
Code snippet from index.ts:
export const funcName = functions.region("someRegion").database.ref('/user/{id}/var3').onUpdate((change, context) =>{
const originalData = <varType> change.after.val();
const processedData = customMethod(originalData);
if(change.after.ref.parent)
return change.after.ref.parent.child('custom').set(processedData);
else
return null;
});
function customMethod(data: varType){
return admin.database().ref('/user/{id}/var2').once('value').then(function(snapshot){
// processing stuff after storing value from var2 in a local variable
}