interview.js 1.2 KB

12345678910111213141516171819202122232425262728
  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 { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 访谈表
  8. const interview = {
  9. dock_id: { type: ObjectId },
  10. title: { type: String, required: false, maxLength: 500 }, // 标题
  11. publish_time: { type: String, required: false, maxLength: 500 }, // 时间
  12. origin: { type: String, required: false, maxLength: 500, default: '网站管理员' }, // 来源
  13. brief: { type: String, maxLength: 100 }, // 简介
  14. picture: { type: String, required: false }, // 图片
  15. filepath: { type: String, required: false }, // 视频
  16. content: { type: String, required: false }, // 正文内容
  17. remark: { type: String, maxLength: 200 },
  18. create_time: { type: String },
  19. };
  20. const schema = new Schema(interview, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.index({ title: 1 });
  23. schema.index({ 'meta.createdAt': 1 });
  24. schema.plugin(metaPlugin);
  25. module.exports = app => {
  26. const { mongoose } = app;
  27. return mongoose.model('Interview', schema, 'interview');
  28. };