column.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 Attachment = new Schema({
  9. // name: { type: String, maxLength: 128 },
  10. // uri: { type: String, maxLength: 128 },
  11. // }, { _id: false });
  12. // 栏目信息
  13. const SchemaDefine = {
  14. site: { type: String, required: true, maxLength: 64 }, // 归属站点
  15. moudle: { type: String, required: true, maxLength: 20 }, // 栏目模块
  16. name: { type: String, required: true, maxLength: 100 }, // 栏目名称
  17. picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
  18. description: { type: String, required: false, maxLength: 256 }, // 栏目描述
  19. inMenu: { type: String, required: false, maxLength: 5 }, // 是否在菜单中显示
  20. showModes: { type: String, required: false, maxLength: 5 }, // 展现方式
  21. isAudit: { type: String, required: false, maxLength: 5 }, // 是否需要审核
  22. issuer: String, // 栏目单位
  23. meta: {
  24. createdBy: String, // 创建用户
  25. updatedBy: String, // 修改用户
  26. },
  27. remark: { type: String, maxLength: 500 }, // 备注
  28. };
  29. const schema = new Schema(SchemaDefine, { 'multi-tenancy': true, toJSON: { virtuals: true } });
  30. schema.plugin(metaPlugin);
  31. schema.index({ column: 1 });
  32. schema.index({ 'meta.state': 1 });
  33. schema.index({ 'meta.createdAt': -1 });
  34. schema.index({ 'meta.createdAt': -1, top: -1, 'meta.state': 1 });
  35. module.exports = app => {
  36. const { mongoose } = app;
  37. return mongoose.model('ColumnInfo', schema, 'cms_column');
  38. };