@ -8,153 +8,140 @@
* Text = length 65535 ( 64 KiB )
* Long text = length 1 , 000 , 000 , 000
* /
/ * 数 据 库 模 型 里 面 各 种 表 的 定 义
* primary 主键
* unique 唯一
* defaultTo 默认值
* nullable 是否为空
* validations 验证规则
* isIn 枚举值 , defaultTo为当前枚举值中的一个
* isUUID 是否为UUID
* validations 验证规则 , 看当前字段是否符合规则 , 不符合就拒写
* visibility 可见性验证 , 仅给定人员可见
* slug : url 别名 type : 内容类型 ( post , page )
* /
module . exports = {
newsletters : { // 邮件通讯表 - 存储邮件通讯相关的配置信息
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } , // 内部主键(对外不可见)
uuid : { type : 'string' , maxlength : 36 , nullable : false , unique : true , validations : { isUUID : true } } , // 外部唯一标志, 即使被泄露还有id保护, 无法被外部人员窃取相关数据
name : { type : 'string' , maxlength : 191 , nullable : false , unique : true } , // 邮件通讯名称,必须唯一
description : { type : 'string' , maxlength : 2000 , nullable : true } , // 邮件通讯描述,可为空
feedback _enabled : { type : 'boolean' , nullable : false , defaultTo : false } , // 是否启用反馈功能,默认关闭
slug : { type : 'string' , maxlength : 191 , nullable : false , unique : true } , // URL友好的标识符, 必须唯一
sender _name : { type : 'string' , maxlength : 191 , nullable : true } , // 发件人名称,可为空
sender _email : { type : 'string' , maxlength : 191 , nullable : true } , // 发件人邮箱地址,可为空
sender _reply _to : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'newsletter' } , // 回复地址,默认为'newsletter'
status : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'active' , validations : { isIn : [ [ 'active' , 'archived' ] ] } } , // 状态:活跃或已归档
newsletters : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
uuid : { type : 'string' , maxlength : 36 , nullable : false , unique : true , validations : { isUUID : true } } ,
name : { type : 'string' , maxlength : 191 , nullable : false , unique : true } ,
description : { type : 'string' , maxlength : 2000 , nullable : true } ,
feedback _enabled : { type : 'boolean' , nullable : false , defaultTo : false } ,
slug : { type : 'string' , maxlength : 191 , nullable : false , unique : true } ,
sender _name : { type : 'string' , maxlength : 191 , nullable : true } ,
sender _email : { type : 'string' , maxlength : 191 , nullable : true } ,
sender _reply _to : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'newsletter' } ,
status : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'active' , validations : { isIn : [ [ 'active' , 'archived' ] ] } } ,
visibility : {
type : 'string' ,
maxlength : 50 ,
nullable : false ,
defaultTo : 'members' //设置可见性,仅会员可见
defaultTo : 'members'
} ,
subscribe _on _signup : { type : 'boolean' , nullable : false , defaultTo : true } , // 用户注册时是否自动订阅邮件通讯, 默认为true( 自动订阅)
sort _order : { type : 'integer' , nullable : false , unsigned : true , defaultTo : 0 } , // 排序顺序,用于控制显示顺序
header _image : { type : 'string' , maxlength : 2000 , nullable : true } , // 头部图片URL, 可为空
show _header _icon : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示头部图标,默认显示
show _header _title : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示头部标题,默认显示
show _excerpt : { type : 'boolean' , nullable : false , defaultTo : false } , // 是否显示摘要,默认不显示
title _font _category : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'sans_serif' , validations : { isIn : [ [ 'serif' , 'sans_serif' ] ] } } , // 标题字体类别:衬线体或无衬线体
title _alignment : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'center' , validations : { isIn : [ [ 'center' , 'left' ] ] } } , // 标题对齐方式:居中或左对齐
show _feature _image : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示特色图片,默认显示
body _font _category : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'sans_serif' , validations : { isIn : [ [ 'serif' , 'sans_serif' ] ] } } , // 正文字体类别:衬线体或无衬线体
footer _content : { type : 'text' , maxlength : 1000000000 , nullable : true } , // 页脚内容,支持长文本
show _badge : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示徽章,默认显示
show _header _name : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示头部名称,默认显示
show _post _title _section : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示文章标题区域,默认显示
show _comment _cta : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示评论行动号召,默认显示
show _subscription _details : { type : 'boolean' , nullable : false , defaultTo : false } , // 是否显示订阅详情,默认不显示
show _latest _posts : { type : 'boolean' , nullable : false , defaultTo : false } , // 是否显示最新文章,默认不显示
background _color : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'light' } , // 背景颜色,默认为浅色
post _title _color : { type : 'string' , maxlength : 50 , nullable : true } , // 文章标题颜色,可为空
created _at : { type : 'dateTime' , nullable : false } , // 创建时间,不能为空
updated _at : { type : 'dateTime' , nullable : true } , // 更新时间,可为空
button _corners : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'rounded' , validations : { isIn : [ [ 'square' , 'rounded' , 'pill' ] ] } } , // 按钮圆角样式:方形、圆角或药丸形
button _style : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'fill' , validations : { isIn : [ [ 'fill' , 'outline' ] ] } } , // 按钮样式:填充或轮廓
title _font _weight : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'bold' , validations : { isIn : [ [ 'normal' , 'medium' , 'semibold' , 'bold' ] ] } } , // 标题字体粗细:正常、中等、半粗体、粗体
link _style : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'underline' , validations : { isIn : [ [ 'underline' , 'regular' , 'bold' ] ] } } , // 链接样式:下划线、常规、粗体
image _corners : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'square' , validations : { isIn : [ [ 'square' , 'rounded' ] ] } } , // 图片圆角样式:方形或圆角
header _background _color : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'transparent' } , // 头部背景颜色,默认为透明
section _title _color : { type : 'string' , maxlength : 50 , nullable : true } , // 区域标题颜色,可为空
divider _color : { type : 'string' , maxlength : 50 , nullable : true } , // 分隔线颜色,可为空
button _color : { type : 'string' , maxlength : 50 , nullable : true , defaultTo : 'accent' } , // 按钮颜色,默认为强调色
link _color : { type : 'string' , maxlength : 50 , nullable : true , defaultTo : 'accent' } // 链接颜色,默认为强调色
} ,
// 内容管理器,对内容的各种信息进行存储管理
subscribe _on _signup : { type : 'boolean' , nullable : false , defaultTo : true } ,
sort _order : { type : 'integer' , nullable : false , unsigned : true , defaultTo : 0 } ,
header _image : { type : 'string' , maxlength : 2000 , nullable : true } ,
show _header _icon : { type : 'boolean' , nullable : false , defaultTo : true } ,
show _header _title : { type : 'boolean' , nullable : false , defaultTo : true } ,
show _excerpt : { type : 'boolean' , nullable : false , defaultTo : false } ,
title _font _category : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'sans_serif' , validations : { isIn : [ [ 'serif' , 'sans_serif' ] ] } } ,
title _alignment : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'center' , validations : { isIn : [ [ 'center' , 'left' ] ] } } ,
show _feature _image : { type : 'boolean' , nullable : false , defaultTo : true } ,
body _font _category : { type : 'string' , maxlength : 191 , nullable : false , defaultTo : 'sans_serif' , validations : { isIn : [ [ 'serif' , 'sans_serif' ] ] } } ,
footer _content : { type : 'text' , maxlength : 1000000000 , nullable : true } ,
show _badge : { type : 'boolean' , nullable : false , defaultTo : true } ,
show _header _name : { type : 'boolean' , nullable : false , defaultTo : true } ,
show _post _title _section : { type : 'boolean' , nullable : false , defaultTo : true } ,
show _comment _cta : { type : 'boolean' , nullable : false , defaultTo : true } ,
show _subscription _details : { type : 'boolean' , nullable : false , defaultTo : false } ,
show _latest _posts : { type : 'boolean' , nullable : false , defaultTo : false } ,
background _color : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'light' } ,
post _title _color : { type : 'string' , maxlength : 50 , nullable : true } ,
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true } ,
button _corners : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'rounded' , validations : { isIn : [ [ 'square' , 'rounded' , 'pill' ] ] } } ,
button _style : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'fill' , validations : { isIn : [ [ 'fill' , 'outline' ] ] } } ,
title _font _weight : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'bold' , validations : { isIn : [ [ 'normal' , 'medium' , 'semibold' , 'bold' ] ] } } ,
link _style : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'underline' , validations : { isIn : [ [ 'underline' , 'regular' , 'bold' ] ] } } ,
image _corners : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'square' , validations : { isIn : [ [ 'square' , 'rounded' ] ] } } ,
header _background _color : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'transparent' } ,
section _title _color : { type : 'string' , maxlength : 50 , nullable : true } ,
divider _color : { type : 'string' , maxlength : 50 , nullable : true } ,
button _color : { type : 'string' , maxlength : 50 , nullable : true , defaultTo : 'accent' } ,
link _color : { type : 'string' , maxlength : 50 , nullable : true , defaultTo : 'accent' }
} ,
posts : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } , // 主键ID, 唯一标识文章
uuid : { type : 'string' , maxlength : 36 , nullable : false , index : true , validations : { isUUID : true } } , // 全局唯一标识符,用于外部引用
title : { type : 'string' , maxlength : 2000 , nullable : false , validations : { isLength : { max : 255 } } } , // 文章标题, 最大长度255字符
slug : { type : 'string' , maxlength : 191 , nullable : false , unique : true }, // URL别名, 用于在URL中标识文章
mobiledoc : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } , // 旧编辑器JSON格式内容
lexical : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } , // 新编辑器JSON格式内容
html : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } , // 编译之后的HTML内容
comment _id : { type : 'string' , maxlength : 50 , nullable : true } , // 评论ID, 用于外部评论系统集成
plaintext : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } , // 纯文本摘要,用于搜索和预览
feature _image : { type : 'string' , maxlength : 2000 , nullable : true } , // 封面图地址
featured : { type : 'boolean' , nullable : false , defaultTo : false } , // 是否置顶,默认为否,需要手动设置
type : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'post' , validations : { isIn : [ [ 'post' , 'page' ] ] } } , // 内容类型, post为文章, page为页面
status : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'draft' , validations : { isIn : [ [ 'published' , 'draft' , 'scheduled' , 'sent' ] ] } } , // 文章状态:已发布、草稿、定时发布、已发送
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
uuid : { type : 'string' , maxlength : 36 , nullable : false , index : true , validations : { isUUID : true } } ,
title : { type : 'string' , maxlength : 2000 , nullable : false , validations : { isLength : { max : 255 } } } ,
slug : { type : 'string' , maxlength : 191 , nullable : false },
mobiledoc : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } ,
lexical : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } ,
html : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } ,
comment _id : { type : 'string' , maxlength : 50 , nullable : true } ,
plaintext : { type : 'text' , maxlength : 1000000000 , fieldtype : 'long' , nullable : true } ,
feature _image : { type : 'string' , maxlength : 2000 , nullable : true } ,
featured : { type : 'boolean' , nullable : false , defaultTo : false } ,
type : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'post' , validations : { isIn : [ [ 'post' , 'page' ] ] } } ,
status : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'draft' , validations : { isIn : [ [ 'published' , 'draft' , 'scheduled' , 'sent' ] ] } } ,
// NOTE: unused at the moment and reserved for future features
locale : { type : 'string' , maxlength : 6 , nullable : true } , // 语言区域设置,预留字段
locale : { type : 'string' , maxlength : 6 , nullable : true } ,
visibility : {
type : 'string' ,
maxlength : 50 ,
nullable : false ,
defaultTo : 'public' // 可见性设置,默认为公开
defaultTo : 'public'
} ,
email _recipient _filter : {
type : 'text' ,
maxlength : 1000000000 ,
nullable : false // 邮件接收者筛选条件
nullable : false
} ,
created _at : { type : 'dateTime' , nullable : false } , // 创建时间
updated _at : { type : 'dateTime' , nullable : true , index : true } , // 更新时间,有索引便于排序
published _at : { type : 'dateTime' , nullable : true , index : true } , // 发布时间,有索引便于排序
published _by : { type : 'string' , maxlength : 24 , nullable : true } , // 发布者ID
custom _excerpt : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 300 } } } , // 自定义摘要, 最大300字符
codeinjection _head : { type : 'text' , maxlength : 65535 , nullable : true } , // 头部代码注入,用于在<head>标签中添加自定义代码
codeinjection _foot : { type : 'text' , maxlength : 65535 , nullable : true } , // 底部代码注入,用于在<body>结束前添加自定义代码
custom _template : { type : 'string' , maxlength : 100 , nullable : true } , // 自定义模板名称
canonical _url : { type : 'text' , maxlength : 2000 , nullable : true } , // 规范URL, 用于SEO避免重复内容
newsletter _id : { type : 'string' , maxlength : 24 , nullable : true , references : 'newsletters.id' } , // 关联的邮件通讯ID
show _title _and _feature _image : { type : 'boolean' , nullable : false , defaultTo : true } , // 是否显示标题和封面图,默认为是
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true , index : true } ,
published _at : { type : 'dateTime' , nullable : true , index : true } ,
published _by : { type : 'string' , maxlength : 24 , nullable : true } ,
custom _excerpt : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 300 } } } ,
codeinjection _head : { type : 'text' , maxlength : 65535 , nullable : true } ,
codeinjection _foot : { type : 'text' , maxlength : 65535 , nullable : true } ,
custom _template : { type : 'string' , maxlength : 100 , nullable : true } ,
canonical _url : { type : 'text' , maxlength : 2000 , nullable : true } ,
newsletter _id : { type : 'string' , maxlength : 24 , nullable : true , references : 'newsletters.id' } ,
show _title _and _feature _image : { type : 'boolean' , nullable : false , defaultTo : true } ,
'@@INDEXES@@' : [
[ 'type' , 'status' , 'updated_at' ] // 复合索引:按类型、状态、更新时间排序,提高查询性能
[ 'type' , 'status' , 'updated_at' ]
] ,
'@@UNIQUE_CONSTRAINTS@@' : [
[ 'slug' , 'type' ] // 唯一约束: 同一类型的文章不能有相同的slug
[ 'slug' , 'type' ]
]
} ,
posts _meta : { //用于存储文章的额外元数据
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } , //主键ID, 唯一标识文章元数据
post _id : { type : 'string' , maxlength : 24 , nullable : false , references : 'posts.id' , unique : true } , // 关联的文章ID, 唯一标识
og _image : { type : 'string' , maxlength : 2000 , nullable : true } , // Open Graph 图片URL
og _title : { type : 'string' , maxlength : 300 , nullable : true } , // Open Graph 标题, 最大300字符
og _description : { type : 'string' , maxlength : 500 , nullable : true } , // Open Graph 描述, 最大500字符
twitter _image : { type : 'string' , maxlength : 2000 , nullable : true } , // Twitter 图片URL
twitter _title : { type : 'string' , maxlength : 300 , nullable : true } , // Twitter 标题, 最大300字符
twitter _description : { type : 'string' , maxlength : 500 , nullable : true } , // Twitter 描述, 最大500字符
meta _title : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 300 } } } , // SEO 标题, 最大300字符
meta _description : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 500 } } } , // SEO 描述, 最大500字符
email _subject : { type : 'string' , maxlength : 300 , nullable : true } , // 邮件主题, 最大300字符
frontmatter : { type : 'text' , maxlength : 65535 , nullable : true } , // 文章的Frontmatter内容, 用于自定义元数据
feature _image _alt : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 191 } } } , // 封面图替代文本, 最大191字符
feature _image _caption : { type : 'text' , maxlength : 65535 , nullable : true } , // 封面图标题,用于图片描述
email _only : { type : 'boolean' , nullable : false , defaultTo : false } , // 是否仅通过邮件发送,默认为否
posts _meta : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
post _id : { type : 'string' , maxlength : 24 , nullable : false , references : 'posts.id' , unique : true } ,
og _image : { type : 'string' , maxlength : 2000 , nullable : true } ,
og _title : { type : 'string' , maxlength : 300 , nullable : true } ,
og _description : { type : 'string' , maxlength : 500 , nullable : true } ,
twitter _image : { type : 'string' , maxlength : 2000 , nullable : true } ,
twitter _title : { type : 'string' , maxlength : 300 , nullable : true } ,
twitter _description : { type : 'string' , maxlength : 500 , nullable : true } ,
meta _title : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 300 } } } ,
meta _description : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 500 } } } ,
email _subject : { type : 'string' , maxlength : 300 , nullable : true } ,
frontmatter : { type : 'text' , maxlength : 65535 , nullable : true } ,
feature _image _alt : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 191 } } } ,
feature _image _caption : { type : 'text' , maxlength : 65535 , nullable : true } ,
email _only : { type : 'boolean' , nullable : false , defaultTo : false }
} ,
// NOTE: this is the staff table
users : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } , //主键ID, 唯一标识用户
name : { type : 'string' , maxlength : 191 , nullable : false } , // 用户名
slug : { type : 'string' , maxlength : 191 , nullable : false , unique : true } , //用户slug, 唯一标识
password : { type : 'string' , maxlength : 60 , nullable : false } , //用户密码
email : { type : 'string' , maxlength : 191 , nullable : false , unique : true , validations : { isEmail : true } } , //用户邮箱,唯一标识
profile _image : { type : 'string' , maxlength : 2000 , nullable : true } , // 用户头像URL
cover _image : { type : 'string' , maxlength : 2000 , nullable : true } , //用户封面图URL
bio : { type : 'text' , maxlength : 65535 , nullable : true , validations : { isLength : { max : 250 } } } , //用户简介, 最大250字符
website : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isEmptyOrURL : true } } , //用户网站URL
location : { type : 'text' , maxlength : 65535 , nullable : true , validations : { isLength : { max : 150 } } } , //用户位置, 最大150字符
facebook : { type : 'string' , maxlength : 2000 , nullable : true } , //用户Facebook链接
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
name : { type : 'string' , maxlength : 191 , nullable : false } ,
slug : { type : 'string' , maxlength : 191 , nullable : false , unique : true } ,
password : { type : 'string' , maxlength : 60 , nullable : false } ,
email : { type : 'string' , maxlength : 191 , nullable : false , unique : true , validations : { isEmail : true } } ,
profile _image : { type : 'string' , maxlength : 2000 , nullable : true } ,
cover _image : { type : 'string' , maxlength : 2000 , nullable : true } ,
bio : { type : 'text' , maxlength : 65535 , nullable : true , validations : { isLength : { max : 250 } } } ,
website : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isEmptyOrURL : true } } ,
location : { type : 'text' , maxlength : 65535 , nullable : true , validations : { isLength : { max : 150 } } } ,
facebook : { type : 'string' , maxlength : 2000 , nullable : true } ,
twitter : { type : 'string' , maxlength : 2000 , nullable : true } ,
threads : { type : 'string' , maxlength : 191 , nullable : true } , //用户Threads链接
bluesky : { type : 'string' , maxlength : 191 , nullable : true } , //用户Bluesky链接
mastodon : { type : 'string' , maxlength : 191 , nullable : true } , //用户Mastodon链接
tiktok : { type : 'string' , maxlength : 191 , nullable : true } , //用户TikTok链接
youtube : { type : 'string' , maxlength : 191 , nullable : true } , //用户YouTube链接
instagram : { type : 'string' , maxlength : 191 , nullable : true } , //用户Instagram链接
linkedin : { type : 'string' , maxlength : 191 , nullable : true } , //用户LinkedIn链接
accessibility : { type : 'text' , maxlength : 65535 , nullable : true } , //用户可访问性设置
threads : { type : 'string' , maxlength : 191 , nullable : true } ,
bluesky : { type : 'string' , maxlength : 191 , nullable : true } ,
mastodon : { type : 'string' , maxlength : 191 , nullable : true } ,
tiktok : { type : 'string' , maxlength : 191 , nullable : true } ,
youtube : { type : 'string' , maxlength : 191 , nullable : true } ,
instagram : { type : 'string' , maxlength : 191 , nullable : true } ,
linkedin : { type : 'string' , maxlength : 191 , nullable : true } ,
accessibility : { type : 'text' , maxlength : 65535 , nullable : true } ,
status : {
type : 'string' ,
maxlength : 50 ,
@ -173,7 +160,7 @@ module.exports = {
}
} ,
// NOTE: unused at the moment and reserved for future features
locale : { type : 'string' , maxlength : 6 , nullable : true } , //用户语言设置
locale : { type : 'string' , maxlength : 6 , nullable : true } ,
visibility : {
type : 'string' ,
maxlength : 50 ,
@ -197,25 +184,25 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
posts _authors : { // 文章作者关联表
posts _authors : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
post _id : { type : 'string' , maxlength : 24 , nullable : false , references : 'posts.id' } ,
author _id : { type : 'string' , maxlength : 24 , nullable : false , references : 'users.id' } ,
sort _order : { type : 'integer' , nullable : false , unsigned : true , defaultTo : 0 }
} ,
roles : { // 角色
roles : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
name : { type : 'string' , maxlength : 50 , nullable : false , unique : true } ,
description : { type : 'string' , maxlength : 2000 , nullable : true } ,
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
roles _users : { // 角色用户关联表
roles _users : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
role _id : { type : 'string' , maxlength : 24 , nullable : false } ,
user _id : { type : 'string' , maxlength : 24 , nullable : false }
} ,
permissions : { // 权限
permissions : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
name : { type : 'string' , maxlength : 50 , nullable : false , unique : true } ,
object _type : { type : 'string' , maxlength : 50 , nullable : false } ,
@ -224,17 +211,17 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
permissions _users : { // 权限用户关联表
permissions _users : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
user _id : { type : 'string' , maxlength : 24 , nullable : false } ,
permission _id : { type : 'string' , maxlength : 24 , nullable : false }
} ,
permissions _roles : { // 权限角色关联表
permissions _roles : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
role _id : { type : 'string' , maxlength : 24 , nullable : false } ,
permission _id : { type : 'string' , maxlength : 24 , nullable : false }
} ,
settings : { // 设置
settings : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
group : {
type : 'string' ,
@ -278,7 +265,7 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
tags : { // 标签
tags : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
name : { type : 'string' , maxlength : 191 , nullable : false , validations : { matches : /^([^,]|$)/ } } ,
slug : { type : 'string' , maxlength : 191 , nullable : false , unique : true } ,
@ -307,7 +294,7 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
posts _tags : { // 文章标签关联表
posts _tags : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
post _id : { type : 'string' , maxlength : 24 , nullable : false , references : 'posts.id' } ,
tag _id : { type : 'string' , maxlength : 24 , nullable : false , references : 'tags.id' } ,
@ -316,7 +303,7 @@ module.exports = {
[ 'post_id' , 'tag_id' ]
]
} ,
invites : { // 邀请
invites : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
role _id : { type : 'string' , maxlength : 24 , nullable : false } ,
status : {
@ -332,14 +319,14 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
brute : { // 暴力破解
brute : {
key : { type : 'string' , maxlength : 191 , primary : true } ,
firstRequest : { type : 'bigInteger' } ,
lastRequest : { type : 'bigInteger' } ,
lifetime : { type : 'bigInteger' } ,
count : { type : 'integer' }
} ,
sessions : { // 会话
sessions : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
session _id : { type : 'string' , maxlength : 32 , nullable : false , unique : true } ,
user _id : { type : 'string' , maxlength : 24 , nullable : false } ,
@ -347,7 +334,7 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
integrations : { // 集成
integrations : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
type : {
type : 'string' ,
@ -363,12 +350,12 @@ module.exports = {
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true }
} ,
webhooks : { //用于实现事件驱动的外部系统集成, 当系统中发生特定时间的时候, 会自动向配置的外部url发送http通知
webhooks : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
event : { type : 'string' , maxlength : 50 , nullable : false , validations : { isLowercase : true } } , // 事件类型
target _url : { type : 'string' , maxlength : 2000 , nullable : false } , // 目标url
name : { type : 'string' , maxlength : 191 , nullable : true } , // 名称
secret : { type : 'string' , maxlength : 191 , nullable : true } , // 密钥
event : { type : 'string' , maxlength : 50 , nullable : false , validations : { isLowercase : true } } ,
target _url : { type : 'string' , maxlength : 2000 , nullable : false } ,
name : { type : 'string' , maxlength : 191 , nullable : true } ,
secret : { type : 'string' , maxlength : 191 , nullable : true } ,
// @NOTE: the defaultTo does not make sense to set on DB layer as it leads to unnecessary maintenance every major release
// would be ideal if we can remove the default and instead have "isIn" validation checking if it's a valid version e.g: 'v3', 'v4', 'canary'
api _version : { type : 'string' , maxlength : 50 , nullable : false , defaultTo : 'v2' } ,
@ -389,14 +376,14 @@ module.exports = {
nullable : false ,
validations : { isIn : [ [ 'content' , 'admin' ] ] }
} ,
secret : { //密钥字符串
secret : {
type : 'string' ,
maxlength : 191 ,
nullable : false ,
unique : true , //防止出现重复
unique : true ,
validations : { isLength : { min : 26 , max : 128 } }
} ,
role _id : { type : 'string' , maxlength : 24 , nullable : true } , // 角色ID: 关联到roles表, 定义密钥的权限级别
role _id : { type : 'string' , maxlength : 24 , nullable : true } ,
// integration_id is nullable to allow "internal" API keys that don't show in the UI
integration _id : { type : 'string' , maxlength : 24 , nullable : true } ,
user _id : { type : 'string' , maxlength : 24 , nullable : true } ,
@ -427,7 +414,7 @@ module.exports = {
feature _image _caption : { type : 'text' , maxlength : 65535 , nullable : true } ,
custom _excerpt : { type : 'string' , maxlength : 2000 , nullable : true , validations : { isLength : { max : 300 } } }
} ,
members : { // 会员
members : {
id : { type : 'string' , maxlength : 24 , nullable : false , primary : true } ,
uuid : { type : 'string' , maxlength : 36 , nullable : false , unique : true , validations : { isUUID : true } } ,
transient _id : { type : 'string' , maxlength : 191 , nullable : false , unique : true } ,
@ -450,7 +437,7 @@ module.exports = {
last _commented _at : { type : 'dateTime' , nullable : true } ,
created _at : { type : 'dateTime' , nullable : false } ,
updated _at : { type : 'dateTime' , nullable : true } ,
'@@INDEXES@@' : [ // 索引
'@@INDEXES@@' : [
[ 'email_disabled' ]
]
} ,
@ -1103,4 +1090,4 @@ module.exports = {
member _id : { type : 'string' , maxlength : 24 , nullable : true , references : 'members.id' , unique : false , setNullDelete : true } ,
created _at : { type : 'dateTime' , nullable : false }
}
} ;
} ;