'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 日志表 const logs = { user_id: { type: String }, // 用户id account: { type: String }, // 账号 name: { type: String }, // 账号名称 _tenant: { type: String }, // 所属分站 opera: { type: String }, // 操作 path: { type: String }, // 请求地址 module: { type: String }, // 模块 remark: { type: String }, }; const schema = new Schema(logs, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ user_id: 1 }); schema.index({ account: 1 }); schema.index({ name: 1 }); schema.index({ _tenant: 1 }); schema.index({ opera: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Logs', schema, 'logs'); };