123456789101112131415161718192021222324252627282930 |
- /**
- * 信息列表管理
- */
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 模块信息
- const SchemaDefine = {
- site: { type: String, required: true, maxLength: 64 }, // 归属站点
- title: { type: String, required: false, maxLength: 100 }, // 信息列表名称
- type: { type: String, required: false, maxLength: 5 }, // 类型,'content'=>信息内容类型/'list'=>'信息列表'类型,
- is_use: { type: String, required: false, maxLength: 5 }, // 是否使用,0=>使用中;1=>已禁止
- meta: {
- createdBy: String, // 创建用户
- updatedBy: String, // 修改用户
- },
- };
- const schema = new Schema(SchemaDefine, { 'multi-tenancy': true, toJSON: { virtuals: true } });
- schema.plugin(metaPlugin);
- schema.index({ site: 1 });
- schema.index({ 'meta.state': 1 });
- schema.index({ 'meta.createdAt': -1 });
- schema.index({ 'meta.createdAt': -1, top: -1, 'meta.state': 1 });
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('NewslistInfo', schema, 'cms_newslist');
- };
|