exam.js 743 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 试卷表
  7. const exam = {
  8. type: { type: String }, // 类型:exam-考试;practise-练习
  9. questions: { type: Array }, // 问题列表(只存id,之后去换,保持联动的状态)
  10. proportion: { type: Array }, // 题型比例
  11. remark: { type: String },
  12. };
  13. const schema = new Schema(exam, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('Exam', schema, 'exam');
  20. };