12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose/lib/model/schema');
- // 用户表
- const UserSchema = {
- name: { type: String, required: true, maxLength: 200 }, // 用户名称
- mobile: { type: String, required: true, maxLength: 200 }, // 手机号
- password: { type: Secret, select: false }, // 密码
- dept_id: { type: String, required: false, maxLength: 200 }, // 部门id
- gender: { type: String, required: false, maxLength: 200 }, // 性别
- remark: { type: String, required: false, maxLength: 200 }, // 备注
- };
- const schema = new Schema(UserSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('User', schema, 'user');
- };
|