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.

46 lines
1.5 KiB

  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 },
  9. avatar: { type: String },
  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. state: {type: String},//viewed, pendent
  34. message: {type: String},
  35. link: {type: String},//aquí oju, a la app i a la web calen links diferents, però ho podem fer posant sempre a la app i a la web el prefix del link (#!/app) o (#/app/), i després afegint-hi la pàgina on volem enviar el routing, per exemple (dashboard)
  36. icon: {type: String},
  37. date: {type: Date},
  38. dateviewed: {type: Date}
  39. }]
  40. })
  41. userSchema.plugin(mongooseUniqueValidator);
  42. module.exports = mongoose.model('userModel', userSchema);