carousel.js 656 B

12345678910111213141516171819
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // 轮播图表
  6. const carousel = {
  7. url: { type: String },
  8. name: { type: String },
  9. remark: { type: String, maxLength: 200 },
  10. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  11. };
  12. const schema = new Schema(carousel, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('Carousel', schema, 'carousel');
  19. };