1234567891011121314151617181920 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const Role = {
- project: { type: String, required: true, maxLength: 200 }, // 项目名
- name: { type: String, required: true, maxLength: 200 }, // 角色名称
- type: { type: String, required: false, maxLength: 200 }, // 类型,每个项目有每个项目的设置,这里只存储,让各自项目记住自己类型对应什么
- menu: { type: Array, required: true }, // 菜单标题
- disabled: { type: Boolean, default: false }, // 使用状态
- params: { type: Object }, // 参数字段,需要就用,不需要就不用
- };
- const schema = new Schema(Role, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Role', schema, 'role');
- };
|