Bỏ qua, đến nội dung

Database schema

ER Diagram

Chi tiết bảng

collections

Bảng metadata lưu định nghĩa collection. Mỗi record tương ứng một bảng vật lý (hoặc view) trong database.

FieldTypeMô tả
keyuidUID duy nhất
namestring (unique)Tên collection — bảng vật lý sẽ là t_<name>
titlestringTên hiển thị trên UI
inheritstringTên collection cha (PostgreSQL table inheritance)
hiddenbooleantrue = ẩn khỏi Collection Manager UI
optionsjsonTuỳ chọn: view (boolean), schema (DB schema), autoGenId, sortable...
descriptionstringMô tả

Associations:

  • hasMany fields — danh sách field.
  • belongsToMany collectionCategories — danh mục phân loại (qua junction collectionCategory).

fields

Bảng metadata lưu định nghĩa field. Mỗi record tương ứng một column trong bảng vật lý (hoặc relation).

FieldTypeMô tả
keyuidUID duy nhất
namestringTên field — tên column vật lý
collectionNamestring (FK)Collection sở hữu
typestringField type: string, integer, belongsTo, hasMany...
interfacestringUI interface: input, number, select, obo...
descriptionstringMô tả field
parentKeystring (FK)fields.key — cho sub-fields (VD: JSON sub-fields)
reverseKeystring (FK)fields.key — reverse relation field
optionsjsonTuỳ chọn: target, foreignKey, through, unique, defaultValue...
sortintegerThứ tự hiển thị trên UI

Associations:

  • belongsTo collection — collection sở hữu.
  • hasMany children — sub-fields (qua parentKey).
  • hasOne reverseField — reverse relation (qua reverseKey).

Options JSON — ví dụ

belongsTo field:

json
{
  "target": "users",
  "foreignKey": "customerId",
  "targetKey": "id",
  "onDelete": "SET NULL"
}

belongsToMany field:

json
{
  "target": "tags",
  "through": "ordersTags",
  "foreignKey": "orderId",
  "otherKey": "tagId"
}

collectionCategories

Danh mục phân loại collection.

FieldTypeMô tả
idbigInt (PK)Snowflake ID
namestringTên danh mục (VD: "Business", "System")
colorstringMàu hiển thị trên UI

M2M với collections qua bảng junction collectionCategory.