department.js 502 B

123456789101112131415161718
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 部门表
  5. const DepartmentSchema = {
  6. name: { type: String, required: false, maxLength: 500 }, // 部门名称
  7. };
  8. const schema = new Schema(DepartmentSchema, { toJSON: { virtuals: true } });
  9. schema.index({ id: 1 });
  10. schema.plugin(metaPlugin);
  11. module.exports = app => {
  12. const { mongoose } = app;
  13. return mongoose.model('Department', schema, 'department');
  14. };