12345678910111213141516171819202122232425262728293031 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 学生信息表
- const stuInfo = new Schema({
- stuid: { type: String, required: false, maxLength: 500 }, // 学生id
- stuname: { type: String, required: false, maxLength: 500 }, // 学生姓名
- type: { type: String, required: false, maxLength: 500, default: '0' }, // 类型,0-组员,1-组长
- });
- // 分组表
- const GroupSchema = {
- name: { type: String, required: true, maxLength: 500 }, // 名称
- termid: { type: String, required: false, maxLength: 500 }, // 期id
- batchid: { type: String, required: false, maxLength: 500 }, // 批次id
- classid: { type: String, required: false, maxLength: 500 }, // 班级id
- students: { type: [ stuInfo ], select: true }, // 学生信息
- score: { type: String, required: false, maxLength: 500 }, // 分数
- status: { type: String, required: true, maxLength: 500, default: '0' }, // 状态,0-未确认,1-确认
- };
- const schema = new Schema(GroupSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Group', schema, 'group');
- };
|