Some please consider a solution for me,
This is my database:

Am trying to get how many users "referralcode" match any users "refercode", For example, this first user "refercode:" is "Fhb0VP7xje97" I want to know how many users from the whole database has this referral code in their "referralcode" value, and save the number to the "referno" value, so that the number of people referred by users would be visible to the user, so far I have tried this
Var referralcode=snapshot.val().referralcode;
Var refercode=snapshot.val().refercode;
const ref = firebase.database().ref('users');
const query = ref.orderByChild('referralcode').equalTo('refercode').get().then((results) => {
console.log(Object.keys(results.val()).length);
results.forEach((snapshot) => {
console.log(snapshot.key, snapshot.val());
});
});
Please can someone tell me what to do specifically?