contact.js 854 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. pinned: {
  36. type: Boolean,
  37. default: false,
  38. },
  39. owner: {
  40. type: SchemaTypes.ObjectId,
  41. ref: 'user',
  42. },
  43. },
  44. { timestamps: true }
  45. );
  46. contactSchema.plugin(mongoosePaginate);
  47. const Contact = model('contact', contactSchema);
  48. module.exports = Contact;