0
我有一些文章。如何限制寫入Firestore中用戶擁有的文檔?
每篇文章都有一個參考場給誰寫的特定文章作者的個人資料文件。
Auth'd用戶(使用Firebase的身份驗證)將與這些配置文件關聯。
只有當該用戶擁有該文章時,我如何才能使這些文章可由當前登錄的用戶編輯?
在公司的FireStore的文檔,有一個重複的例子:
service cloud.firestore {
match /databases/{database}/documents {
// Allows you to edit the current user document (like a user's profile).
match /users/{userId} {
allow read, write: if request.auth.uid == userId;
}
// Allows you to read/write messages as long as you're logged in (doesn't matter who you're logged in as, so theoretically you could change other peoples' messages).
match /rooms/{roomId} {
match /messages/{messageId} {
allow read, write: if request.auth != null;
}
}
}
}
哪裏是如何組織和編輯由特定用戶所擁有的文件的例子嗎?
我的文章文檔沒有'老闆:',它有'主人:<引用到另一個文檔>'(即'firestore.googleapis.com/project/XXXXXXXXX-eb000 /數據庫/(默認)/文件/用戶/ ajsidjasidjsaidjasidasj')。參考_contains_ uid。 –
corysimmons
Fwiw,我正在嘗試你正在提議的內容,但它似乎不適用於參考。我懷疑我需要做一些'get()'的東西,但不能得到正確的語法...... :( – corysimmons
當處理用戶信息時,我建議將uid存儲爲字符串,只要你想參考確切的原因是一個業主 - 也許有辦法做到這一點,否則,但我不知道如何工作。 –