uploadquestion.js 1001 B

1234567891011121314151617181920212223242526272829
  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. roomid: { type: String, required: true, maxLength: 200 }, // 计划id
  12. userid: { type: String, required: true, maxLength: 200 }, // 学生id
  13. questionnaireid: { type: String, required: false, maxLength: 200 }, // 问卷id
  14. answers: { type: [ answerInfo ], select: true }, // 选项
  15. };
  16. const schema = new Schema(UploadquestionSchema, { toJSON: { virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.index({ roomid: 1 });
  19. schema.index({ userid: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Uploadquestion', schema, 'uploadquestion');
  24. };