@nocobase/plugin-ai 2.3.0-alpha.1 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/dist/ai/docs/nocobase/ai-employees/block/ai-chat-box.md +133 -0
  2. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/documents.md +1 -1
  3. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/index.md +11 -7
  4. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/settings.md +12 -8
  5. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-database.md +3 -3
  6. package/dist/ai/docs/nocobase/ai-employees/workflow/nodes/knowledge/create-document.md +1 -1
  7. package/dist/ai/docs/nocobase/api/app/env.md +3 -1
  8. package/dist/ai/docs/nocobase/api/cli/index.md +14 -2
  9. package/dist/ai/docs/nocobase/api/cli/portal/config.md +44 -0
  10. package/dist/ai/docs/nocobase/api/cli/portal/create.md +48 -0
  11. package/dist/ai/docs/nocobase/api/cli/portal/deploy.md +39 -0
  12. package/dist/ai/docs/nocobase/api/cli/portal/destroy.md +41 -0
  13. package/dist/ai/docs/nocobase/api/cli/portal/dev.md +39 -0
  14. package/dist/ai/docs/nocobase/api/cli/portal/index.md +136 -0
  15. package/dist/ai/docs/nocobase/api/cli/portal/info.md +41 -0
  16. package/dist/ai/docs/nocobase/api/cli/portal/list.md +40 -0
  17. package/dist/ai/docs/nocobase/api/cli/portal/pull.md +43 -0
  18. package/dist/ai/docs/nocobase/api/cli/portal/push.md +41 -0
  19. package/dist/ai/docs/nocobase/building-tips/ai-fill-js-block-form.md +1092 -0
  20. package/dist/ai/docs/nocobase/data-sources/calendar/calendar-collection.md +100 -3
  21. package/dist/ai/docs/nocobase/data-sources/collection-comment/index.md +92 -39
  22. package/dist/ai/docs/nocobase/data-sources/collection-sql/index.md +150 -29
  23. package/dist/ai/docs/nocobase/data-sources/collection-tree/index.md +93 -5
  24. package/dist/ai/docs/nocobase/data-sources/collection-view/index.md +226 -4
  25. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/china-region.md +122 -5
  26. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/collection-select.md +105 -4
  27. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/json.md +102 -4
  28. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/nano-id.md +104 -4
  29. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/snowflake-id.md +108 -4
  30. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/sort.md +3 -19
  31. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/uuid.md +104 -4
  32. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/associations/index.md +44 -8
  33. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/color.md +102 -4
  34. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/email.md +104 -4
  35. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/icon.md +102 -4
  36. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/input.md +112 -8
  37. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/integer.md +103 -4
  38. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/number.md +103 -4
  39. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/password.md +102 -4
  40. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/percent.md +104 -5
  41. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/phone.md +104 -4
  42. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/textarea.md +99 -8
  43. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/url.md +103 -4
  44. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox-group.md +105 -3
  45. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox.md +102 -4
  46. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/china-region.md +108 -5
  47. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/multiple-select.md +103 -5
  48. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/radio-group.md +106 -4
  49. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/select.md +103 -5
  50. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/date.md +102 -4
  51. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime-without-tz.md +103 -5
  52. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime.md +103 -5
  53. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/index.md +53 -47
  54. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/time.md +102 -4
  55. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/unix-timestamp.md +103 -5
  56. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/circle.md +102 -4
  57. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/line.md +103 -5
  58. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/point.md +102 -4
  59. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/polygon.md +102 -4
  60. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/index.md +62 -16
  61. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/markdown.md +104 -4
  62. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/rich-text.md +105 -5
  63. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-at.md +105 -5
  64. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-by.md +103 -5
  65. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/space.md +100 -6
  66. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/table-oid.md +102 -4
  67. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-at.md +104 -5
  68. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-by.md +104 -6
  69. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/validation.md +68 -58
  70. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection.md +32 -13
  71. package/dist/ai/docs/nocobase/data-sources/data-modeling/index.md +41 -33
  72. package/dist/ai/docs/nocobase/data-sources/data-source-external-mariadb/index.md +114 -6
  73. package/dist/ai/docs/nocobase/data-sources/data-source-external-mssql/index.md +117 -6
  74. package/dist/ai/docs/nocobase/data-sources/data-source-external-mysql/index.md +103 -6
  75. package/dist/ai/docs/nocobase/data-sources/data-source-external-nocobase/index.md +75 -73
  76. package/dist/ai/docs/nocobase/data-sources/data-source-external-oracle/index.md +129 -11
  77. package/dist/ai/docs/nocobase/data-sources/data-source-external-postgres/index.md +110 -6
  78. package/dist/ai/docs/nocobase/data-sources/data-source-kingbase/index.md +75 -49
  79. package/dist/ai/docs/nocobase/data-sources/data-source-main/general-collection.md +116 -15
  80. package/dist/ai/docs/nocobase/data-sources/data-source-main/index.md +92 -62
  81. package/dist/ai/docs/nocobase/data-sources/data-source-main/inheritance-collection.md +97 -10
  82. package/dist/ai/docs/nocobase/data-sources/data-source-manager/external-database.md +97 -58
  83. package/dist/ai/docs/nocobase/data-sources/data-source-manager/index.md +32 -24
  84. package/dist/ai/docs/nocobase/data-sources/data-source-rest-api/index.md +115 -153
  85. package/dist/ai/docs/nocobase/data-sources/external/clickhouse.md +124 -0
  86. package/dist/ai/docs/nocobase/data-sources/external/doris.md +130 -0
  87. package/dist/ai/docs/nocobase/data-sources/external/index.md +140 -0
  88. package/dist/ai/docs/nocobase/data-sources/external/kingbase.md +129 -0
  89. package/dist/ai/docs/nocobase/data-sources/external/mariadb.md +126 -0
  90. package/dist/ai/docs/nocobase/data-sources/external/mssql.md +129 -0
  91. package/dist/ai/docs/nocobase/data-sources/external/mysql.md +115 -0
  92. package/dist/ai/docs/nocobase/data-sources/external/nocobase.md +159 -0
  93. package/dist/ai/docs/nocobase/data-sources/external/oceanbase.md +126 -0
  94. package/dist/ai/docs/nocobase/data-sources/external/oracle.md +158 -0
  95. package/dist/ai/docs/nocobase/data-sources/external/postgresql.md +122 -0
  96. package/dist/ai/docs/nocobase/data-sources/external/rest-api.md +245 -0
  97. package/dist/ai/docs/nocobase/data-sources/field-attachment-url/index.md +100 -12
  98. package/dist/ai/docs/nocobase/data-sources/field-encryption/index.md +48 -47
  99. package/dist/ai/docs/nocobase/data-sources/field-formula/index.md +99 -5
  100. package/dist/ai/docs/nocobase/data-sources/field-markdown-vditor/index.md +105 -5
  101. package/dist/ai/docs/nocobase/data-sources/field-sequence/index.md +102 -5
  102. package/dist/ai/docs/nocobase/data-sources/field-signature/index.md +18 -16
  103. package/dist/ai/docs/nocobase/data-sources/field-sort/index.md +76 -73
  104. package/dist/ai/docs/nocobase/data-sources/file-manager/field-attachment.md +101 -7
  105. package/dist/ai/docs/nocobase/data-sources/file-manager/file-collection.md +101 -14
  106. package/dist/ai/docs/nocobase/data-sources/index.md +49 -33
  107. package/dist/ai/docs/nocobase/data-sources/main/index.md +130 -0
  108. package/dist/ai/docs/nocobase/data-sources/main/kingbase.md +147 -0
  109. package/dist/ai/docs/nocobase/data-sources/main/mariadb.md +59 -0
  110. package/dist/ai/docs/nocobase/data-sources/main/mysql.md +59 -0
  111. package/dist/ai/docs/nocobase/data-sources/main/oceanbase.md +62 -0
  112. package/dist/ai/docs/nocobase/data-sources/main/postgresql.md +61 -0
  113. package/dist/ai/docs/nocobase/file-manager/storage/index.md +66 -26
  114. package/dist/ai/docs/nocobase/file-manager/storage/s3-pro.md +58 -7
  115. package/dist/ai/docs/nocobase/get-started/installation/env.md +2 -2
  116. package/dist/ai/docs/nocobase/ops-management/migration-manager/built-in-tables.md +1 -2
  117. package/dist/ai/docs/nocobase/runjs/context/ai.md +194 -4
  118. package/dist/ai/tools/executeFrontendTool.d.ts +10 -0
  119. package/dist/ai/tools/executeFrontendTool.js +86 -0
  120. package/dist/ai/tools/getSkill.js +1 -1
  121. package/dist/ai/tools/loadFrontendTool.d.ts +10 -0
  122. package/dist/ai/tools/loadFrontendTool.js +99 -0
  123. package/dist/client/244.8631eb5cf3f05e21.js +10 -0
  124. package/dist/client/{525.203778500aca5d05.js → 525.94dd4136c1361477.js} +1 -1
  125. package/dist/client/681.6ffbc9329b9ac242.js +10 -0
  126. package/dist/{client-v2/705.1d10027ff8cfdf79.js → client/705.19b642db34de438a.js} +1 -1
  127. package/dist/client/index.d.ts +1 -3
  128. package/dist/client/index.js +8 -8
  129. package/dist/client-v2/244.c428e645ecb94414.js +10 -0
  130. package/dist/client-v2/420.b2aedb1ff71fca0e.js +10 -0
  131. package/dist/client-v2/681.6890caa389564ff7.js +10 -0
  132. package/dist/client-v2/705.8dc34d43f02f322c.js +10 -0
  133. package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +2 -0
  134. package/dist/client-v2/ai-employees/AddContextButton.d.ts +2 -0
  135. package/dist/client-v2/ai-employees/chatbox/components/AIEmployeeSwitcher.d.ts +1 -0
  136. package/dist/client-v2/ai-employees/chatbox/components/ChatBoxUnreadBadge.d.ts +17 -0
  137. package/dist/client-v2/ai-employees/chatbox/components/Conversations.d.ts +9 -1
  138. package/dist/client-v2/ai-employees/chatbox/components/MessageRenderers.d.ts +1 -1
  139. package/dist/client-v2/ai-employees/chatbox/components/Messages.d.ts +5 -1
  140. package/dist/client-v2/ai-employees/chatbox/components/ModelSwitcher.d.ts +4 -0
  141. package/dist/client-v2/ai-employees/chatbox/components/Sender.d.ts +33 -1
  142. package/dist/client-v2/ai-employees/chatbox/components/index.d.ts +1 -0
  143. package/dist/client-v2/ai-employees/chatbox/hooks/useChat.d.ts +8 -5
  144. package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +3 -2
  145. package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxEffect.d.ts +2 -1
  146. package/dist/client-v2/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +3 -2
  147. package/dist/client-v2/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +4 -2
  148. package/dist/client-v2/ai-employees/chatbox/hooks/useToolCallActions.d.ts +3 -1
  149. package/dist/client-v2/ai-employees/chatbox/hooks/useUploadFiles.d.ts +13 -3
  150. package/dist/client-v2/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +3 -2
  151. package/dist/client-v2/ai-employees/chatbox/index.d.ts +17 -0
  152. package/dist/client-v2/ai-employees/chatbox/roles.d.ts +2 -153
  153. package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +46 -31
  154. package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +7 -7
  155. package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +23 -18
  156. package/dist/client-v2/ai-employees/chatbox/stores/chat-sender.d.ts +43 -0
  157. package/dist/client-v2/ai-employees/chatbox/stores/chat-tool-call.d.ts +6 -5
  158. package/dist/client-v2/ai-employees/chatbox/stores/chat-tools.d.ts +11 -5
  159. package/dist/client-v2/ai-employees/chatbox/stores/mounted-chat-boxes.d.ts +20 -0
  160. package/dist/client-v2/ai-employees/chatbox/stores/runtime.d.ts +43 -0
  161. package/dist/client-v2/ai-employees/chatbox/stores/workflow-tasks.d.ts +22 -10
  162. package/dist/client-v2/ai-employees/chatbox/upload.d.ts +19 -0
  163. package/dist/client-v2/ai-employees/chatbox/utils.d.ts +28 -4
  164. package/dist/client-v2/ai-employees/frontend-tools.d.ts +11 -0
  165. package/dist/client-v2/ai-employees/tools/SuggestionsOptionsCard.d.ts +1 -1
  166. package/dist/client-v2/ai-employees/tools/WorkflowTaskOutputCard.d.ts +1 -1
  167. package/dist/client-v2/ai-employees/types.d.ts +30 -0
  168. package/dist/client-v2/block/ai-chat-box/AIChatBoxBlockModel.d.ts +21 -0
  169. package/dist/client-v2/block/ai-chat-box/AIChatBoxCoreModel.d.ts +13 -0
  170. package/dist/client-v2/block/ai-chat-box/components/AIChatBoxCoreView.d.ts +10 -0
  171. package/dist/client-v2/block/ai-chat-box/components/AIChatBoxView.d.ts +12 -0
  172. package/dist/client-v2/block/ai-chat-box/index.d.ts +14 -0
  173. package/dist/client-v2/block/ai-chat-box/settings.d.ts +12 -0
  174. package/dist/client-v2/block/ai-chat-box/sub-models.d.ts +26 -0
  175. package/dist/client-v2/block/ai-chat-box/types.d.ts +38 -0
  176. package/dist/client-v2/block/ai-chat-box/utils.d.ts +26 -0
  177. package/dist/client-v2/index.d.ts +3 -5
  178. package/dist/client-v2/index.js +3 -3
  179. package/dist/client-v2/llm-services/model-select.d.ts +33 -0
  180. package/dist/client-v2/llm-services/utils.d.ts +1 -0
  181. package/dist/client-v2/manager/ai-manager.d.ts +10 -3
  182. package/dist/client-v2/manager/frontend-tool-registry.d.ts +30 -0
  183. package/dist/client-v2/models/ai-employees/AIEmployeeActionModel.d.ts +4 -1
  184. package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +5 -0
  185. package/dist/client-v2/pages/EmployeesPage.d.ts +2 -0
  186. package/dist/client-v2/runjs/registerAIEmployeeRunJSFacade.d.ts +1 -0
  187. package/dist/common/ai-employee-validation.d.ts +15 -0
  188. package/dist/common/ai-employee-validation.js +61 -0
  189. package/dist/common/error-codes.d.ts +13 -0
  190. package/dist/common/error-codes.js +48 -0
  191. package/dist/common/frontend-tools.d.ts +26 -0
  192. package/dist/common/frontend-tools.js +57 -0
  193. package/dist/common/llm-service-models.d.ts +16 -0
  194. package/dist/common/llm-service-models.js +84 -0
  195. package/dist/externalVersion.js +16 -16
  196. package/dist/locale/en-US.json +67 -0
  197. package/dist/locale/zh-CN.json +67 -0
  198. package/dist/node_modules/@langchain/mistralai/package.json +1 -1
  199. package/dist/node_modules/@langchain/xai/package.json +1 -1
  200. package/dist/node_modules/fs-extra/package.json +1 -1
  201. package/dist/node_modules/jsonrepair/package.json +1 -1
  202. package/dist/node_modules/just-bash/package.json +1 -1
  203. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  204. package/dist/node_modules/openai/package.json +1 -1
  205. package/dist/node_modules/zod/package.json +1 -1
  206. package/dist/server/ai-employees/ai-conversations.d.ts +4 -1
  207. package/dist/server/ai-employees/ai-conversations.js +2 -0
  208. package/dist/server/ai-employees/ai-employee.d.ts +2 -1
  209. package/dist/server/ai-employees/ai-employee.js +26 -7
  210. package/dist/server/ai-employees/middleware/conversation.js +9 -2
  211. package/dist/server/collections/ai-conversations.js +5 -0
  212. package/dist/server/document-loader/constants.js +1 -1
  213. package/dist/server/frontend-tools.d.ts +25 -0
  214. package/dist/server/frontend-tools.js +171 -0
  215. package/dist/server/manager/work-context-handler.js +10 -3
  216. package/dist/server/plugin.d.ts +1 -0
  217. package/dist/server/plugin.js +25 -0
  218. package/dist/server/resource/aiConversations.d.ts +2 -0
  219. package/dist/server/resource/aiConversations.js +33 -3
  220. package/dist/server/resource/aiEmployees.d.ts +2 -0
  221. package/dist/server/resource/aiEmployees.js +62 -0
  222. package/dist/server/resource/aiWorkflowTasks.js +9 -1
  223. package/dist/server/resource/llmServices.d.ts +11 -0
  224. package/dist/server/resource/llmServices.js +85 -0
  225. package/dist/server/types/knowledge-base.type.d.ts +6 -2
  226. package/dist/swagger/common.d.ts +143 -0
  227. package/dist/swagger/common.js +144 -0
  228. package/dist/swagger/employees.d.ts +301 -0
  229. package/dist/swagger/employees.js +131 -0
  230. package/dist/swagger/index.d.ts +1588 -0
  231. package/dist/swagger/index.js +62 -0
  232. package/dist/swagger/llm.d.ts +555 -0
  233. package/dist/swagger/llm.js +247 -0
  234. package/dist/swagger/schemas.d.ts +736 -0
  235. package/dist/swagger/schemas.js +381 -0
  236. package/package.json +2 -2
  237. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-store.md +0 -24
  238. package/dist/ai/docs/nocobase/data-sources/development/index.md +0 -6
  239. package/dist/client/372.40eb52905e3f3049.js +0 -10
  240. package/dist/client/681.399948c18d753667.js +0 -10
  241. package/dist/client/705.380279da896021fb.js +0 -10
  242. package/dist/client-v2/372.8cc3fde09c9bec77.js +0 -10
  243. package/dist/client-v2/406.341be51205c674e0.js +0 -10
  244. package/dist/client-v2/681.082f4f1c7b841983.js +0 -10
  245. package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +0 -46
  246. package/dist/client-v2/ai-employees/chatbox/utils/normalizeTriggerTaskOptions.d.ts +0 -19
