message.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. companionIdForwardToAndFrom: {
  24. type: String,
  25. default: null,
  26. },
  27. name: {
  28. type: String,
  29. default: null,
  30. },
  31. lastName: {
  32. type: String,
  33. default: null,
  34. },
  35. replyName: {
  36. type: String,
  37. default: null,
  38. },
  39. replyLastName: {
  40. type: String,
  41. default: null,
  42. },
  43. forwardName: {
  44. type: String,
  45. default: null,
  46. },
  47. forwardLastName: {
  48. type: String,
  49. default: null,
  50. },
  51. avatarUrl: {
  52. type: String,
  53. default: null,
  54. },
  55. color: {
  56. type: String,
  57. default: null,
  58. },
  59. number: {
  60. type: String,
  61. default: null,
  62. },
  63. type: {
  64. type: String,
  65. default: null,
  66. },
  67. fullType: {
  68. type: String,
  69. default: null,
  70. },
  71. idTime: {
  72. type: String,
  73. default: null,
  74. },
  75. oldId: {
  76. type: String,
  77. default: null,
  78. },
  79. caption: {
  80. type: String,
  81. default: null,
  82. },
  83. replyCaption: {
  84. type: String,
  85. default: null,
  86. },
  87. emoji: {
  88. type: String,
  89. default: null,
  90. },
  91. emojiCompanion: {
  92. type: String,
  93. default: null,
  94. },
  95. pinned: {
  96. type: Boolean,
  97. default: false,
  98. },
  99. owner: {
  100. type: SchemaTypes.ObjectId,
  101. ref: 'user',
  102. },
  103. },
  104. { timestamps: true }
  105. );
  106. messageSchema.plugin(mongoosePaginate);
  107. const Message = model('message', messageSchema);
  108. module.exports = Message;