12345678910111213141516171819 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 用户权限表
- const RolesSchema = {
- code: { type: String, required: true, maxLength: 200 }, // 权限code
- name: { type: String, required: true, maxLength: 200 }, // 权限名称
- };
- const schema = new Schema(RolesSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Roles', schema, 'roles');
- };
|