'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 UserSchema = { userid: { type: String, required: false, maxLength: 200 }, // 用户信息表id openid: { type: String, required: false, maxLength: 200 }, // 用户微信openid passwd: { type: { Secret }, required: true, select: false, maxLength: 200 }, // 用户密码 role_id: { type: String, required: false, maxLength: 200 }, // 用户权限id name: { type: String, required: false, maxLength: 200 }, // 用户名 phone: { type: String, required: true, maxLength: 64 }, // 手机号 type: { type: String, required: false, maxLength: 200 }, // 用户类型,0-超级管理员,1-管理员,2-专家,3-普通用户 }; const schema = new Schema(UserSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('User', schema, 'user'); };