question_type.js 892 B

12345678910111213141516171819202122
  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 question_type = {
  8. title: { type: String }, // 类型名称,中文显示
  9. type: { type: String }, // select:单选; checkBox:多选; input:简答
  10. // checkbox: 多选: 全对全分,有错0分 / 有对半分,全错0分; 2种模式
  11. // input: 关键词: 包含关键词就正确
  12. score: { type: Number }, // 每题的分数
  13. remark: { type: String },
  14. };
  15. const schema = new Schema(question_type, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Question_type', schema, 'question_type');
  22. };