answer.js 1.1 KB

1234567891011121314151617181920212223242526272829
  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 answer = {
  8. exam_place_id: { type: String }, // 考场id
  9. exam_info: { type: Object }, // 本次考试的相关信息
  10. user_id: { type: String }, // 保安员id
  11. user_name: { type: String }, // 保安员姓名
  12. user_card: { type: String }, // 保安员身份号
  13. score: { type: Number }, // 分数
  14. config: { type: Object }, // 设置,生成试卷时的设置
  15. questions: { type: Array }, // 具体详情(此处都存起来,将该转换的数据都转换了,要当时的值保存在这)
  16. remark: { type: String },
  17. };
  18. const schema = new Schema(answer, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ exam_place_id: 1 });
  21. schema.index({ user_id: 1 });
  22. schema.index({ user_name: 1 });
  23. schema.index({ user_card: 1 });
  24. schema.index({ 'meta.createdAt': 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('Answer', schema, 'answer');
  29. };