|
@@ -1,21 +1,20 @@
|
|
|
'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 = {
|
|
|
- account: { type: String, required: true, zh: '账号' }, //
|
|
|
- name: { type: String, required: false, zh: '姓名' }, //
|
|
|
- password: { type: Secret, required: true, select: false, zh: '密码' }, //
|
|
|
+ name: { type: String, zh: '昵称' },
|
|
|
+ account: { type: String, zh: '账号' },
|
|
|
+ password: { type: Secret, select: false, zh: '密码' }, //
|
|
|
};
|
|
|
-const schema = new Schema(admin, { toJSON: { getters: true, virtuals: true } });
|
|
|
+const schema = new Schema(admin, { toJSON: { virtuals: true } });
|
|
|
schema.index({ id: 1 });
|
|
|
+schema.index({ name: 1 });
|
|
|
+schema.index({ account: 1 });
|
|
|
schema.index({ 'meta.createdAt': 1 });
|
|
|
-
|
|
|
schema.plugin(metaPlugin);
|
|
|
-
|
|
|
module.exports = app => {
|
|
|
const { mongoose } = app;
|
|
|
return mongoose.model('Admin', schema, 'admin');
|