user.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. },
  68. { timestamps: true }
  69. );
  70. const User = model('user', userSchema);
  71. module.exports = User;