I am trying to check, if two objects have at least one common child. In the following example I want to be able to be control, if people can read org.money.value.
The right to read is determined by comparing the children of org.keys and users.{auth.uid}.keys. If there is a common key, reading would be allowed.
Database JSON:
{
"org" : {
"keys" : {
"red" : {
"value" : "..."
},
"blue" : {
"value" : "..."
}
},
"money" : {
"value" : "..."
}
},
"users" : {
"John" : { // in reality John == auth.uid of a user
"keys" : {
"red" : {
"value" : "..."
}
}
},
"Alice" : { // in reality Alice == auth.uid of a user
"keys" : {
"green" : {
"value" : "..."
}
}
}
}
}
Rules:
"rules:"{
"org" : {
"money" : {
// can read if "org.keys" and "users.auth.uid.keys"
// have at least one common child name.
// With the above data reading would be allowed for John,
// but not for Alice.
".read" : what to write here?
}
}
}
Is it possible to make this work?
By the way, the organization does not know the auth.uid of users.