123456789101112131415161718192021222324252627282930313233343536 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const optionInfo = new Schema({
- number: { type: String, required: false, maxLength: 200 },
- opname: { type: String, required: false, maxLength: 200 },
- });
- const questionInfo = new Schema({
- type: { type: String, required: false, maxLength: 200 },
- topic: { type: String, required: false, maxLength: 500 },
- answer: { type: String, required: false, maxLength: 500 },
- option: { type: [ optionInfo ], required: false, select: true },
- score: { type: String, required: false, maxLength: 500 },
- });
- const TaskSchema = {
- code: { type: String, required: true, maxLength: 200 },
- name: { type: String, required: true, maxLength: 500 },
- title: { type: String, required: true, maxLength: 500 },
- status: { type: String, required: false, maxLength: 200 },
- question: { type: [ questionInfo ], required: false, select: true },
- };
- const schema = new Schema(TaskSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Task', schema, 'task');
- };
|