message.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. forwardMessage: {
  16. type: String,
  17. default: null,
  18. },
  19. companionId: {
  20. type: String,
  21. default: null,
  22. },
  23. companionIdFlow: {
  24. type: String,
  25. default: null,
  26. },
  27. companionIdForwardToAndFrom: {
  28. type: String,
  29. default: null,
  30. },
  31. name: {
  32. type: String,
  33. default: null,
  34. },
  35. lastName: {
  36. type: String,
  37. default: null,
  38. },
  39. replyName: {
  40. type: String,
  41. default: null,
  42. },
  43. replyLastName: {
  44. type: String,
  45. default: null,
  46. },
  47. forwardName: {
  48. type: String,
  49. default: null,
  50. },
  51. forwardLastName: {
  52. type: String,
  53. default: null,
  54. },
  55. avatarUrl: {
  56. type: String,
  57. default: null,
  58. },
  59. color: {
  60. type: String,
  61. default: null,
  62. },
  63. number: {
  64. type: String,
  65. default: null,
  66. },
  67. type: {
  68. type: String,
  69. default: null,
  70. },
  71. fullType: {
  72. type: String,
  73. default: null,
  74. },
  75. idTime: {
  76. type: String,
  77. default: null,
  78. },
  79. oldId: {
  80. type: String,
  81. default: null,
  82. },
  83. caption: {
  84. type: String,
  85. default: null,
  86. },
  87. replyCaption: {
  88. type: String,
  89. default: null,
  90. },
  91. forwardCaption: {
  92. type: String,
  93. default: null,
  94. },
  95. emoji: {
  96. type: String,
  97. default: null,
  98. },
  99. emojiCompanion: {
  100. type: String,
  101. default: null,
  102. },
  103. pinned: {
  104. type: Boolean,
  105. default: false,
  106. },
  107. edited: {
  108. type: Boolean,
  109. default: false,
  110. },
  111. deleted: {
  112. type: Boolean,
  113. default: false,
  114. },
  115. initiator: {
  116. type: Boolean,
  117. default: false,
  118. },
  119. duration: {
  120. type: Number,
  121. default: null,
  122. },
  123. owner: {
  124. type: SchemaTypes.ObjectId,
  125. ref: 'user',
  126. },
  127. },
  128. { timestamps: true }
  129. );
  130. messageSchema.plugin(mongoosePaginate);
  131. const Message = model('message', messageSchema);
  132. module.exports = Message;