第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

firebase查詢方法startAt()采用區(qū)分大小寫的參數(shù)

firebase查詢方法startAt()采用區(qū)分大小寫的參數(shù)

拉風的咖菲貓 2019-12-05 14:38:10
這段代碼工作正常。我想要的唯一改進是 -當我傳遞“ Pi”時,它將獲取所有以“ Pi”名稱開頭的項目對象,但是當我輸入“ pi”時,它什么也不返回!這意味著我希望此方法startAt(itemName)不區(qū)分大小寫。因此,在那種情況下,“ Pi”或“ pi”等任何東西(小寫或大寫)都可以使用。//5. Get menu items from RestaurantMenuthis.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");    }  });}
查看完整描述

1 回答

?
慕標琳琳

TA貢獻1830條經(jīng)驗 獲得超9個贊

Firebase當前不支持小寫搜索。處理此問題的最佳方法是將小寫字符串與原始字符串一起存儲,然后查詢小寫字符串。


var ref_restMenu = firebase.database().ref()

    .child('Restaurants')

    .child('Company')

    .child('menu');

var item = "Apple Pie";

// Or however you store data

ref.push({

    itemName: item,

    itemNameLower: item.toLowerCase(),

    ...

})

然后您可以這樣查詢:


//Check if item is already exist!

// query itemNameLoweruse and .toLowerCase()

ref_restMenu.orderByChild("itemNameLower").startAt(itemName.toLowerCase()).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");

    }

});

這確實需要復制數(shù)據(jù),但是到目前為止,還沒有一個更容易預見的選項。


查看完整回答
反對 回復 2019-12-05
  • 1 回答
  • 0 關(guān)注
  • 267 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號