@more-copy/table-plugin
v1.0.0
Published
读取mysql表结构
Downloads
3
Readme
@more-copy/table-plugin
获取 MySQL 表字段
使用示例
// more-copy.config.js
const TablePlugin = require('@more-copy/table-plugin')
module.exports = {
// 数据
data: {},
// 使用插件,有先后顺序
plugins: [
new TablePlugin({
// 表名
table: 'tb_user',
// 类型映射
type_mapping: {},
// 数据库配置
config: {
host: '127.0.0.1',
port: 3306,
user: 'root',
password: '123456',
database: 'data',
},
}),
],
}
挂载到 data 数据
{
"table": {
"name": "tb_user",
"comment": "",
"columns": [
{
"name": "age",
"type": "int",
"comment": "年龄",
"default": null
},
{
"name": "email",
"type": "varchar",
"comment": "邮箱",
"default": null
},
{
"name": "id",
"type": "int",
"comment": "主键",
"default": null
},
{
"name": "name",
"type": "varchar",
"comment": "姓名",
"default": null
},
{
"name": "phone",
"type": "varchar",
"comment": "手机号",
"default": null
},
{
"name": "profession",
"type": "varchar",
"comment": "专业",
"default": null
},
{
"name": "status",
"type": "int",
"comment": "状态",
"default": null
}
]
}
}