opendb-news-articles.schema.json 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. {
  2. "bsonType": "object",
  3. "required": ["user_id", "title", "content"],
  4. "permission": {
  5. "read": "doc.user_id == auth.uid && doc.article_status == 0 || doc.article_status == 1",
  6. "create": "auth.uid != null",
  7. "update": "doc.user_id == auth.uid",
  8. "delete": "doc.user_id == auth.uid"
  9. },
  10. "properties": {
  11. "_id": {
  12. "description": "存储文档 ID(用户 ID),系统自动生成"
  13. },
  14. "user_id": {
  15. "bsonType": "string",
  16. "description": "文章作者ID, 参考`uni-id-users` 表",
  17. "foreignKey": "uni-id-users._id",
  18. "defaultValue": {
  19. "$env": "uid"
  20. }
  21. },
  22. "category_id": {
  23. "bsonType": "string",
  24. "title": "分类",
  25. "description": "分类 id,参考`uni-news-categories`表",
  26. "foreignKey": "opendb-news-categories._id",
  27. "enum": {
  28. "collection": "opendb-news-categories",
  29. "field": "name as text, _id as value"
  30. }
  31. },
  32. "title": {
  33. "bsonType": "string",
  34. "title": "标题",
  35. "description": "标题",
  36. "label": "标题",
  37. "trim": "both"
  38. },
  39. "content": {
  40. "bsonType": "string",
  41. "title": "文章内容",
  42. "description": "文章内容",
  43. "label": "文章内容",
  44. "trim": "right"
  45. },
  46. "excerpt": {
  47. "bsonType": "string",
  48. "title": "文章摘录",
  49. "description": "文章摘录",
  50. "label": "摘要",
  51. "trim": "both"
  52. },
  53. "article_status": {
  54. "bsonType": "int",
  55. "title": "文章状态",
  56. "description": "文章状态:0 草稿箱 1 已发布",
  57. "defaultValue": 0,
  58. "enum": [{
  59. "value": 0,
  60. "text": "草稿箱"
  61. }, {
  62. "value": 1,
  63. "text": "已发布"
  64. }]
  65. },
  66. "view_count": {
  67. "bsonType": "int",
  68. "title": "阅读数量",
  69. "description": "阅读数量",
  70. "permission": {
  71. "write": false
  72. }
  73. },
  74. "like_count": {
  75. "bsonType": "int",
  76. "description": "喜欢数、点赞数",
  77. "permission": {
  78. "write": false
  79. }
  80. },
  81. "is_sticky": {
  82. "bsonType": "bool",
  83. "title": "是否置顶",
  84. "description": "是否置顶",
  85. "permission": {
  86. "write": false
  87. }
  88. },
  89. "is_essence": {
  90. "bsonType": "bool",
  91. "title": "阅读加精",
  92. "description": "阅读加精",
  93. "permission": {
  94. "write": false
  95. }
  96. },
  97. "comment_status": {
  98. "bsonType": "int",
  99. "title": "开放评论",
  100. "description": "评论状态:0 关闭 1 开放",
  101. "enum": [{
  102. "value": 0,
  103. "text": "关闭"
  104. }, {
  105. "value": 1,
  106. "text": "开放"
  107. }]
  108. },
  109. "comment_count": {
  110. "bsonType": "int",
  111. "description": "评论数量",
  112. "permission": {
  113. "write": false
  114. }
  115. },
  116. "last_comment_user_id": {
  117. "bsonType": "string",
  118. "description": "最后回复用户 id,参考`uni-id-users` 表",
  119. "foreignKey": "uni-id-users._id"
  120. },
  121. "avatar": {
  122. "bsonType": "string",
  123. "title": "封面大图",
  124. "description": "缩略图地址",
  125. "label": "封面大图",
  126. "trim": "both"
  127. },
  128. "publish_date": {
  129. "bsonType": "timestamp",
  130. "title": "发表时间",
  131. "description": "发表时间",
  132. "defaultValue": {
  133. "$env": "now"
  134. }
  135. },
  136. "publish_ip": {
  137. "bsonType": "string",
  138. "title": "发布文章时IP地址",
  139. "description": "发表时 IP 地址",
  140. "forceDefaultValue": {
  141. "$env": "clientIP"
  142. }
  143. },
  144. "last_modify_date": {
  145. "bsonType": "timestamp",
  146. "title": "最后修改时间",
  147. "description": "最后修改时间",
  148. "defaultValue": {
  149. "$env": "now"
  150. }
  151. },
  152. "last_modify_ip": {
  153. "bsonType": "string",
  154. "description": "最后修改时 IP 地址",
  155. "forceDefaultValue": {
  156. "$env": "clientIP"
  157. }
  158. },
  159. "mode": {
  160. "bsonType": "number",
  161. "title": "排版显示模式",
  162. "description": "排版显示模式,如左图右文、上图下文等"
  163. }
  164. }
  165. }