news.js 738 B

12345678910111213141516171819202122
  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: true, maxLength: 500 }, // 栏目id
  7. title: { type: String, required: true, maxLength: 500 }, // 标题
  8. orgin: { type: String, required: true, maxLength: 500 }, // 来源
  9. content: { type: String, required: true }, // 正文
  10. picture: { type: String, required: false }, // 图片路径
  11. };
  12. const schema = new Schema(NewsSchema, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('News', schema, 'serve_news');
  18. };