bedroom.js 773 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 寝室表
  5. const BedroomSchema = {
  6. code: { type: String, required: true, maxLength: 200 }, // 寝室号
  7. number: { type: String, required: true, maxLength: 200 }, // 人数
  8. batch: { type: String, required: false, maxLength: 200 }, // 批次
  9. gender: { type: String, required: false, maxLength: 200 }, // 男女限制
  10. floor: { type: String, required: false, maxLength: 200 }, // 楼层
  11. };
  12. const schema = new Schema(BedroomSchema, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Bedroom', schema, 'bedroom');
  18. };