model.md 1.5 KB

Model 说明

1. const schema = new Schema(${tableName}, { toJSON: { virtuals: true } });

这行代码是生成mongodb的Schemas,相当于建表


2

```const ${tableName}(表名) = {

column(字段名):{
  type:TYPE,
  required:Boolean,
  default:TYPE,
  ref:model,
  ------------以上为mongoose的常用属性,还有别的自己找----------------
  ------------以下为自定义属性,写进去也不会错(没写错的话)-------------
  zh:'中文',
  getProp:'${prop}'/['${prop}']
}

} ```

属性 使用场景 类型 说明
type 建表 基础数据类型 mongodb数据类型
required 建表 Boolean 是否必填,不必填可以不写这个字段
default 建表 Any 默认值
ref 建表 String 与哪个model关联
zh 导入/出;显示 String 该字段中文
getProp 导入/出;显示 String 字符串:属性,取出后使用zh中文,与ref配合使用,会将当前字段添加 showModel:${ref}.${getProp} 属性
selectList 显示;表单选项/显示 Array/Object 选择列表,数组直接使用;Object是做请求
formType 表单 String 表单中是什么类型,不写默认text
isShowList 显示 Boolean 是否显示在列表中
isShowDetail 显示 Boolean 是否显示在详情中
listFilter 显示 Boolean 是否显示在列表中作为查询项
showCreate 显示 Boolean 是否显示在创建的表单中
showUpdate 显示 Boolean 是否显示在修改的表单中
getProp 显示 String/Array ref关联表,取出的属性,在查询时使用