news.js 982 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 信息表
  5. const NewsSchema = {
  6. column_id: { type: String, required: false, maxLength: 500 }, // 栏目id
  7. column_name: { type: String, required: false, maxLength: 500 }, // 栏目名称
  8. title: { type: String, required: false, maxLength: 500 }, // 标题
  9. orgin: { type: String, required: false, maxLength: 500 }, // 来源
  10. publish: { type: String, required: false, maxLength: 500 }, // 发布者
  11. publish_time: { type: String, required: false, maxLength: 500 }, // 发布时间
  12. content: { type: String, required: false }, // 正文
  13. picture: { type: String, required: false }, // 图片路径
  14. };
  15. const schema = new Schema(NewsSchema, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('News', schema, 'live_news');
  21. };