setting.js 921 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 设置表
  5. const SettingSchema = {
  6. am_start: { type: String, required: true, maxLength: 20 }, // 上午考勤开始时间
  7. am_end: { type: String, required: true, maxLength: 20 }, // 上午考勤结束时间
  8. pm_start: { type: String, required: true, maxLength: 20 }, // 下午开始时间
  9. pm_end: { type: String, required: false, maxLength: 20 }, // 下午结束时间
  10. bd_start: { type: String, required: true, maxLength: 20 }, // 寝室开始时间
  11. bd_end: { type: String, required: false, maxLength: 20 }, // 寝室结束时间
  12. };
  13. const schema = new Schema(SettingSchema, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('Setting', schema, 'setting');
  19. };