config.js 842 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const configProp = {
  5. logo: { type: Array, zh: 'logo' },
  6. share: { type: Array, zh: '分享图片' },
  7. buyPoint: { type: Number, zh: '购物赠送积分' },
  8. pointPlan: { type: Array, zh: '积分计划' }, // 后续有待制作,目前全靠新写
  9. };
  10. // 系统设置
  11. const config = {
  12. title: { type: String, required: false, zh: '系统名称' }, //
  13. config: { type: Object, required: false, zh: '设置' }, //
  14. };
  15. const schema = new Schema(config, { toJSON: { getters: true, virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Config', schema, 'config');
  22. };