'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; const { Secret } = require('naf-framework-mongoose/lib/model/schema'); // 管理员表 const user = { name: { type: String }, // 名称 login_id: { type: String }, // 登陆口令 password: { type: Secret, select: false }, // 注册密码 openid: { type: String }, // 微信openid remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(user, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('User', schema, 'user'); };