How to validate queries?

Hello everyone!
I am finishing my app but im stuck in one thing, i need to implement a validation that allow me to know when the register is found and vice-versa. this is my function for consulting a register in my database.

var referenceresultado= this.resultadoref.orderByChild(‘referencia’).equalTo(this.resultado);
referenceresultado.on(‘value’, itemSnapshot => {
this.products = [];
itemSnapshot.forEach( itemSnap => {
return false;



If the app find a register it have to show me a message saying “You got the product” or in other case “You dont got the product”

I build this alert

 let alert = this.alertCtrl.create({
title: ' You got the product',
buttons: ['OK'],


Please help me :slight_smile: