1234567891011121314151617181920212223242526 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 菜单表
- const menus = {
- name: { type: String, zh: '菜单名称' },
- parent_id: { type: String, zh: '父级菜单' },
- order_num: { type: Number, zh: '显示顺序' },
- path: { type: String, zh: '路由地址' },
- component: { type: String, zh: '组件地址' },
- type: { type: String, zh: '菜单类型' }, // 0:目录,1:菜单,2:子页面.....
- status: { type: String, zh: '状态', default: '0' }, // 0:使用;1;禁用
- icon: { type: String, zh: '图标', default: 'icon-shouye' },
- config: { type: Object }, // 设置,页面的按钮,函数设置
- remark: { type: String },
- };
- const schema = new Schema(menus, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Menus', schema, 'menus');
- };
|