'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 评分表 const ScoreSchema = { lessonid: { type: String, required: true, maxLength: 200 }, // 课程id stuid: { type: String, required: true, maxLength: 200 }, // 学生id teacherid: { type: String, required: true, maxLength: 200 }, // 教师id score: { type: String, required: false, maxLength: 200 }, // 评分 remark: { type: String, required: false, maxLength: 2000 }, // 评价 }; const schema = new Schema(ScoreSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Score', schema, 'score'); };