1234567891011121314151617181920212223242526272829303132333435363738 |
- '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 = {
- type: { type: String, required: true, maxLength: 200 }, // 类型,0-单选,1-多选,2-问答
- topic: { type: String, required: true, maxLength: 500 }, // 题目
- status: { type: String, required: false, maxLength: 200 }, // 状态,0-弃用,1-正常
- option: { type: [ optionInfo ], select: true }, // 选项
- };
- // 问卷表
- const QuestionnaireSchema = {
- name: { type: String, required: true, maxLength: 200 }, // 问卷名称
- num: { type: String, required: true, maxLength: 200 }, // 序号
- type: { type: String, required: true, maxLength: 200 }, // 类型,0-常用问卷,1-非常用问卷,2-教师问卷
- status: { type: String, required: true, maxLength: 200, default: '0' }, // 状态,0-草稿,1-发布,2-禁用
- question: { type: [ questionInfo ], required: false, select: true }, // 问卷
- };
- const schema = new Schema(QuestionnaireSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ type: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Questionnaire', schema, 'questionnaire');
- };
|