contact.js 800 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 contactSchema = new Schema(
  6. {
  7. companionId: {
  8. type: String,
  9. default: null,
  10. },
  11. name: {
  12. type: String,
  13. default: null,
  14. },
  15. lastName: {
  16. type: String,
  17. default: null,
  18. },
  19. number: {
  20. type: String,
  21. default: null,
  22. },
  23. country: {
  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. owner: {
  36. type: SchemaTypes.ObjectId,
  37. ref: 'user',
  38. },
  39. },
  40. { timestamps: true }
  41. );
  42. contactSchema.plugin(mongoosePaginate);
  43. const Contact = model('contact', contactSchema);
  44. module.exports = Contact;