template.js 779 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 模板表
  7. const template = {
  8. title: { type: String }, // 模板标题
  9. is_use: { type: Boolean, default: false }, // 启用/禁用; 只能启用1个
  10. excel: { type: Object }, // excel数据
  11. remark: { type: String },
  12. };
  13. const schema = new Schema(template, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ is_use: 1 });
  16. schema.index({ title: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Template', schema, 'template');
  22. };