8
此代碼工作正常!firebase查詢方法startAt()考慮區分大小寫參數
我想唯一的改進是 - 當我通過「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");
}
});
}
謝謝,這幫了我! –
這個問題是當你想顯示用戶註冊的方式時。 – EduardoMaia
然後顯示非小寫版本。你只能用小寫查詢,這並不意味着你需要提交它。 – theblindprophet