1234567891011121314151617181920 |
- '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 role = {
- name: { type: String, zh: '名称' }, // 名称
- brief: { type: String, zh: '简介' }, // 简介
- menu: { type: Array, zh: '菜单' }, // 菜单
- remark: { type: String },
- };
- const schema = new Schema(role, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Role', schema, 'role');
- };
|