question.js 1003 B

1234567891011121314151617181920212223242526
  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. // 调研考察表
  6. const question = {
  7. title: { type: String, maxLength: 500 }, // 标题
  8. origin: { type: String, maxLength: 500 }, // 来源
  9. img_path: { type: String, maxLength: 500 }, // 图片
  10. file_path: { type: String, maxLength: 500 }, // 文件
  11. content: { type: String, maxLength: 500 }, // 内容
  12. create_id: { type: String }, // 创建人id
  13. create_code: { type: String }, // 创建人角色
  14. remark: { type: String, maxLength: 200 },
  15. create_date: { type: String },
  16. };
  17. const schema = new Schema(question, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.index({ create_id: 1 });
  20. schema.index({ create_code: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('question', schema, 'question');
  26. };