123456789101112131415161718192021222324 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
- // 系统管理员表
- const admin = {
- name: { type: String, required: true }, // 用户名
- phone: { type: String, required: false, maxLength: 200 }, // 电话号码
- password: { type: Secret, required: true, select: false }, // 登录密码
- card: { type: String, required: false, maxLength: 200 }, // 身份证号
- email: { type: String, required: false, maxLength: 200 }, // 邮箱
- addr: { type: String, required: false, maxLength: 500 }, // 地址
- remark: { type: String, maxLength: 200 },
- };
- const schema = new Schema(admin, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ phone: 1 });
- schema.index({ card: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Admin', schema, 'admin');
- };
|