Così ho dati in questo modo:Perché questo Firebase ".indexOn" non funziona?
pushNotifications {
-K - RwEgd541PIGNOXXUH: {
message: "Xiaoyu Hugh Hou bid at $900 on your task: New P..."
notifyId: "facebook:10100683829966199"
relatedTask: "-Jzl8XKaxGCv19nIOChm"
timestamp: 1443594566599
} - K - RwpcBlQa04VJT4Bwm: {
message: "Sam Feldt bid at $1100 on your task: New Post g..."
notifyId: "google:1043268349966197"
relatedTask: "-Jzl8XKaxGCv19nIOChm"
timestamp: 1443594721963
} - K - RwuM3 - 0 G0q9I96WHg: {
message: "Sam Feldt bid at $600 on your task: NO Firebase..."
notifyId: "facebook:10100683829966199"
relatedTask: "-JzTSk2TIlO46oVqJ1Nn"
timestamp: 1443594741347
}
}
Nel mio codice, ho bisogno di ottenere l'ultima notifica di seguito per un certo "NotifyID". Ecco il codice:
ref.child('pushNotifications')
.orderByChild("notifyId")
.limitToLast(1)
.on("child_added", function (snapshot) {
console.log("Found a new notification...");
sendPush(snapshot.val());
});
Nella mia regola di sicurezza Firebase, ho questa regola indice:
"pushNotifications": {
".read": "auth != null",
".write": "auth != null",
"$pushId": {
".indexOn": ["notifyId", "timestamp"],
}
},
E 'il seguito struttura di indice dei documenti Firebase qui: docs
Ma quando Eseguo il codice, la console continua a registrare
AVVISO PERICOLO: Utilizzo di un indice non specificato. Considera l'aggiunta di ".indexOn": "notifyId" a/pushNotifications alle tue regole di sicurezza per prestazioni migliori
Che non ha senso poiché l'ho già fatto. Per favore aiuto!
Btw, questo stesso argomento è stato indirizzato meno di un giorno fa qui: htt p: //stackoverflow.com/questions/32849805/firebase-index-rule-for-attributes-under-key-created-by-childautobyid –