I'm working on an app using Firebase. I have the following data structure on Firebase:
{
rules: {
"version": {
"threads": {
"$thread": {
"noticeList": {
".read": true,
".write": true
},
"messages": {
".read": "root.child('version/threads/' + $thread + '/users/' + auth.uid).exists()",
".write": "root.child('version/threads/' + $thread + '/users/' + auth.uid).exists()"
},
"$other": {
".read": "auth != null",
".write": "auth != null"
}
}
}
}
}
Each thread has subnode /users/
and I want to make a rule that only included users can read and write the messages in that thread.
There are one more condition that I have to access to noticeList
when the new messages are added. However, these rules do not work. If there are other node rules in the '$thread', I couldn't get any respond when I used
firebase.child("version/threads/" + $thread + "/noticeList").once("value", function(snapshot) {});
or
firebase.child("version/threads").once("value", function(snapshot) {});
How can I fix it?
Thanks