@@ -1,14 +1,111 @@
1
1
  ---
2
2
  pkg: "@nocobase/plugin-calendar"
3
+ title: "Calendar collection"
4
+ description: "Use a Calendar collection to store time-range data such as meetings, schedules, courses, and shifts, then display and edit event records with Calendar blocks."
5
+ keywords: "Calendar collection,Calendar Collection,calendar events,recurring events,Calendar block,NocoBase"
3
6
  ---
4
7
 
5
8
  # Calendar collection
6
9
 
7
10
  ## Introduction
8
11
 
9
- A calendar Collection is a specialized data table designed to store dates and date-related information. It is commonly used to manage and track time within applications or systems. The primary goal of the calendar table is to offer flexible and efficient access to date information, allowing for the swift retrieval of relevant data as needed.
12
+ Calendar collections are suitable for time-range data, such as meeting-room reservations, project schedules, course schedules, duty rosters, and event calendars. They are still collections, but include fields related to calendar events so that they can be used with Calendar blocks later.
10
13
 
11
- ## User Manual
14
+ You can create Calendar collections only from the main data source. External databases, REST API data sources, and External NocoBase data sources do not support creating Calendar collections.
12
15
 
16
+ ## Use cases
13
17
 
14
- ![20240512182454](https://static-docs.nocobase.com/20240512182454.png)
18
+ Calendar collections are suitable for these business scenarios:
19
+
20
+ - Meeting-room, vehicle, and equipment reservations
21
+ - Project schedules, task plans, and milestone arrangements
22
+ - Timetables, training plans, and event calendars
23
+ - Duty rosters, shift records, and inspection plans
24
+ - Event records that need to be viewed by day, week, or month
25
+
26
+ ## Create and configure
27
+
28
+ In the main data source, click **Create collection** and select **Calendar collection** to create a Calendar collection.
29
+
30
+ Calendar collection settings are mostly the same as those for a general collection. `Preset fields` controls common system fields, and Calendar collections also include fields for storing recurring-event data.
31
+
32
+ | Setting | Description |
33
+ | --- | --- |
34
+ | Collection display name | The name displayed for the collection, such as `Meeting room reservations`, `Course schedule`, or `Duty roster`. |
35
+ | Collection name | The collection identifier used internally by APIs, relation fields, permissions, and workflows. |
36
+ | Inherits | Select a parent collection to inherit. This setting is visible only when the main database is PostgreSQL. |
37
+ | Categories | Collection categories affect only organization in Data source management; they do not change the collection structure. |
38
+ | Description | A description of the collection. State which events it stores, who maintains it, and which business processes it relates to. |
39
+ | Preset fields | Preset fields. Keep system fields and Calendar collection built-in fields when creating a Calendar collection. |
40
+
41
+ ### Built-in fields
42
+
43
+ After a Calendar collection is created, it usually includes the following built-in fields. `cron` and `exclude` store recurrence rules and excluded dates.
44
+
45
+ | Field | Field name | Description |
46
+ | --- | --- | --- |
47
+ | ID | `id` | The default primary key that uniquely identifies an event record. |
48
+ | Created at | `createdAt` | Automatically records when the event record was created. |
49
+ | Created by | `createdBy` | Automatically records the user who created the event record. |
50
+ | Updated at | `updatedAt` | Automatically records when the event record was last updated. |
51
+ | Updated by | `updatedBy` | Automatically records the user who last updated the event record. |
52
+ | Sort | `sort` | Stores the sort value for an event record and supports capabilities such as drag-and-drop ordering. |
53
+ | Repeats | `cron` | Stores recurrence rules, such as daily, weekly, monthly, or yearly repetition. |
54
+ | Exclude | `exclude` | Stores excluded dates in a recurring event. It is normally maintained automatically through calendar interactions. |
55
+ | Space | `space` | Available after enabling the [Multi-space plugin](../../multi-app/multi-space/index.md). It isolates data by space and does not appear when Multi-space is not enabled. |
56
+
57
+ When a Calendar block uses a Calendar collection, specify the business fields used to display events:
58
+
59
+ | Setting | Description |
60
+ | --- | --- |
61
+ | Title field | Determines the event title in the calendar, such as `Meeting subject` or `Course name`. |
62
+ | Start date field | Determines when the event starts. Usually use a date-time field. |
63
+ | End date field | Determines when the event ends. Usually use a date-time field. |
64
+
65
+ :::warning Note
66
+
67
+ `cron` and `exclude` are normally maintained by Calendar capabilities and should not be edited directly as ordinary business fields. Create and configure title, start-date, and end-date fields according to your business needs; otherwise, Calendar blocks cannot display events correctly.
68
+
69
+ :::
70
+
71
+ ### Primary key field
72
+
73
+ Like a general collection, a Calendar collection needs a primary key. Keep the ID preset field when creating the collection; its default primary-key type is `Snowflake ID (53-bit)`.
74
+
75
+ If a Calendar collection has no primary key, set **Record unique key** when editing the collection. Otherwise, Calendar blocks might not open, edit, or locate event records correctly.
76
+
77
+ ## Edit configuration
78
+
79
+ In the collection list, click **Edit** next to a Calendar collection to change its display name, category, description, simple pagination mode, **Record unique key**, and other settings.
80
+
81
+ Calendar built-in fields such as `cron` and `exclude` are normally used by Calendar capabilities and should not be repurposed for other business meanings. To extend event information, add ordinary business fields such as location, participants, meeting room, or status.
82
+
83
+ ## Delete a collection
84
+
85
+ In the collection list, click **Delete** next to a Calendar collection to delete it.
86
+
87
+ Deleting a Calendar collection deletes event records, Calendar built-in field data, and related collection metadata. Before deleting it, confirm whether Calendar blocks, Table blocks, permissions, workflows, or APIs still depend on the collection.
88
+
89
+ :::danger Warning
90
+
91
+ Calendar collections usually store time data for schedules, reservations, and shifts. After deletion, historical events and recurrence rules are lost. Confirm that the data is backed up or no longer needed before proceeding.
92
+
93
+ :::
94
+
95
+ ## Use in pages
96
+
97
+ A Calendar collection can use most data blocks for a [general collection](../data-source-main/general-collection.md) to create, read, update, and delete records. It is also usually used with Calendar blocks:
98
+
99
+ | Block | Use |
100
+ | --- | --- |
101
+ | [Calendar block](../../interface-builder/blocks/data-blocks/calendar.md) | Displays event records in day, week, month, and other views, and creates, views, and edits events in the calendar. |
102
+ | [Table block](../../interface-builder/blocks/data-blocks/table.md) | Views, filters, and maintains event records in a list. |
103
+ | [Form block](../../interface-builder/blocks/data-blocks/form.md) | Creates or edits one event record. |
104
+ | [Details block](../../interface-builder/blocks/data-blocks/details.md) | Views details of one event. |
105
+
106
+ ## Related links
107
+
108
+ - [General collection](../data-source-main/general-collection.md) - General configuration and block usage.
109
+ - [Date and time fields](../data-modeling/collection-fields/datetime/datetime.md) - Create event start and end fields.
110
+ - [Calendar block](../../interface-builder/blocks/data-blocks/calendar.md) - Display data in a calendar on a page.
111
+ - [Multi-space](../../multi-app/multi-space/index.md) - Learn about the Space field and data isolation by space.
@@ -1,66 +1,119 @@
1
1
  ---
2
2
  pkg: "@nocobase/plugin-comments"
3
+ title: "Comment collection"
4
+ description: "A Comment collection stores comments, replies, and feedback for business records. It supports rich-text content, user tracking, multi-level comments, and Comment blocks."
5
+ keywords: "Comment collection,comments,rich text comments,multi-level comments,Collection Comment,NocoBase"
3
6
  ---
4
7
 
5
- # Comment Collection
8
+ # Comment collection
6
9
 
7
10
  ## Introduction
8
11
 
9
- Comment collection is a specialized data table template designed for storing user comments and feedback. With the comment feature, you can add commenting capabilities to any data table, allowing users to discuss, provide feedback, or annotate specific records. The comment collection supports rich text editing, providing flexible content creation capabilities.
12
+ Comment collections are suitable for storing discussions, feedback, and annotations around business records. For example, you can use a Comment collection for task comments, approval opinions, article comments, and customer feedback.
10
13
 
11
- ![comment-collection-2025-11-01-00-39-01](https://static-docs.nocobase.com/comment-collection-2025-11-01-00-39-01.png)
14
+ A Comment collection is usually not used as an independent main business collection. A more common approach is to create a Comment collection, configure a relation field in the business collection, and then add a Comment block to the details page or popup for business records.
12
15
 
13
- ## Features
16
+ ![Comment collection workflow](https://static-docs.nocobase.com/comment-collection-2025-11-01-00-39-01.png)
14
17
 
15
- - **Rich Text Editing**: Includes Markdown (vditor) editor by default, supporting rich text content creation
16
- - **Link to Any Data Table**: Can associate comments with records in any data table through relationship fields
17
- - **Multi-level Comments**: Supports replying to comments, building a comment tree structure
18
- - **User Tracking**: Automatically records comment creator and creation time
18
+ ## Use cases
19
19
 
20
- ## User Guide
20
+ Comment collections are suitable for these business scenarios:
21
21
 
22
- ### Creating a Comment Collection
22
+ - Collaboration discussions on tasks, requirements, and defects
23
+ - Processing opinions on approval forms, work orders, and contracts
24
+ - Comments on articles, knowledge bases, and announcements
25
+ - Customer feedback, after-sales follow-up, and internal notes
23
26
 
24
- ![comment-collection-2025-11-01-00-37-10](https://static-docs.nocobase.com/comment-collection-2025-11-01-00-37-10.png)
27
+ ## Usage flow
25
28
 
26
- 1. Go to the data table management page
27
- 2. Click the "Create Collection" button
28
- 3. Select the "Comment Collection" template
29
- 4. Enter the table name (e.g., "Task Comments", "Article Comments", etc.)
30
- 5. The system will automatically create a comment table with the following default fields:
31
- - Comment content (Markdown vditor type)
32
- - Created by (linked to user table)
33
- - Created at (datetime type)
29
+ Comment collections are typically used together with a business collection and a Comment block:
34
30
 
35
- ### Configuring Relationships
31
+ 1. Create a Comment collection to store comment content, reply relations, creators, creation time, and other information.
32
+ 2. Create a relation field in the business collection and relate it to the Comment collection. For example, relate a `Task comments` collection to the `Tasks` collection.
33
+ 3. Add a Comment block to a details page or popup for the business collection.
34
+ 4. When users post or reply in the Comment block, comment data is written to the Comment collection and related to the current business record.
35
+ 5. Configure Comment collection permissions as needed to control who can view, create, or delete comments.
36
36
 
37
- To link comments to a target data table, you need to configure relationship fields:
37
+ ## Create and configure
38
+
39
+ In the main data source, click **Create collection** and select **Comment collection** to create a Comment collection.
40
+
41
+ ![Create a Comment collection](https://static-docs.nocobase.com/comment-collection-2025-11-01-00-37-10.png)
42
+
43
+ | Setting | Description |
44
+ | --- | --- |
45
+ | Collection display name | The name displayed for the collection, such as `Task comments`, `Approval opinions`, or `Article comments`. |
46
+ | Collection name | The collection identifier used internally by APIs, relation fields, permissions, and workflows. |
47
+ | Inherits | Select a parent collection to inherit. This setting is visible only when the main database is PostgreSQL. |
48
+ | Categories | Collection categories affect only organization in Data source management; they do not change the collection structure. |
49
+ | Description | A description of the collection. State which business object it serves, who maintains it, and how comment permissions are designed. |
50
+ | Preset fields | Preset fields. Keep system fields and Comment collection built-in fields when creating a Comment collection. |
51
+
52
+ ### Built-in fields
53
+
54
+ After a Comment collection is created, it usually includes the following built-in fields. Comment blocks mainly use `content`, `createdBy`, and `createdAt` to display comment text, commenter, and comment time.
55
+
56
+ | Field | Field name | Description |
57
+ | --- | --- | --- |
58
+ | ID | `id` | The default primary key that uniquely identifies a comment record. |
59
+ | Comment content | `content` | Stores the comment text entered by users. It uses the Markdown Vditor interface by default. |
60
+ | Created at | `createdAt` | Automatically records when the comment was created. Comment blocks use it to display the comment time. |
61
+ | Created by | `createdBy` | Automatically records the user who posted the comment. Comment blocks use it to display the commenter. |
62
+ | Updated at | `updatedAt` | Automatically records when the comment was last updated. |
63
+ | Updated by | `updatedBy` | Automatically records the user who last updated the comment. |
64
+ | Space | `space` | Available after enabling the [Multi-space plugin](../../multi-app/multi-space/index.md). It isolates data by space and does not appear when Multi-space is not enabled. |
65
+
66
+ :::warning Note
67
+
68
+ Comment collection built-in fields are normally maintained by Comment blocks and should not be deleted or repurposed casually. To store information such as comment category or processing status, add business fields instead.
69
+
70
+ :::
71
+
72
+ ### Primary key field
73
+
74
+ Like a general collection, a Comment collection needs a primary key. Comment blocks use the primary key to locate comment records and reply relationships.
75
+
76
+ If a Comment collection has no primary key, set **Record unique key** when editing the collection. Otherwise, Comment blocks might not view, reply to, or delete comments correctly.
77
+
78
+ ## Create a relation
79
+
80
+ Create a relation field in the business collection and relate it to the Comment collection.
38
81
 
39
82
  ![](https://static-docs.nocobase.com/Solution/demoE3v1-19N.gif)
40
83
 
41
- 1. Add a "Many-to-One" relationship field in the comment table
42
- 2. Select the target data table to link to (e.g., tasks table, articles table, etc.)
43
- 3. Set the field name (e.g., "Belongs to Task", "Belongs to Article", etc.)
84
+ ## Use in pages
85
+
86
+ Comment collections are usually used through Comment blocks. Add a Comment block to a details page, popup, or record page of a business collection to let users comment on the current record.
87
+
88
+ ![Enable the Comments collection](https://static-docs.nocobase.com/Solution/demoE3v1-20.gif)
89
+
90
+ | Configuration location | Use |
91
+ | --- | --- |
92
+ | [Details block](../../interface-builder/blocks/data-blocks/details.md) | Shows a comment entry in business-record details. |
93
+ | [Form block](../../interface-builder/blocks/data-blocks/form.md) | Uses the comment relation field in business-collection editing flows. |
94
+ | Comment block | Displays the comment list and lets users post and reply to comments. |
95
+
96
+ ## Edit configuration
97
+
98
+ In the collection list, click **Edit** next to a Comment collection to change its display name, category, description, simple pagination mode, **Record unique key**, and other settings.
99
+
100
+ After a Comment collection is in use, do not casually change its comment-content field or reply-relation field. Comment blocks, permissions, workflows, and APIs might depend on these fields.
44
101
 
45
- ### Using Comment Blocks on Pages
102
+ ## Delete a collection
46
103
 
47
- ![Enable Comments Collection](https://static-docs.nocobase.com/Solution/demoE3v1-20.gif)
104
+ In the collection list, click **Delete** next to a Comment collection to delete it.
48
105
 
49
- 1. Go to the page where you want to add comment functionality
50
- 2. Add a block in the details or popup of the target record
51
- 3. Select the "Comments" block type
52
- 4. Choose the comment collection you just created
106
+ Deleting a Comment collection deletes comment records, reply relations, and related collection metadata. Before deleting it, confirm whether relation fields in business collections, Comment blocks, permissions, workflows, or APIs still depend on it.
53
107
 
108
+ :::danger Warning
54
109
 
55
- ### Typical Use Cases
110
+ Deleting a Comment collection removes comment data from existing business records. Comments often contain collaboration history and processing opinions. Confirm whether the data needs to be backed up or archived before proceeding.
56
111
 
57
- - **Task Management Systems**: Team members discuss and provide feedback on tasks
58
- - **Content Management Systems**: Readers comment and interact with articles
59
- - **Approval Workflows**: Approvers annotate and provide opinions on application forms
60
- - **Customer Feedback**: Collect customer reviews of products or services
112
+ :::
61
113
 
62
- ## Notes
114
+ ## Related links
63
115
 
64
- - Comment collection is a commercial plugin feature and requires the comments plugin to be enabled
65
- - It's recommended to set appropriate permissions for the comment table to control who can view, create, and delete comments
66
- - For scenarios with a large number of comments, it's recommended to enable pagination for better performance
116
+ - [General collection](../data-source-main/general-collection.md) - General configuration and block usage.
117
+ - [Relation fields](../data-modeling/collection-fields/associations/index.md) - Learn how business collections relate to Comment collections.
118
+ - [Comments plugin](../../plugins/@nocobase/plugin-comments/index.md) - Learn about Comment blocks and commenting capabilities.
119
+ - [Multi-space](../../multi-app/multi-space/index.md) - Learn about the Space field and data isolation by space.
@@ -1,58 +1,179 @@
1
1
  ---
2
2
  pkg: "@nocobase/plugin-collection-sql"
3
+ title: "SQL collection"
4
+ description: "Create a collection from SQL query results. Configure field sources, field mapping, and Record unique key for joins, aggregations, and reports."
5
+ keywords: "SQL collection,SQL query,field mapping,report,NocoBase"
3
6
  ---
4
7
 
5
- # SQL Collection
8
+ # SQL collection
6
9
 
7
10
  ## Introduction
8
11
 
9
- The SQL collection provides a powerful method for retrieving data using SQL queries. By extracting data fields through SQL queries and configuring the associated field metadata, users can utilize these fields as though they were working with a standard table. This feature is particularly beneficial for scenarios involving complex join queries, statistical analysis, and more.
12
+ Write a SQL query to create an SQL collection. It does not create a real database table. NocoBase reads the query result and makes it available in Tables, Details, Charts, and Workflows. It is suitable for aggregate data and statistical reports.
10
13
 
11
- ## User Manual
14
+ :::warning Note
12
15
 
13
- ### Creating a New SQL Collection
16
+ SQL collections support only `SELECT` statements and `WITH ... SELECT` statements. They support query display only and do not support creating, editing, or deleting data.
14
17
 
15
- <img src="https://static-docs.nocobase.com/202405191452918.png"/>
18
+ :::
16
19
 
17
- 1. Enter your SQL query in the provided input box and click Execute. The system will analyze the query to determine the tables and fields involved, automatically extracting the relevant field metadata from the source tables.
20
+ ## Create an SQL collection
18
21
 
19
- <img src="https://static-docs.nocobase.com/202405191453556.png"/>
22
+ 1. Open the data-source home page from the **Data sources** menu in system settings.
23
+ 2. Select the **Main** data source in the data-source list and click **Configure** to open the main database.
24
+ 3. In main database management, click **Create collection** and select **SQL collection**.
20
25
 
21
- 2. If the system's analysis of the source tables and fields is incorrect, you can manually select the appropriate tables and fields to ensure the correct metadata is used. Start by selecting the source table, then choose the corresponding fields in the field source section below.
26
+ ![Configure the Main data source](https://static-docs.nocobase.com/configure_main_datasource.png)
27
+ ![Create an SQL collection](https://static-docs.nocobase.com/create_sql_collection.png)
28
+ ![Configure an SQL collection](https://static-docs.nocobase.com/create_sql_collection_configure.png)
22
29
 
23
- <img src="https://static-docs.nocobase.com/202405191453579.png"/>
30
+ | Setting | Description |
31
+ | --- | --- |
32
+ | Collection display name | The name displayed for the SQL collection, such as `Sales summary` or `Inventory alert`. Use a name that explains the meaning of the query result. |
33
+ | Collection name | The identifier of the SQL collection in NocoBase, used internally by APIs, relation fields, permissions, and workflows. It is generated automatically and can be changed manually. It supports only letters, numbers, and underscores, and must begin with a letter. |
34
+ | Categories | Collection categories affect only organization in Data source management; they do not change the SQL query. |
35
+ | Description | A collection description. State which data the SQL queries, who maintains it, and which page or report uses it. |
36
+ | Record unique key | The unique identifier for a record. SQL query results have no actual primary key, so choose a field or combination of fields that can uniquely locate a record. Without it, blocks might not view records correctly. |
37
+ | SQL | The query used by the SQL collection. NocoBase executes this SQL, configures fields from the result, and uses the result as a collection. |
38
+ | Source collections | The sources of SQL query result fields. This relates result fields to fields in existing collections so that NocoBase can identify field sources and interface types. |
39
+ | Fields | Field-mapping settings. Confirm the name, source, interface type, and display name for each field. |
40
+ | Preview | Preview SQL query results. Before saving, confirm that field mappings and display results meet expectations. |
24
41
 
25
- 3. For fields that do not have a direct source, the system will infer the field type based on the data type. If this inference is incorrect, you can manually select the proper field type.
42
+ ### Write the SQL query
26
43
 
27
- <img src="https://static-docs.nocobase.com/202405191454703.png"/>
44
+ Enter the SQL query and click **Execute** to run it and attempt to parse returned fields and source collections. Clicking **Execute** is used only for preview and field parsing. After confirming that the SQL query is valid, click **Confirm** before the form can submit it as the confirmed query.
28
45
 
29
- 4. As you configure each field, you can preview its display in the preview area, allowing you to see the immediate impact of your settings.
46
+ ![Execute a SQL statement](https://static-docs.nocobase.com/202405191453556.png)
30
47
 
31
- <img src="https://static-docs.nocobase.com/202405191455439.png"/>
48
+ :::tip Tip
32
49
 
33
- 5. After you have completed the configuration and confirmed that everything is correct, click the Confirm button below the SQL input box to finalize the submission.
50
+ `Source collections` are source collections inferred from the SQL query. NocoBase identifies which existing collections most query-result fields originate from and limits the selectable `Field source` values during field mapping.
34
51
 
35
- <img src="https://static-docs.nocobase.com/202405191455302.png"/>
52
+ The inference result helps configure a query quickly. If the SQL query contains aliases, subqueries, calculated fields, aggregate functions, or complex joins, the result might be incomplete, inaccurate, or impossible to infer. You can specify `Source collections` manually.
36
53
 
37
- ### Editing
54
+ :::
38
55
 
39
- 1. If you need to modify the SQL query, click the Edit button to directly alter the SQL statement and reconfigure the fields as needed.
56
+ ### Field mapping
40
57
 
41
- 2. To adjust the field metadata, use the Configure Fields option, which allows you to update the field settings just as you would for a regular table.
58
+ Field mapping must be confirmed after creating an SQL collection. An SQL query result only tells NocoBase which columns it returns. To use those columns like ordinary fields in the interface, confirm a `Field source` or configure the `Field interface` and field display name.
42
59
 
43
- ### Synchronization
60
+ [Learn more about field configuration](../data-modeling/collection-fields/index.md)
44
61
 
45
- If the SQL query remains unchanged but the underlying database table structure has been modified, you can synchronize and reconfigure the fields by selecting Configure Fields - Sync from Database.
62
+ ![Configure an SQL field source](https://static-docs.nocobase.com/202405191453579.png)
63
+ ![Configure an SQL field interface](https://static-docs.nocobase.com/202405191454703.png)
46
64
 
47
- <img src="https://static-docs.nocobase.com/202405191456216.png"/>
65
+ | Setting | Description |
66
+ | --- | --- |
67
+ | Field source | Select the existing collection and field from which the SQL result field originates. After choosing a source, NocoBase can reuse its Field interface. |
68
+ | Field interface | Confirm how the field is displayed and entered in pages, such as Input, Number, Date, or Select. |
69
+ | Field display name | The name displayed for the field. Use a name that business users can recognize. |
48
70
 
49
- ### SQL Collection vs. Linked Database Views
71
+ For example, if an SQL query returns `customers.name as customer_name` and it comes from the **Customer name** field in the Customers collection, map it to that field. NocoBase can then reuse the source field's title and interface configuration.
50
72
 
51
- | Template Type | Best Suited For | Implementation Method | Support for CRUD Operations |
52
- | :--- | :--- | :--- | :--- |
53
- | SQL | Simple models, lightweight use cases<br />Limited interaction with the database<br />Avoiding maintenance of views<br />Prefer UI-driven operations | SQL subquery | Not Supported |
54
- | Connect to database view | Complex models<br />Requires database interaction<br />Data modification needed<br />Requires stronger and more stable database support | Database view | Partially Supported |
73
+ For a calculated result such as `count(*) as total` or `sum(amount) as amount_total`, there is normally no explicit source field, so choose an appropriate Field interface manually.
55
74
 
56
- :::warning
57
- When using SQL collection, be sure to select tables that are manageable within NocoBase. Using tables from the same database that are not connected to NocoBase may lead to inaccurate SQL query parsing. If this is a concern, consider creating and linking to a view.
58
- :::
75
+ :::tip Tip
76
+
77
+ `Field source` depends on `Source collections`. Select source collections first so that source fields under those collections appear in the field-mapping table.
78
+
79
+ When field inference identifies a `Field source`, NocoBase preferentially reuses the source field's Field interface. When it cannot infer a source field, specify `Field source` manually. When the inferred result does not match the business meaning, remove `Field source`, specify another source manually, or select the `Field interface` and configure the `Field display name` manually.
80
+
81
+ :::
82
+
83
+ ### Record unique key
84
+
85
+ An SQL collection requires a Record unique key. Without one, you cannot create blocks in pages or view records correctly. You can select one field or a combination of fields as the unique key. Suitable Record unique key fields usually meet these conditions:
86
+
87
+ - Each row in the query result is unique
88
+ - Field values are stable and do not change due to pagination, sorting, or statistical-calculation changes
89
+ - Fields are not empty
90
+ - Fields are always returned by the query result
91
+
92
+ For a single-table query result, return the original table primary key first. For a query result based on multi-table joins or aggregations, retain a stable business ID in the SQL or return several fields that can jointly locate a record.
93
+
94
+ :::warning Note
95
+
96
+ Do not use values such as `row_number()` that change with sorting, filtering, or aggregation scope as a long-term stable Record unique key. When a Record unique key changes, page blocks, permissions, workflows, and external APIs might not locate the same record.
97
+
98
+ :::
99
+
100
+ ### Preview query results
101
+
102
+ Before saving, use **Preview** to inspect SQL query results. Check the following:
103
+
104
+ - SQL executes normally
105
+ - Returned fields are complete
106
+ - Field interface and display name match the business meaning
107
+ - A Record unique key exists and is unique
108
+ - The query result is suitable for page display
109
+
110
+ ![Preview SQL collection results](https://static-docs.nocobase.com/202405191455439.png)
111
+
112
+ ## Configure fields
113
+
114
+ After creating an SQL collection, click **Configure fields** beside it in the collection list to open field settings. Field settings maintain the fields in the SQL collection, how they display in the interface, and how SQL query results map to NocoBase Field interfaces.
115
+
116
+ [Learn more about field configuration](../data-modeling/collection-fields/index.md)
117
+
118
+ ### Change the UI type
119
+
120
+ After creating an SQL collection, you can still adjust field-interface configuration in field settings. This page is mainly used to change the Field interface, display name, description, and field-specific settings.
121
+
122
+ ![Configure SQL collection fields](https://static-docs.nocobase.com/configure_field_sql.png)
123
+
124
+ Use it in these situations:
125
+
126
+ - The Field interface set when creating the SQL collection is incorrect
127
+ - A field display name does not follow business terminology and needs a clearer name
128
+ - The business meaning of a query-result field changes and its display method needs confirmation again
129
+ - Field descriptions or field-specific settings need adjustment, such as Select options
130
+
131
+ ### Synchronize from database
132
+
133
+ If the SQL query is unchanged but the underlying table structure or fields change, open **Configure fields** and click **Sync from database** to run the SQL again and synchronize fields. For field mapping, see [Create an SQL collection](#field-mapping).
134
+
135
+ ![Synchronize SQL collection fields](https://static-docs.nocobase.com/202405191456216.png)
136
+
137
+ ### Edit a field
138
+
139
+ Click **Edit** beside a field to edit its configuration. Field editing is suitable for adjusting how a field displays and is used in NocoBase, such as its display name, description, validation rules, or field-specific settings.
140
+
141
+ [Learn more about field configuration](../data-modeling/collection-fields/index.md)
142
+
143
+ :::warning Note
144
+
145
+ Editing field configuration does not change the SQL query, source-table column name, source-table column definition, or database index. To change the actual columns in a query result, change the SQL query first, then run it again and synchronize fields.
146
+
147
+ :::
148
+
149
+ ### Delete a field
150
+
151
+ Click **Delete** beside a field to delete it. Deleting a field removes only the field stored in NocoBase; it does not delete the SQL query or actual columns in source tables.
152
+
153
+ [Learn more about field configuration](../data-modeling/collection-fields/index.md)
154
+
155
+ :::warning Note
156
+
157
+ Deleting a field can affect page blocks, filters, sorting, permissions, workflows, APIs, and existing configuration. Before deleting it, confirm whether the field is still used. If the SQL query still returns the column, NocoBase might identify the field again when you later run **Sync from database**.
158
+
159
+ :::
160
+
161
+ ## Edit an SQL collection
162
+
163
+ In the collection list, click **Edit** beside an SQL collection to adjust its metadata and runtime settings in NocoBase. Editing uses mostly the same settings as creating an SQL collection, except that `Collection name` cannot be changed.
164
+
165
+ When the SQL query changes, click **Execute** again and confirm the field mapping, Record unique key, and preview result.
166
+
167
+ ![Edit an SQL collection](https://static-docs.nocobase.com/202405191455302.png)
168
+
169
+ :::warning Note
170
+
171
+ Changing an SQL query can change field names, field mapping, or the Record unique key. After changing it, recheck whether page blocks, charts, permissions, and workflows still work.
172
+
173
+ :::
174
+
175
+ ## Delete an SQL collection
176
+
177
+ In the collection list, click **Delete** beside an SQL collection. This deletes only the SQL collection configuration and fields in NocoBase; it does not delete underlying source tables or data in those tables.
178
+
179
+ You can also select multiple SQL collections and delete them together. Before deleting, check whether page blocks, charts, permissions, workflows, or external APIs still use the SQL collection.
@@ -1,18 +1,106 @@
1
1
  ---
2
2
  pkg: "@nocobase/plugin-collection-tree"
3
+ title: "Tree collection"
4
+ description: "Use a Tree collection for hierarchical data such as organizational structures, product categories, regional hierarchies, and department directories. It uses the adjacency-list model to store parent-child relationships."
5
+ keywords: "Tree collection,tree collection,adjacency list,hierarchical data,NocoBase"
3
6
  ---
4
7
 
5
- # Tree Collection
8
+ # Tree collection
6
9
 
7
10
  ## Introduction
8
11
 
9
- A tree structure collection is a data collection design pattern used for organizing hierarchical data. This collection structure mirrors a tree, where each data item may have one or more child items, and those child items can, in turn, have their own descendants.
12
+ Tree collections are suitable for data with parent-child relationships, such as organizational structures, product categories, regional hierarchies, department directories, and knowledge-base directories. A Tree collection uses the adjacency-list model to store parent-child relationships, and each record can point to its own parent node.
10
13
 
11
- ## User Manual
14
+ You can create Tree collections only from the main data source. External databases, REST API data sources, and External NocoBase data sources do not support creating Tree collections.
12
15
 
16
+ ## Use cases
13
17
 
14
- ![20240324143228](https://static-docs.nocobase.com/20240324143228.png)
18
+ Tree collections are suitable for these business scenarios:
15
19
 
20
+ - Company organizational structures and department hierarchies
21
+ - Product categories, knowledge-base directories, and document directories
22
+ - Province, city, and district hierarchies; sales territories; and service-outlet hierarchies
23
+ - BOM categories, equipment categories, and asset categories
16
24
 
25
+ ## Create and configure
17
26
 
18
- ![20240324143555](https://static-docs.nocobase.com/20240324143555.png)
27
+ In the main data source, click **Create collection** and select **Tree collection** to create a Tree collection.
28
+
29
+ ![Create a Tree collection](https://static-docs.nocobase.com/20240324143228.png)
30
+
31
+ The creation settings for a Tree collection are mostly the same as those for a general collection.
32
+
33
+ | Setting | Description |
34
+ | --- | --- |
35
+ | Collection display name | The name displayed for the collection, such as `Organization`, `Product categories`, or `Regional hierarchy`. |
36
+ | Collection name | The collection identifier used internally by APIs, relation fields, permissions, and workflows. |
37
+ | Inherits | Select a parent collection to inherit. This setting is visible only when the main database is PostgreSQL. |
38
+ | Categories | Collection categories affect only organization in Data source management; they do not change the collection structure. |
39
+ | Description | A description of the collection. State which hierarchy data it stores, who maintains it, and which page filters use it. |
40
+ | Preset fields | Preset fields. Keep system fields and Tree collection built-in fields when creating a Tree collection. |
41
+
42
+ ### Built-in fields
43
+
44
+ After a Tree collection is created, it usually includes the following built-in fields. `parentId`, `parent`, and `children` store the hierarchy.
45
+
46
+ | Field | Field name | Description |
47
+ | --- | --- | --- |
48
+ | ID | `id` | The default primary key that uniquely identifies a record. |
49
+ | Created at | `createdAt` | Automatically records when the record was created. |
50
+ | Created by | `createdBy` | Automatically records the user who created the record. |
51
+ | Updated at | `updatedAt` | Automatically records when the record was last updated. |
52
+ | Updated by | `updatedBy` | Automatically records the user who last updated the record. |
53
+ | Parent ID | `parentId` | Stores the parent-node ID. It is usually empty for root nodes. |
54
+ | Parent | `parent` | A many-to-one relation field that points to a parent node in the current collection. |
55
+ | Children | `children` | A one-to-many relation field representing child nodes of the current node. |
56
+ | Space | `space` | Available after enabling the [Multi-space plugin](../../multi-app/multi-space/index.md). It isolates data by space and does not appear when Multi-space is not enabled. |
57
+
58
+ ![Tree collection built-in fields](https://static-docs.nocobase.com/20240324143555.png)
59
+
60
+ :::warning Note
61
+
62
+ Avoid circular relationships in Tree collection data. For example, do not make B the parent of A and A the parent of B. Circular relationships cause incorrect tree displays and filter results.
63
+
64
+ :::
65
+
66
+ ### Primary key field
67
+
68
+ Like a general collection, a Tree collection needs a primary key. Tree relation fields use the parent-node ID to relate to the primary-key record in the same collection.
69
+
70
+ If a Tree collection has no primary key, set **Record unique key** when editing the collection. Otherwise, blocks might not view or edit records correctly, and tree displays might not locate nodes reliably.
71
+
72
+ ## Use in pages
73
+
74
+ A Tree collection can use most of the data blocks for a [general collection](../data-source-main/general-collection.md) to create, read, update, and delete records. It can also work with tree-specific features:
75
+
76
+ | Block | Use |
77
+ | --- | --- |
78
+ | [Table block](../../interface-builder/blocks/data-blocks/table.md#enable-tree-table) | Displays hierarchical records for viewing and maintaining parent-child structures. |
79
+ | [Form block](../../interface-builder/blocks/data-blocks/form.md) | Creates or edits one Tree node record. |
80
+ | [Details block](../../interface-builder/blocks/data-blocks/details.md) | Views details of one Tree node. |
81
+ | [Tree Filter block](../../interface-builder/blocks/filter-blocks/tree.md) | Filters other data blocks with a tree structure. It is commonly used for category, organization, regional, and other hierarchical filters. |
82
+
83
+ ## Edit configuration
84
+
85
+ In the collection list, click **Edit** next to a Tree collection to change its display name, category, description, simple pagination mode, **Record unique key**, and other settings.
86
+
87
+ Do not delete Tree collection parent-child relation fields or repurpose them casually. To adjust the hierarchy, update parent-node relations in the record data first.
88
+
89
+ ## Delete a collection
90
+
91
+ In the collection list, click **Delete** next to a Tree collection to delete it.
92
+
93
+ Deleting a Tree collection deletes its collection metadata, actual database table, and hierarchy data. Before deleting it, confirm whether page blocks, Tree Filter blocks, relation fields, permissions, workflows, or APIs still depend on it.
94
+
95
+ :::danger Warning
96
+
97
+ Tree collections are often used as filter conditions for other blocks. After deleting a Tree collection, related Tree Filter blocks and page configurations that depend on its category hierarchy might stop working.
98
+
99
+ :::
100
+
101
+ ## Related links
102
+
103
+ - [General collection](../data-source-main/general-collection.md) - General configuration and block usage.
104
+ - [Table block](../../interface-builder/blocks/data-blocks/table.md) - Enable Tree collection display in a table.
105
+ - [Tree Filter block](../../interface-builder/blocks/filter-blocks/tree.md) - Filter data with a tree structure.
106
+ - [Multi-space](../../multi-app/multi-space/index.md) - Learn about the Space field and data isolation by space.