chat.js 755 B

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