message.js 927 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 消息表
  5. const MessageSchema = {
  6. openid: { type: String, required: false, maxLength: 200 }, // openid
  7. name: { type: String, required: false, maxLength: 200 }, // openid
  8. title: { type: String, required: false, maxLength: 200 }, // 标题
  9. detail: { type: String, required: false, maxLength: 200 }, // 详细
  10. date: { type: String, required: false, maxLength: 200 }, // 时间
  11. remark: { type: String, required: false, maxLength: 200 }, // 备注
  12. status: { type: String, required: false, default: '0' }, // 状态 0、未读 1、已读
  13. };
  14. const schema = new Schema(MessageSchema, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('Message', schema, 'message');
  20. };