trainchat.js 833 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const Chat = {
  5. unit_id: { type: String, maxLength: 200 }, // 公共聊天区id
  6. sender_id: { type: String, maxLength: 200 }, // 发言人id
  7. sender_name: { type: String, required: true, maxLength: 200 }, // 发言人名称
  8. content: { type: String, required: true, maxLength: 1000 }, // 发言内容
  9. send_time: { type: String, required: true, maxLength: 100 }, // 发言时间:年月日时分秒
  10. role: { type: String, maxLength: 200 }, // 用户身份
  11. };
  12. const schema = new Schema(Chat, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Trainchat', schema, 'train_chat');
  18. };