chat.js 658 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 chatSchema = new Schema(
  6. {
  7. companionId: {
  8. type: String,
  9. },
  10. name: {
  11. type: String,
  12. default: null,
  13. },
  14. lastName: {
  15. type: String,
  16. default: null,
  17. },
  18. avatarUrl: {
  19. type: String,
  20. default: null,
  21. },
  22. color: {
  23. type: String,
  24. default: null,
  25. },
  26. owner: {
  27. type: SchemaTypes.ObjectId,
  28. ref: 'user',
  29. },
  30. },
  31. { timestamps: true }
  32. );
  33. chatSchema.plugin(mongoosePaginate);
  34. const Chat = model('chat', chatSchema);
  35. module.exports = Chat;