'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose/lib/model/schema'); // 其他用户表 const OtheruserSchema = { name: { type: String, required: false, maxLength: 200 }, // 用户名 phone: { type: String, required: true, maxLength: 64 }, // 手机 passwd: { type: { Secret }, select: false }, // 注册密码 type: { type: String, required: true, maxLength: 200 }, // 用户类型,0-金控集团后台管理员,1-金融机构用户,2-政府用户 characterid: { type: String, required: false, maxLength: 200 }, // 用户角色 pid: { type: String, required: false, maxLength: 200 ,default:'0' }, // 0是管理员 非0为客户经理(只针对金融机构) }; const schema = new Schema(OtheruserSchema, { toJSON: { virtuals: true } }); schema.index({ phone: 1 }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Otheruser', schema, 'other_user'); };