I have the following structure:
events
-LEe7X118dkcH2JhJRe
description: "Testdescr"
eventTasks
participants
0zlwpSlCazNGjOyMi95h8awshrG2
lastLogin: 1528641494535
userKey: "0zlwpSlCazNGjOyMi95h8awshrG2"
username: "User1"
6LnYKxRu2SWUrxwIzId8dDpOrl02
lastLogin: 152856590172
userKey: "6LnYKxRu2SWUrxwIzId8dDpOrl02"
username: "User2"
I want to query all events, to which an user participants (like a filter). My Java-Code is:
mDatabaseReference = FirebaseDatabase.getInstance().getReference("event");
mDatabaseReference.orderByChild("participants/"+userId+"/userKey").equalTo(userId).addChildEventListener [...]
This works like a charm - i only receive the correct events.
Now i want to create query-based rules on server side (https://firebase.google.com/docs/database/security/securing-data). So i created a read rule like:
".read": "query.orderByChild == 'participants/'+auth.uid+'/userKey' && query.equalTo == auth.uid"
Problem: i am not able to save that rule. Firebase gives me the error: "Invalid == expression: right operand must be an ordering or string literal when comparing against an ordering.". Why is it not possible to use "query.orderByChild" in combination with auth.uid?
What am i doing wrong?
EDIT: Here are my complete rules:
{
"rules": {
".write": true,
"event":{
".read": "query.orderByChild == 'participants/'+auth.uid+'/userKey' && query.equalTo == auth.uid"
}
}
}