message.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 messageSchema = new Schema(
  6. {
  7. message: {
  8. type: String,
  9. default: null,
  10. },
  11. replyMessage: {
  12. type: String,
  13. default: null,
  14. },
  15. companionId: {
  16. type: String,
  17. default: null,
  18. },
  19. companionIdFlow: {
  20. type: String,
  21. default: null,
  22. },
  23. name: {
  24. type: String,
  25. default: null,
  26. },
  27. lastName: {
  28. type: String,
  29. default: null,
  30. },
  31. replyName: {
  32. type: String,
  33. default: null,
  34. },
  35. replyLastName: {
  36. type: String,
  37. default: null,
  38. },
  39. avatarUrl: {
  40. type: String,
  41. default: null,
  42. },
  43. color: {
  44. type: String,
  45. default: null,
  46. },
  47. number: {
  48. type: String,
  49. default: null,
  50. },
  51. type: {
  52. type: String,
  53. default: null,
  54. },
  55. fullType: {
  56. type: String,
  57. default: null,
  58. },
  59. idTime: {
  60. type: String,
  61. default: null,
  62. },
  63. oldId: {
  64. type: String,
  65. default: null,
  66. },
  67. caption: {
  68. type: String,
  69. default: null,
  70. },
  71. replyCaption: {
  72. type: String,
  73. default: null,
  74. },
  75. emoji: {
  76. type: String,
  77. default: null,
  78. },
  79. emojiCompanion: {
  80. type: String,
  81. default: null,
  82. },
  83. pinned: {
  84. type: Boolean,
  85. default: false,
  86. },
  87. owner: {
  88. type: SchemaTypes.ObjectId,
  89. ref: 'user',
  90. },
  91. },
  92. { timestamps: true }
  93. );
  94. messageSchema.plugin(mongoosePaginate);
  95. const Message = model('message', messageSchema);
  96. module.exports = Message;