'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 寝室表 const BedroomSchema = { code: { type: String, required: true, maxLength: 200 }, // 寝室号 number: { type: String, required: true, maxLength: 200 }, // 人数 batch: { type: String, required: false, maxLength: 200 }, // 批次 gender: { type: String, required: false, maxLength: 200 }, // 男女限制 floor: { type: String, required: false, maxLength: 200 }, // 楼层 }; const schema = new Schema(BedroomSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Bedroom', schema, 'bedroom'); };