通过将数组与firebase安全规则中的数组进行比较,在firebase中设置分层规则

通过将数组与firebase安全规则中的数组进行比较,在firebase中设置分层规则,firebase,firebase-realtime-database,firebase-authentication,firebase-security,Firebase,Firebase Realtime Database,Firebase Authentication,Firebase Security,我正在使用firebase对我的应用程序进行实时聊天。登录是基于用户ID的。因此auth.uid就是这个用户ID。一个用户拥有许多配置文件(比如他的家庭成员),一个配置文件可以属于多个用户(比如一个孩子的配置文件可以属于他的父亲和母亲)。现在聊天总是代表个人资料(即父亲和妻子可以代表他们的儿子发送聊天信息)。我想为此聊天设置安全规则。 我面临的问题是 只有其配置文件创建了聊天信息的用户才能编辑该信息。我无法设置此安全性,因为我必须将数组与必须在firebase不允许的安全规则中为其编写函数的数组

我正在使用firebase对我的应用程序进行实时聊天。登录是基于用户ID的。因此auth.uid就是这个用户ID。一个用户拥有许多配置文件(比如他的家庭成员),一个配置文件可以属于多个用户(比如一个孩子的配置文件可以属于他的父亲和母亲)。现在聊天总是代表个人资料(即父亲和妻子可以代表他们的儿子发送聊天信息)。我想为此聊天设置安全规则。 我面临的问题是

只有其配置文件创建了聊天信息的用户才能编辑该信息。我无法设置此安全性,因为我必须将数组与必须在firebase不允许的安全规则中为其编写函数的数组进行比较

Users:{
    userIdOfVed:{
        profiles:{
            userProfileIdOfVedSon:{
                profileId:userProfileIdOfVedSon,
                relation:son
            },
            __:{...},
            __:{...},
            ...
        }
    },
    __:{...},
    __:{...},
    ...
}


Profiles:{
    userProfileIdOfVedSon:{
        chats:{
            chatRoom1Id:{
                caseId:case32Id,
                chatRoomId:chatRoom1Id
            },
            chatRoom3Id:{
                caseId:case42Id,
                chatRoomId:chatRoom3Id
            }
        }
        //...Other user data(like email, phone no.) which might be required
    },
    __:{...},
    __:{...},
    ...
}

ChatMetadata:{
    chatRoom1Id:{
        createdOn:ISODate("2017-04-13T11:25:35.668Z"),
        members:{
            userProfileIdOfVedSon:{
                userProfileId:userProfileIdOfVedSon
            },
            __:{...},
            __:{...},
            ...
        },
        users:{},//I want to avoid putting this field as least as possible, but if its very critical for setting security, then there is no avoiding it.
        caseId:case32Id,
        lastMessage:"hello world"
        //...Other chat meta data(like last message,etc) which might be required
    },
    __:{...},
    __:{...},
    ...
}

Chats:{
    chatRoom1Id:{
        message1Id:{ //these are randomly generated messageIds by firebase
            userId:userIdOfVed,
            userProfileId:1,
            message:"hello world",
            timestamp:1459361875337 //can be replaced by a standard date time format
        },
        message2Id:{...},
        message3Id:{...}
    },
    chatRoom2Id:{
        message34Id:{...},
        message69Id:{...}
    }
}


//Rules for reading the realtime database
//The list of profiles can be put in the payload of the auth token (auth.profiles) which is not implemented yet
Users:{
    $userId:{ //A user can only read/write/modify his $userId key-value object
        "./read": "$userId == auth.uid"
    }
}
Profiles:{
    $profileId:{ //Can be read/write/modified by  Users who have access to this profiles. 
        ".read": "root.child('Users').child(auth.uid).child('profiles').child($profileId).exists()"
    }
}
ChatMetaData:{
    $chatRoomId:{ //Only the profiles who are present in its "members" keys can read it and a profile can only modify his $profileId entry in "members".
        ".read": "data.child('users').child(auth.uid).exists()"
    }
}
Chats:{
    $chatRoomId:{ //Only the profiles who are present in "ChatMetadata.$chatRoodId.members" keys can read it and push new values in it.(optional: modification to a child can be done only if that profile belongs to "ChatMetadata.$chatRoodId.members" & his profileId==the child.profileId)
        ".read":"I AM UNABLE TO FIGURE OUT THIS RULE, AS FIREBASE DOES NOT ALLOW FUNCTIONS INSIDE THIS."
    }
}

TL;DR:我是否可以将数组与firebase安全规则中的数组进行比较以设置分层规则

firebase不会在其数据库中存储数组:我们是否可以在不使用数组的情况下解决此问题?