chat.js 710 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const mongoose = require('mongoose');
  2. const { Schema, model, SchemaTypes } = mongoose;
  3. const mongoosePaginate = require('mongoose-paginate-v2');
  4. mongoose.Types.ObjectId.isValid();
  5. const chatSchema = new Schema(
  6. {
  7. companionId: {
  8. type: String,
  9. },
  10. name: {
  11. type: String,
  12. default: null,
  13. },
  14. lastName: {
  15. type: String,
  16. default: null,
  17. },
  18. avatarUrl: {
  19. type: String,
  20. default: null,
  21. },
  22. color: {
  23. type: String,
  24. default: null,
  25. },
  26. online: {
  27. type: String,
  28. default: null,
  29. },
  30. owner: {
  31. type: SchemaTypes.ObjectId,
  32. ref: 'user',
  33. },
  34. },
  35. { timestamps: true }
  36. );
  37. chatSchema.plugin(mongoosePaginate);
  38. const Chat = model('chat', chatSchema);
  39. module.exports = Chat;