'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 答案,结果表 const answer = { exam_place_id: { type: String }, // 考场id exam_info: { type: Object }, // 本次考试的相关信息 user_id: { type: String }, // 保安员id user_name: { type: String }, // 保安员姓名 user_card: { type: String }, // 保安员身份号 score: { type: Number }, // 分数 config: { type: Object }, // 设置,生成试卷时的设置 questions: { type: Array }, // 具体详情(此处都存起来,将该转换的数据都转换了,要当时的值保存在这) remark: { type: String }, }; const schema = new Schema(answer, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ exam_place_id: 1 }); schema.index({ user_id: 1 }); schema.index({ user_name: 1 }); schema.index({ user_card: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Answer', schema, 'answer'); };