'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 首屏滚动广告 const banner = { name: { type: String, required: false, zh: '名称' }, // url: { type: Array, required: false, zh: '路径' }, // type: { type: String, required: false, zh: '类型' }, // 字典表:banner_type to: { type: String, required: false, zh: '跳转至' }, // 填写路径 status: { type: String, required: false, default: '0', zh: '是否正在使用' }, // 字典status content: { type: String, required: false, zh: '自定义内容' }, // sort: { type: Number, required: false, zh: '排序' }, // }; const schema = new Schema(banner, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ name: 1 }); schema.index({ type: 1 }); schema.index({ status: 1 }); schema.index({ sort: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Banner', schema, 'banner'); };