notice.js 816 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 notice = {
  6. customer: { type: String, required: true, zh: '用户', ref: 'User.User' }, //
  7. time: { type: String, required: false, zh: '发送时间' }, //
  8. content: { type: String, required: false, zh: '内容' }, //
  9. status: { type: String, required: false, zh: '状态' }, // 字典:notice_status
  10. };
  11. const schema = new Schema(notice, { toJSON: { getters: true, virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.index({ customer: 1 });
  15. schema.index({ status: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('Notice', schema, 'notice');
  20. };