message.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. owner: {
  108. type: SchemaTypes.ObjectId,
  109. ref: 'user',
  110. },
  111. },
  112. { timestamps: true }
  113. );
  114. messageSchema.plugin(mongoosePaginate);
  115. const Message = model('message', messageSchema);
  116. module.exports = Message;