menu.js 749 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // 菜单表
  6. const menu = {
  7. title: { type: String }, // 名称
  8. index: { type: String }, // 路由
  9. sort: { type: Number }, // 菜单顺序,正序 asc
  10. icon: { type: String }, // 图表
  11. remark: { type: String, maxLength: 200 },
  12. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  13. };
  14. const schema = new Schema(menu, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('Menu', schema, 'menu');
  21. };