doctor.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 医生表
  7. const DoctorSchema = {
  8. name: { type: String, required: false, maxLength: 200 }, // 名称
  9. icon: { type: String, required: false, maxLength: 500 }, // 头像
  10. mobile: { type: String, required: true, maxLength: 64 }, // 手机
  11. passwd: { type: Secret, select: false }, // 注册密码
  12. hosname: { type: String, required: false, maxLength: 200 }, // 医院名称
  13. deptname: { type: String, required: false, maxLength: 200 }, // 科室名称
  14. title: { type: String, required: false, maxLength: 200 }, // 职称
  15. post: { type: String, required: false, maxLength: 200 }, // 职务
  16. content: { type: String, required: false }, // 简介
  17. openid: { type: String, required: false }, // 微信openid
  18. money: { type: String, required: false, maxLength: 200 }, // 总金额
  19. balance: { type: String, required: false, maxLength: 200 }, // 剩余金额
  20. remark: { type: String, required: false }, // 备注
  21. invite_id: { type: ObjectId, required: false }, // 邀请医生id
  22. };
  23. const schema = new Schema(DoctorSchema, { toJSON: { virtuals: true } });
  24. schema.index({ openid: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Doctor', schema, 'doctor');
  30. };