news.js 899 B

123456789101112131415161718192021222324
  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. content: { type: String, required: false }, // 正文
  12. picture: { type: String, required: false }, // 图片路径
  13. };
  14. const schema = new Schema(NewsSchema, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('News', schema, 'live_news');
  20. };