12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const Menu = {
- project: { type: String, required: true, maxLength: 200 }, // 项目名
- title: { type: String, required: true }, // 菜单标题
- route: { type: String, required: false, maxLength: 200 }, // 路由
- pid: { type: String, required: false, maxLength: 200 }, // 上级id
- disabled: { type: Boolean, default: false }, // 使用状态
- sort: { type: Number, required: false, default: 0 }, // 顺序,默认为0,使用降序排序,数值越大在前面
- params: { type: Object }, // 参数字段,需要就用,不需要就不用
- type: { type: String, required: false, maxLength: 200 }, // 类型,每个项目有每个项目的设置,这里只存储,让各自项目记住自己类型对应什么
- };
- const schema = new Schema(Menu, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Menu', schema, 'menu');
- };
|