'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 模板表 const template = { title: { type: String }, // 模板标题 is_use: { type: Boolean, default: false }, // 启用/禁用; 只能启用1个 excel: { type: Object }, // excel数据 remark: { type: String }, }; const schema = new Schema(template, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ is_use: 1 }); schema.index({ title: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Template', schema, 'template'); };