1234567891011121314151617181920212223242526 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 节假日信息表
- const festivalInfo = new Schema({
- begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
- finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
- name: { type: String, required: false, maxLength: 200 }, // 名称
- });
- // 节假日表
- const FestivalSchema = {
- year: { type: String, required: true, maxLength: 200 }, // 年份
- festivals: { type: [ festivalInfo ], select: true }, // 节假日
- };
- const schema = new Schema(FestivalSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Festival', schema, 'festival');
- };
|