newslist.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /**
  2. * 信息列表管理
  3. */
  4. 'use strict';
  5. const Schema = require('mongoose').Schema;
  6. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  7. // 模块信息
  8. const SchemaDefine = {
  9. site: { type: String, required: true, maxLength: 64 }, // 归属站点
  10. title: { type: String, required: false, maxLength: 100 }, // 信息列表名称
  11. type: { type: String, required: false, maxLength: 5 }, // 类型,'content'=>信息内容类型/'list'=>'信息列表'类型,
  12. is_use: { type: String, required: false, maxLength: 5 }, // 是否使用,0=>使用中;1=>已禁止
  13. meta: {
  14. createdBy: String, // 创建用户
  15. updatedBy: String, // 修改用户
  16. },
  17. };
  18. const schema = new Schema(SchemaDefine, { 'multi-tenancy': true, toJSON: { virtuals: true } });
  19. schema.plugin(metaPlugin);
  20. schema.index({ site: 1 });
  21. schema.index({ 'meta.state': 1 });
  22. schema.index({ 'meta.createdAt': -1 });
  23. schema.index({ 'meta.createdAt': -1, top: -1, 'meta.state': 1 });
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('NewslistInfo', schema, 'cms_newslist');
  27. };