news.js 814 B

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