Here's the rules that I have:
{
"rules": {
"deck":{
".read":true,
".write":true,
".indexOn": "user"
}
}
}
Currently when I run:
deckRef.once('value', function(dataSnapshot) {
console.log(dataSnapshot.ref());
});
I get all my data returned:
{
"deck" : {
"-JkpwAnieKjQVsdtPD4m" : {
"deckName" : "Deck 1",
"user" : "simplelogin:1"
},
"-Jkq4unexm-qwhO_U2YO" : {
"deckName" : "Deck 2",
"user" : "simplelogin:1"
},
"-Jkq5-II1q5yM6w3ytmG" : {
"deckName" : "Deck 3",
"user" : "simplelogin:6"
},
"-Jks5mbMHmPB9MwnnOCj" : {
"deckName" : "Deck 4",
"user" : "simplelogin:1"
}
}
}
But I want to prevent anyone from accessing the items that don't match the user id.
I tried changing the deck portion to:
"deck": {
".read":"data.child('user').val() === auth.uid"
}
But this returns nothing. Ideally I'd like it to return just items 1,2 and 4 if user "simplelogin:1" in logged in or item 3 if "simplelogin:6" is logged in.