opendb-news-comments.schema.json 1.8 KB

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