Firebase当前不支持小写搜索。处理此问题的最佳方法是将小写字符串与原始字符串一起存储,然后查询小写字符串。
var ref_restMenu = firebase.database().ref() .child('Restaurants') .child('Company') .child('menu');var item = "Apple Pie";// Or however you store dataref.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"); }});
这确实需要复制数据,但是到目前为止,还没有一个更容易预见的选项。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)