123456789101112131415161718192021222324252627282930313233 |
- '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 = {
- phone: { type: String, required: false }, // 手机号
- password: { type: Secret, select: false }, // 密码
- type: { type: String, required: false }, // 用户类型
- icon: { type: Array, required: false }, // 头像
- nickname: { type: String, required: false }, // 昵称
- gender: { type: String, required: false }, // 性别
- work: { type: String, required: false }, // 岗位
- mechanism: { type: String, required: false }, // 机构
- email: { type: String, required: false }, // 邮箱
- status: { type: String, required: false, default: '0' }, // 状态,0-待审,1:审核通过,2:审核拒绝
- // account: { type: String, required: false }, // 账号
- // uid: { type: String }, // 关联id,与各自业务有关的用户id
- remark: { type: String },
- };
- const schema = new Schema(user, { 'multi-tenancy': true, toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ phone: 1 });
- schema.index({ type: 1 });
- schema.index({ gender: 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');
- };
|