123456789101112131415161718192021 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 部门表
- const DepartmentSchema = {
- name: { type: String, required: true, maxLength: 200 }, // 部门名称
- unit: { type: String, required: false, maxLength: 200 }, // 所属单位
- duty: { type: String, required: false, maxLength: 200 }, // 部门职责
- phone: { type: String, required: false, maxLength: 200 }, // 部门电话
- };
- const schema = new Schema(DepartmentSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Department', schema, 'department');
- };
|