12345678910111213141516171819202122 |
- '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 config = {
- can_exam: { type: Boolean, default: false }, // 是否开放考试
- proportion: { type: Array }, // 题型比例
- exam_proportion: { type: Array }, // 考试题型比例
- rules: { type: Array }, // 额外规则
- score: { type: Number, default: 100 }, // 试卷满分
- remark: { type: String },
- };
- const schema = new Schema(config, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Config', schema, 'config');
- };
|