【发布时间】:2020-02-22 23:39:33
【问题描述】:
我收到一条错误消息:
FIREBASE 警告:使用未指定的索引。您的数据将在客户端下载和过滤。考虑将 /questions 处的 ".indexOn": "author" 添加到您的安全规则中以获得更好的性能。
我的 Firebase 规则:
"questions": {
".read": true,
".write": true,
".indexOn": ["category,author"]
},
我的 Firebase 数据:
"questions" : {
"-Ls1LfayKF9TUg20ByPE" : {
"question" : "1",
"timestamp" : 1571997530706,
"author" : "9jNkvzr0chgPi0SC6rXMlVWdOF12"
},
"-Ls1Lj_OG4lo11r3WQzF" : {
"question" : "2",
"timestamp" : 1571997546988,
"author" : "9jNkvzr0chgPi0SC6rXMlVWdOF12"
},
我的代码:
const ref = FirebaseRef.child('questions')
ref.orderByChild('author').equalTo(UID).limitToLast(this.state.limit)
.on("child_added", snapshot => {
console.log("FireB ",snapshot)
var items = [];
snapshot.forEach((child) => {
items.push({
key: child.key,
...child.val()
});
});
【问题讨论】:
标签: javascript firebase firebase-realtime-database firebase-security