menu.js 984 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const { ObjectId } = require('mongoose').Types;
  5. const Menu = {
  6. title: { type: String, required: true }, // 菜单标题
  7. route: { type: String, required: false }, // 路由
  8. pid: { type: ObjectId, required: false }, // 上级id
  9. disabled: { type: Boolean, default: false }, // 禁用状态
  10. sort: { type: Number, required: false, default: 0 }, // 顺序,默认为0,使用降序排序,数值越大在前面
  11. can_delete: { type: Boolean, default: true }, // 可以删除
  12. params: { type: Object }, // 参数字段,需要就用,不需要就不用
  13. icon: { type: String }, // 图标
  14. remark: { type: String },
  15. };
  16. const schema = new Schema(Menu, {
  17. toJSON: { virtuals: true },
  18. });
  19. schema.index({ id: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Menu', schema, 'menu');
  24. };