123456789101112131415161718192021 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 菜单表
- const menu = {
- title: { type: String }, // 名称
- index: { type: String }, // 路由
- sort: { type: Number }, // 菜单顺序,正序 asc
- icon: { type: String }, // 图表
- remark: { type: String, maxLength: 200 },
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(menu, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Menu', schema, 'menu');
- };
|