user.js 814 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const mongoose = require('mongoose');
  2. const { Schema, model } = mongoose;
  3. mongoose.Types.ObjectId.isValid();
  4. const userSchema = new Schema(
  5. {
  6. name: {
  7. type: String,
  8. default: null,
  9. },
  10. lastName: {
  11. type: String,
  12. default: null,
  13. },
  14. number: {
  15. type: String,
  16. required: [true, 'Number required'],
  17. unique: true,
  18. min: 8,
  19. max: 14,
  20. },
  21. country: {
  22. type: String,
  23. required: [true, 'Country required'],
  24. min: 1,
  25. max: 40,
  26. },
  27. avatarUrl: {
  28. type: String,
  29. default: null,
  30. },
  31. color: {
  32. type: String,
  33. default: null,
  34. },
  35. token: {
  36. type: String,
  37. default: null,
  38. },
  39. code: {
  40. type: String,
  41. default: null,
  42. },
  43. online: {
  44. type: String,
  45. default: null,
  46. },
  47. },
  48. { timestamps: true }
  49. );
  50. const User = model('user', userSchema);
  51. module.exports = User;