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.

54 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. localNode: { type: String },
  16. validated: { type: Boolean, default: false },
  17. validatedBy: {
  18. type: mongoose.Schema.Types.ObjectId,
  19. ref: 'adminModel'
  20. },
  21. valorations: [{
  22. user: {
  23. type: mongoose.Schema.Types.ObjectId,
  24. ref: 'userModel'
  25. },
  26. value: { type: Number },
  27. comment: { type: String }
  28. }],
  29. likes: [{
  30. type: mongoose.Schema.Types.ObjectId,
  31. ref: 'userModel'
  32. }],
  33. favs: [{
  34. user: {
  35. type: mongoose.Schema.Types.ObjectId,
  36. ref: 'userModel'
  37. },
  38. date: {type: Date}
  39. }],
  40. travels: [{
  41. type: mongoose.Schema.Types.ObjectId,
  42. ref: 'travelModel'
  43. }],
  44. notifications: [{
  45. type: mongoose.Schema.Types.ObjectId,
  46. ref: 'notificationModel'
  47. }]
  48. })
  49. userSchema.plugin(mongooseUniqueValidator);
  50. module.exports = mongoose.model('userModel', userSchema);