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');
- };
|