message.js 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. companionId: {
  12. type: String,
  13. default: null,
  14. },
  15. companionIdFlow: {
  16. type: String,
  17. default: null,
  18. },
  19. name: {
  20. type: String,
  21. default: null,
  22. },
  23. lastName: {
  24. type: String,
  25. default: null,
  26. },
  27. avatarUrl: {
  28. type: String,
  29. default: null,
  30. },
  31. color: {
  32. type: String,
  33. default: null,
  34. },
  35. number: {
  36. type: String,
  37. default: null,
  38. },
  39. type: {
  40. type: String,
  41. default: null,
  42. },
  43. fullType: {
  44. type: String,
  45. default: null,
  46. },
  47. idTime: {
  48. type: String,
  49. default: null,
  50. },
  51. owner: {
  52. type: SchemaTypes.ObjectId,
  53. ref: 'user',
  54. },
  55. },
  56. { timestamps: true }
  57. );
  58. messageSchema.plugin(mongoosePaginate);
  59. const Message = model('message', messageSchema);
  60. module.exports = Message;