opendb-news-comments.schema.json 1.8 KB
Newer Older
雪洛's avatar
雪洛 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
{
	"bsonType": "object",
	"required": ["article_id", "user_id", "comment_content", "like_count", "comment_type", "reply_user_id",
		"reply_comment_id"
	],
	"permission": {
		"read": true,
		"create": "auth.uid != null && get(`database.opendb-news-article.${doc.article_id}`).comment_status == 1",
		"update": "doc.user_id == auth.uid",
		"delete": "doc.user_id == auth.uid"
	},
	"properties": {
		"_id": {
			"description": "存储文档 ID(文章 ID),系统自动生成"
		},
		"article_id": {
			"bsonType": "string",
			"description": "文章ID,opendb-news-posts 表中的`_id`字段",
			"foreignKey": "opendb-news-articles._id"
		},
		"user_id": {
			"bsonType": "string",
			"description": "评论者ID,参考`uni-id-users` 表",
			"forceDefaultValue": {
				"$env": "uid"
			},
			"foreignKey": "uni-id-users._id"
		},
		"comment_content": {
			"bsonType": "string",
			"description": "评论内容",
			"title": "评论内容",
			"trim": "right"
		},
		"like_count": {
			"bsonType": "int",
			"description": "评论喜欢数、点赞数"
		},
		"comment_type": {
			"bsonType": "int",
			"description": "回复类型: 0 针对文章的回复  1 针对评论的回复"
		},
		"reply_user_id": {
			"bsonType": "string",
			"description": "被回复的评论用户ID,comment_type为1时有效",
			"foreignKey": "uni-id-users._id"
		},
		"reply_comment_id": {
			"bsonType": "string",
			"description": "被回复的评论ID,comment_type为1时有效",
			"foreignKey": "opendb-news-comments._id"
		},
		"comment_date": {
			"bsonType": "timestamp",
			"description": "评论发表时间",
			"forceDefaultValue": {
				"$env": "now"
			}
		},
		"comment_ip": {
			"bsonType": "string",
			"description": "评论发表时 IP 地址",
			"forceDefaultValue": {
				"$env": "clientIP"
			}
		}
	}
}