contact.js 760 B

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