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