uploadquestion.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 答案详情
  5. const answerInfo = new Schema({
  6. questionid: { type: String, required: false, maxLength: 200 }, // 问题id
  7. answer: { type: String, required: false, maxLength: 200 }, // 答案
  8. });
  9. // 学生上传问卷表
  10. const UploadquestionSchema = {
  11. planid: { type: String, required: true, maxLength: 200 }, // 计划id
  12. termid: { type: String, required: true, maxLength: 200 }, // 期id
  13. batchid: { type: String, required: true, maxLength: 200 }, // 批次id
  14. classid: { type: String, required: true, maxLength: 200 }, // 班级id
  15. studentid: { type: String, required: true, maxLength: 200 }, // 学生id
  16. questionnaireid: { type: String, required: false, maxLength: 200 }, // 问卷id
  17. answers: { type: [ answerInfo ], select: true }, // 选项
  18. };
  19. const schema = new Schema(UploadquestionSchema, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ termid: 1 });
  22. schema.index({ batchid: 1 });
  23. schema.index({ classid: 1 });
  24. schema.plugin(metaPlugin);
  25. module.exports = app => {
  26. const { mongoose } = app;
  27. return mongoose.model('Uploadquestion', schema, 'uploadquestion');
  28. };