indexModule.js 861 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 首页模块管理
  5. const indexModule = {
  6. name: { type: String, required: false, zh: '模块名称' }, //
  7. to_type: { type: String, required: false, zh: '跳转类型' }, // 字典:to_type
  8. to: { type: String, required: false, zh: '跳转至' }, //
  9. is_use: { type: String, required: false, zh: '是否使用' }, // 字典:use
  10. url: { type: Array, required: false, zh: '图标' }, //
  11. };
  12. const schema = new Schema(indexModule, { toJSON: { getters: true, virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.index({ name: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('IndexModule', schema, 'indexModule');
  20. };