12345678910111213141516171819202122232425262728293031323334 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
- // 用户表(分站模式)
- const user = {
- name: { type: String, required: false }, // 名称
- phone: { type: String, required: false }, // 手机号
- password: { type: Secret, select: false }, // 密码
- card: { type: String, required: false }, // 身份证
- email: { type: String, required: false }, // 邮箱
- addr: { type: String, required: false }, // 地址
- school: { type: String, required: false }, // 院系
- major: { type: String, required: false }, // 专业
- zwzc: { type: String, required: false }, // 职务职称
- office_phone: { type: String, required: false }, // 办公电话
- profession: { type: String, required: false }, // 所属行业
- status: { type: String, required: false, default: '0' }, // 状态,0-待审,1:审核通过,2:审核拒绝
- remark: { type: String },
- };
- const schema = new Schema(user, { 'multi-tenancy': true, toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ phone: 1 });
- schema.index({ card: 1 });
- schema.index({ major: 1 });
- schema.index({ school: 1 });
- schema.index({ status: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('User', schema, 'user');
- };
|