You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

7 years ago
7 years ago
  1. var mongoose = require('mongoose'),
  2. Schema = mongoose.Schema;
  3. var mongooseUniqueValidator = require('mongoose-unique-validator');
  4. var userSchema = new Schema({
  5. username: { type: String, required: true, unique: true },
  6. password: { type: String, required: true, selected: false },
  7. token: { type: String, selected: false },
  8. description: { type: String, default: "Hello world" },
  9. avatar: { type: String, default: "img/avatars/racoon.png" },
  10. email: { type: String, required: true },
  11. phone: { type: String },
  12. telegram: { type: String },
  13. valorations: [{
  14. user: {
  15. type: mongoose.Schema.Types.ObjectId,
  16. ref: 'userModel'
  17. },
  18. value: { type: Number },
  19. comment: { type: String }
  20. }],
  21. favs: [{
  22. user: {
  23. type: mongoose.Schema.Types.ObjectId,
  24. ref: 'userModel'
  25. },
  26. date: {type: Date}
  27. }],
  28. travels: [{
  29. type: mongoose.Schema.Types.ObjectId,
  30. ref: 'travelModel'
  31. }],
  32. notifications: [{
  33. type: mongoose.Schema.Types.ObjectId,
  34. ref: 'notificationModel'
  35. }]
  36. })
  37. userSchema.plugin(mongooseUniqueValidator);
  38. module.exports = mongoose.model('userModel', userSchema);