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 }, // 类型,0-单选,1-多选,2-问答
- topic: { type: String, required: false, maxLength: 500 }, // 题目
- answer: { type: String, required: false, maxLength: 500 }, // 答案
- option: { type: [ optionInfo ], 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 }, // 状态,0-弃用,1-正常
- question: { type: [ questionInfo ], 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');
- };
|