1234567891011121314151617181920212223 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 班级表
- const ClassSchema = {
- name: { type: String, required: true, maxLength: 500 }, // 班级名称
- number: { type: String, required: false, maxLength: 200 }, // 人数
- batch: { type: String, required: false, maxLength: 200 }, // 批次
- term: { type: String, required: false, maxLength: 200 }, // 期
- headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id
- type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
- };
- const schema = new Schema(ClassSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Class', schema, 'class');
- };
|