otheruser.js 1.1 KB

12345678910111213141516171819202122232425
  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. // 其他用户表
  6. const OtheruserSchema = {
  7. name: { type: String, required: false, maxLength: 200 }, // 用户名
  8. phone: { type: String, required: true, maxLength: 64 }, // 手机
  9. passwd: { type: { Secret }, select: false }, // 注册密码
  10. type: { type: String, required: true, maxLength: 200 }, // 用户类型,0-金控集团后台管理员,1-金融机构用户,2-政府用户
  11. characterid: { type: String, required: false, maxLength: 200 }, // 用户角色
  12. pid: { type: String, required: false, maxLength: 200 ,default:'0' }, // 0是管理员 非0为客户经理(只针对金融机构)
  13. };
  14. const schema = new Schema(OtheruserSchema, { toJSON: { virtuals: true } });
  15. schema.index({ phone: 1 });
  16. schema.index({ id: 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('Otheruser', schema, 'other_user');
  21. };