'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 { ObjectId } = require('mongoose').Types; // 医生表 const DoctorSchema = { name: { type: String, required: false, maxLength: 200 }, // 名称 icon: { type: String, required: false, maxLength: 500 }, // 头像 mobile: { type: String, required: true, maxLength: 64 }, // 手机 passwd: { type: Secret, select: false }, // 注册密码 hosname: { type: String, required: false, maxLength: 200 }, // 医院名称 deptname: { type: String, required: false, maxLength: 200 }, // 科室名称 title: { type: String, required: false, maxLength: 200 }, // 职称 post: { type: String, required: false, maxLength: 200 }, // 职务 content: { type: String, required: false }, // 简介 openid: { type: String, required: false }, // 微信openid money: { type: String, required: false, maxLength: 200 }, // 总金额 balance: { type: String, required: false, maxLength: 200 }, // 剩余金额 remark: { type: String, required: false }, // 备注 invite_id: { type: ObjectId, required: false }, // 邀请医生id }; const schema = new Schema(DoctorSchema, { toJSON: { virtuals: true } }); schema.index({ openid: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Doctor', schema, 'doctor'); };