1234567891011121314151617181920 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 机构表
- const DeptSchema = {
- name: { type: String, required: false, maxLength: 200 }, // 机构名称
- pid: { type: String, required: false, maxLength: 200 }, // 父ID
- };
- const schema = new Schema(DeptSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ pid: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Dept', schema, 'dept');
- };
|