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.

53 lines
1.6 KiB

7 years ago
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, select: false },
  7. token: { type: String, select: false },
  8. description: { type: String, default: "Hello world" },
  9. avatar: { type: String, default: "img/avatars/racoon.png" },
  10. faircoinString: { type: String, default: "faircoin wallet" },
  11. faircoin: { type: String, default: "img/faircoinpublickey_sample.png" },
  12. email: { type: String, required: true, select: false },
  13. phone: { type: String },
  14. telegram: { type: String },
  15. validated: { type: Boolean, default: false },
  16. validatedBy: {
  17. type: mongoose.Schema.Types.ObjectId,
  18. ref: 'adminModel'
  19. },
  20. valorations: [{
  21. user: {
  22. type: mongoose.Schema.Types.ObjectId,
  23. ref: 'userModel'
  24. },
  25. value: { type: Number },
  26. comment: { type: String }
  27. }],
  28. likes: [{
  29. type: mongoose.Schema.Types.ObjectId,
  30. ref: 'userModel'
  31. }],
  32. favs: [{
  33. user: {
  34. type: mongoose.Schema.Types.ObjectId,
  35. ref: 'userModel'
  36. },
  37. date: {type: Date}
  38. }],
  39. travels: [{
  40. type: mongoose.Schema.Types.ObjectId,
  41. ref: 'travelModel'
  42. }],
  43. notifications: [{
  44. type: mongoose.Schema.Types.ObjectId,
  45. ref: 'notificationModel'
  46. }]
  47. })
  48. userSchema.plugin(mongooseUniqueValidator);
  49. module.exports = mongoose.model('userModel', userSchema);