This code is working fine.
The only improvement I want is - when I pass "Pi", it fetch all the items object that begin with the name "Pi", but when I enter "pi" it returns nothing!
This means I want this method startAt(itemName)
to be worked case insensitive. So that should works with anything (lowercase or uppercase) in that case "Pi" or "pi" etc..
//5. Get menu items from RestaurantMenu
this.getMenuItemFromRestaurantMenu = function(callback, itemName) {
var ref_restMenu = firebase.database().ref()
.child('Restaurants')
.child('Company')
.child('menu');
//Check if item is already exist!
ref_restMenu.orderByChild("itemName").startAt(itemName).once("value", function(snapshot) {
var data = snapshot.val();
if(data !== null) {
//We will ger item name and restaurant id from this data.
callback(data);
} else {
//Item not found in globalMenu
console.log("%c Item not found in Global Menu", "color: red");
}
});
}