config.js 822 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 config = {
  8. can_exam: { type: Boolean, default: false }, // 是否开放考试
  9. proportion: { type: Array }, // 题型比例
  10. exam_proportion: { type: Array }, // 考试题型比例
  11. rules: { type: Array }, // 额外规则
  12. score: { type: Number, default: 100 }, // 试卷满分
  13. remark: { type: String },
  14. };
  15. const schema = new Schema(config, { 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('Config', schema, 'config');
  22. };