science.js 1.0 KB

12345678910111213141516171819202122232425
  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 science = {
  9. title: { type: String, required: false, maxLength: 500 }, // 名称
  10. publish_time: { type: String, required: false, maxLength: 500 }, // 时间
  11. origin: { type: String, required: false, maxLength: 500 }, // 来源
  12. picture: { type: String, required: false }, // 图片
  13. filepath: { type: String, required: false }, // 附件
  14. content: { type: String, required: false }, // 正文
  15. remark: { type: String, maxLength: 200 },
  16. create_time: { type: String },
  17. };
  18. const schema = new Schema(science, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ 'meta.createdAt': 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Science', schema, 'science');
  25. };