news.js 1.2 KB

12345678910111213141516171819202122232425262728
  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. titlejj: { type: String, required: false, maxLength: 500 }, // 标题简介
  10. orgin: { type: String, required: false, maxLength: 500 }, // 来源
  11. publish: { type: String, required: false, maxLength: 500 }, // 发布者
  12. publish_time: { type: String, required: false, maxLength: 500 }, // 发布时间
  13. uid: { type: String, required: false, maxLength: 500 }, // 用户id
  14. content: { type: String, required: false }, // 正文
  15. picture: { type: String, required: false }, // 图片路径
  16. filepath: { type: String, required: false }, // 文件路径
  17. };
  18. const schema = new Schema(NewsSchema, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('News', schema, 'live_news');
  24. };