I'm trying to share data between two accounts (literally children's data with multiple parents). Here's my data structure:
{
"children" : {
"1633465800166" : {
"name" : "Malcolm",
"parents" : {
"123456789123456789" : true,
"987654321987654321" : true
}
}
}
}
I've started setting up my DB rules to allow the first parent to create the node, then add an additional parent, then make that parent read/write supported:
"children":{
"$childid":{
// Data doesn't already exist
// AND newData has a child called parents
// AND parents has a uid in it that matches the current parent
".write": "(
!data.exists()
&& newData.hasChild('parents')
&& newData.child('parents').hasChild(auth.uid))
// OR the data exists,
// AND one of the parents is the current parent
|| (
data.exists()
&& data.child('parents').hasChild(auth.uid)
)",
// one of the parents is the current parent
".read":"data.child('parents').hasChild(auth.uid)
// ???
&& query.orderByChild == 'parents'
&& query.equalTo == auth.uid
"
}
}
Every tutorial I've seen about this has a single node, not a group of nodes. How do I share ownership this way?