firestore配置

## Firestore配置 ``` rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { function signedInAndIsOwner() { return request.auth.uid != null && resource.data.id == request.auth.uid; } match /users/{user_id}{ // if auth and is the owner of the document allow read, write: if request.auth.uid != null && user_id == request.auth.uid; // if auth and (is the member of the house or is the owner of the house) match /houses/{house_id}/{document=**} { allow read, write: if request.auth.uid != null && (exists(/databases/$(database)/documents/users/$(request.auth.uid)/joinHouses/$(house_id)) || user_id == request.auth.uid); } } } } # user_1是house_1的owner /users/<user_1>/houses/<house_1>/... # user_1发起邀请 user_2成为其家庭的成员 # 如果 user_2加入了 user_1的 house_1,成为其家庭成员 /users/<user_2>/joinHouses/<house_1>/... - owner = user_1 后台 watch joinHouses的新增与删除: 当发生新增时,获取 house_id以及house的owner_id,user_2的id以及其nickName/email,找到对应owner的house document,更新其members字段。此处为新增 item <user_2> /users/<user_1>/houses/<house_1>/... - members = {"<user_2>": {"nickName": "xxxx", "emailAddress": "xxx"}, "<user_3>": {"nickName": "xxx", "emailAddress": "xxx"}} ``` https://firebase.google.com/docs/auth/admin/manage-users#python ![image.png](https://cos.easydoc.net/21942958/files/kfrqnurn.png) ![image.png](https://cos.easydoc.net/21942958/files/kfrqof7v.png)