banner.js 712 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  5. // 首页轮播管理表
  6. const BannerSchema = {
  7. name: { type: String, required: false, maxLength: 200 }, // 图片名称
  8. url: { type: String, required: true, maxLength: 200 }, // 图片路径
  9. order: { type: String, required: false, maxLength: 200 }, // 排序
  10. };
  11. const schema = new Schema(BannerSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Banner', schema, 'banner');
  17. };