uploadquestion.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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. termid: { type: String, required: true, maxLength: 200 }, // 期id
  12. batchid: { type: String, required: true, maxLength: 200 }, // 批次id
  13. classid: { type: String, required: true, maxLength: 200 }, // 班级id
  14. studentid: { type: String, required: true, maxLength: 200 }, // 学生id
  15. questionnaireid: { type: String, required: false, maxLength: 200 }, // 问卷id
  16. answers: { type: [ answerInfo ], select: true }, // 选项
  17. };
  18. const schema = new Schema(UploadquestionSchema, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ termid: 1 });
  21. schema.index({ batchid: 1 });
  22. schema.index({ classid: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Uploadquestion', schema, 'uploadquestion');
  27. };