message.js 956 B

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