user.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. originalName: {
  15. type: String,
  16. default: null,
  17. },
  18. originalLastName: {
  19. type: String,
  20. default: null,
  21. },
  22. number: {
  23. type: String,
  24. required: [true, 'Number required'],
  25. unique: true,
  26. min: 8,
  27. max: 14,
  28. },
  29. country: {
  30. type: String,
  31. required: [true, 'Country required'],
  32. min: 1,
  33. max: 40,
  34. },
  35. avatarUrl: {
  36. type: String,
  37. default: null,
  38. },
  39. avatarsArr: {
  40. type: Array,
  41. default: [],
  42. },
  43. color: {
  44. type: String,
  45. default: null,
  46. },
  47. token: {
  48. type: String,
  49. default: null,
  50. },
  51. code: {
  52. type: String,
  53. default: null,
  54. },
  55. online: {
  56. type: String,
  57. default: null,
  58. },
  59. sort: {
  60. type: Boolean,
  61. default: false,
  62. },
  63. nightMode: {
  64. type: Boolean,
  65. default: false,
  66. },
  67. silentMode: {
  68. type: Boolean,
  69. default: false,
  70. },
  71. },
  72. { timestamps: true }
  73. );
  74. const User = model('user', userSchema);
  75. module.exports = User;