From fdac3feb1d7645f6dacb72630a81e3da7564b1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E7=BA=A2=E4=BF=9D?= Date: Tue, 27 Oct 2020 18:21:58 +0800 Subject: [PATCH] add permission --- collection/opendb-mall-categories/collection.json | 6 ++++++ collection/opendb-mall-comments/collection.json | 6 ++++++ collection/opendb-news-comments/collection.json | 5 ++++- collection/opendb-search-hot/collection.json | 6 ++++++ collection/opendb-search-log/collection.json | 8 +++++++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/collection/opendb-mall-categories/collection.json b/collection/opendb-mall-categories/collection.json index b4e5efa..6c72e17 100644 --- a/collection/opendb-mall-categories/collection.json +++ b/collection/opendb-mall-categories/collection.json @@ -2,6 +2,12 @@ "schema": { "bsonType": "object", "required": ["name"], + "permission": { + ".read": true, + ".create": false, + ".update": false, + ".delete": false + }, "properties": { "_id": { "description": "存储文档 ID(文章 ID),系统自动生成" diff --git a/collection/opendb-mall-comments/collection.json b/collection/opendb-mall-comments/collection.json index a3ebfa3..bc31000 100644 --- a/collection/opendb-mall-comments/collection.json +++ b/collection/opendb-mall-comments/collection.json @@ -2,6 +2,12 @@ "schema": { "bsonType": "object", "required": ["goods_id", "user_id", "content"], + "permission": { + ".read": true, + ".create": "auth.uid != null", + ".update": "doc.user_id == auth.uid", + ".delete": "doc.user_id == auth.uid" + }, "properties": { "_id": { "description": "存储文档 ID(文章 ID),系统自动生成" diff --git a/collection/opendb-news-comments/collection.json b/collection/opendb-news-comments/collection.json index 4401d46..64c942d 100644 --- a/collection/opendb-news-comments/collection.json +++ b/collection/opendb-news-comments/collection.json @@ -18,7 +18,10 @@ }, "user_id": { "bsonType": "string", - "description": "评论者ID,参考`uni-id-users` 表" + "description": "评论者ID,参考`uni-id-users` 表", + "forceDefaultValue": { + "$env": "uid" + } }, "comment_content": { "bsonType": "string", diff --git a/collection/opendb-search-hot/collection.json b/collection/opendb-search-hot/collection.json index 8c06238..affbce6 100644 --- a/collection/opendb-search-hot/collection.json +++ b/collection/opendb-search-hot/collection.json @@ -2,6 +2,12 @@ "schema": { "bsonType": "object", "required": ["content", "count"], + "permission": { + ".read": true, + ".create": false, + ".update": false, + ".delete": false + }, "properties": { "_id": { "description": "ID,系统自动生成" diff --git a/collection/opendb-search-log/collection.json b/collection/opendb-search-log/collection.json index e46deba..ed86473 100644 --- a/collection/opendb-search-log/collection.json +++ b/collection/opendb-search-log/collection.json @@ -1,7 +1,13 @@ { "schema": { "bsonType": "object", - "required": ["user_id", "content"], + "required": ["content"], + "permission": { + ".read": false, + ".create": false, + ".update": false, + ".delete": false + }, "properties": { "_id": { "description": "ID,系统自动生成"