123456789101112131415161718192021222324 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 微信用户表
- const user = {
- openid: { type: String, required: true, zh: 'openid ' }, //
- name: { type: String, required: false, zh: '用户名' }, //
- gender: { type: String, required: false, zh: '性别' }, //
- phone: { type: String, required: false, zh: '手机号' }, //
- icon: { type: Array, required: false, zh: '头像' }, //
- type: { type: String, required: false, default: '0', zh: '用户类别' }, // -1:超级管理员;0:普通用户;1-学院管理员;2-教练;3-学员;10-游客
- };
- const schema = new Schema(user, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ openid: 1 });
- schema.index({ name: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('User', schema, 'user');
- };
|