contact.js 782 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. },
  10. name: {
  11. type: String,
  12. default: null,
  13. },
  14. lastName: {
  15. type: String,
  16. default: null,
  17. },
  18. number: {
  19. type: String,
  20. default: null,
  21. },
  22. country: {
  23. type: String,
  24. default: null,
  25. },
  26. avatarUrl: {
  27. type: String,
  28. default: null,
  29. },
  30. color: {
  31. type: String,
  32. default: null,
  33. },
  34. owner: {
  35. type: SchemaTypes.ObjectId,
  36. ref: 'user',
  37. },
  38. },
  39. { timestamps: true }
  40. );
  41. contactSchema.plugin(mongoosePaginate);
  42. const Contact = model('contact', contactSchema);
  43. module.exports = Contact;