为什么我会犯这个错误?:
火灾警告:使用未指定的索引。考虑在安全规则中添加".indexOn":“键盘”以获得更好的性能
我的火库里有很多电报键盘
他说:我想纠正这个错误。✔️
他说:我想得到和Console.log rock和rocky当电报用户输入rock,
const ref = db.ref('Keyboards/rock'); //keyboard 1
const ref = db.ref('Keyboards/morning'); //keyboard 2
const ref = db.ref('Keyboards/rocky'); //keyboard 3结构:

规则:
{
"rules": {
".read": true,
".write": true,
"Keyboards" : {
".indexOn": "Keyboards"
}
}
}代码:
const ref = db.ref('/');
ref.child('/').orderByChild('Keyboards').equalTo('rock').on("value", function(snapshot) {
console.log(snapshot.val());
key = snapshot.forEach(function(data) {
console.log(data.key);
});
});发布于 2017-10-15 12:49:44
您正在多次运行相同的查询,每次都由同一个子查询进行排序:Keyboards。Firebase告诉你你可能想索引这个搜索,有点像告诉数据库你要经常这样做,所以准备好了,我会经常做这个搜索。
在这里解释:索引您的数据
可以在项目中设置数据库-> Rules下的索引。
https://stackoverflow.com/questions/46754749
复制相似问题