// comment.schema.json { "bsonType": "object", "required": ["content", "user_id"], "permission": { "read": "doc.status == 'published' || auth.uid == doc.user_id", "create": "auth.uid != null", "update": "auth.uid == doc.user_id || 'admin' in auth.role", "delete": "auth.uid == doc.user_id || 'admin' in auth.role" }, "properties": { "_id": { "description": "评论ID,系统自动生成", "foreignKey": "opendb-comment._id" }, "parent_id": { "bsonType": "string", "title": "父评论ID", "description": "用于嵌套评论", "foreignKey": "opendb-comment._id", "defaultValue": "" }, "user_id": { "bsonType": "string", "title": "用户ID", "description": "关联uni-id-users表", "forceDefaultValue": { "env": "uid" }, "foreignKey": "uni-id-users._id" }, "content": { "bsonType": "string", "title": "评论内容", "minLength": 1, "maxLength": 500, "trim": "both" }, "like_count": { "bsonType": "int", "title": "点赞数", "minimum": 0, "defaultValue": 0 }, "create_time": { "bsonType": "timestamp", "title": "创建时间", "defaultValue": { "env": "now" } }, "update_time": { "bsonType": "timestamp", "title": "更新时间", "defaultValue": { "env": "now" } }, "status": { "bsonType": "string", "title": "状态", "enum": [ {"value": "draft", "text": "草稿"}, {"value": "published", "text": "已发布"}, {"value": "deleted", "text": "已删除"} ], "defaultValue": "published" } }, "indexes": [ { "name": "parent_id_index", "fields": [{ "field": "parent_id", "order": "asc" }] }, { "name": "user_index", "fields": [{ "field": "user_id", "order": "asc" }] } ] }