【发布时间】:2016-11-30 03:56:27
【问题描述】:
这段代码运行良好。
我想要的唯一改进是 - 当我传递“Pi”时,它会获取所有以名称“Pi”开头的项目对象,但是当我输入“pi”时它什么也不返回!
这意味着我希望此方法 startAt(itemName) 不区分大小写。所以这应该适用于任何东西(小写或大写)在这种情况下“Pi”或“pi”等..
//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");
}
});
}
【问题讨论】:
标签: javascript firebase firebase-realtime-database