我想在两个用户之间创建一个“聊天”集合,以允许他们两个都访问同一集合。集合是其Firestore用户ID(“ UID1_UID2”)的组合集合。因此,我将安全规则写为:
match /chats/{combinedUserIDs}/messages{
allow update, read: if request.auth != null && request.auth.uid == combinedUserIDs[0:27];
allow update, read: if request.auth != null && request.auth.uid == combinedUserIDs[29:56];
}
我尝试按子字符串进行匹配,但这些字符串不起作用,并且被拒绝了。我可以像这样将参数与子字符串匹配吗?
来自Flutter的呼叫的客户端代码(如果将规则设置为所有经过身份验证的用户,则可以正常工作):
await firestore
.collection('chats')
.document(orderedUserIDs)
.collection('messages')
.orderBy('timestamp', descending: true)
.limit(documentLimit)
.getDocuments();