indexModule.js 803 B

12345678910111213141516171819202122
  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. };
  11. const schema = new Schema(indexModule, { toJSON: { getters: true, virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.index({ name: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('IndexModule', schema, 'indexModule');
  19. };