festival.js 849 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 节假日信息表
  5. const festivalInfo = new Schema({
  6. begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
  7. finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
  8. name: { type: String, required: false, maxLength: 200 }, // 名称
  9. });
  10. // 节假日表
  11. const FestivalSchema = {
  12. year: { type: String, required: true, maxLength: 200 }, // 年份
  13. festivals: { type: [ festivalInfo ], select: true }, // 节假日
  14. };
  15. const schema = new Schema(FestivalSchema, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('Festival', schema, 'festival');
  21. };