'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 menu = { title: { type: String }, // 菜单名称 index: { type: String }, // 路由 icon: { type: String }, // 图标 remark: { type: String }, }; const schema = new Schema(menu, { 'multi-tenancy': true, 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'); };