I am a newbie in cloud functions. I am trying to access my values. But there are 2 problems. First of all, When I am trying to run my function ( also, My other functions have this problem) My console gives me the same results that ran before.
Such as:
The first function = Gives me an apple
I run it.
The second function = Gives me a banana.
I run it.
Result: it gives me an apple. After that I am starting again my function that's time gives me a banana.
How can I fix it?
Also, Here is my main question:
exports.scheduleremindernotifications = functions.database.ref('/users/{userId}/name').onCreate((snapshot, context) => {
const usersRef = admin.database().ref('users');
usersRef.once('value', (snapshot) => {
snapshot.forEach((childSnapshot) => {
const userId = childSnapshot.key;
const consumingRef = admin.database().ref(`users/${userId}/missions`);
consumingRef.once('value', (snapshot) => {
snapshot.forEach((childSnapshot) => {
const missions_keys = childSnapshot.key;
// Start at time elde ettik.
const startatref = admin.database().ref(`users/${userId}/missions/${missions_keys}/startat`);
startatref.once('value', (snapshot) => {
snapshot.forEach((childSnapshot) => {
const notification_time = childSnapshot.val;
// I want to access all my startat' values. And I want to show them in my console.
console.log(`${notification_time}`);
});
});
Also here is my realtime database structure:
How can I show my values? I want to access "startat" values. And showing to my console. How can I fix it?