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.

48 lines
1.4 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 },
  13. phone: { type: String },
  14. telegram: { type: String },
  15. valorations: [{
  16. user: {
  17. type: mongoose.Schema.Types.ObjectId,
  18. ref: 'userModel'
  19. },
  20. value: { type: Number },
  21. comment: { type: String }
  22. }],
  23. likes: [{
  24. type: mongoose.Schema.Types.ObjectId,
  25. ref: 'userModel'
  26. }],
  27. favs: [{
  28. user: {
  29. type: mongoose.Schema.Types.ObjectId,
  30. ref: 'userModel'
  31. },
  32. date: {type: Date}
  33. }],
  34. travels: [{
  35. type: mongoose.Schema.Types.ObjectId,
  36. ref: 'travelModel'
  37. }],
  38. notifications: [{
  39. type: mongoose.Schema.Types.ObjectId,
  40. ref: 'notificationModel'
  41. }]
  42. })
  43. userSchema.plugin(mongooseUniqueValidator);
  44. module.exports = mongoose.model('userModel', userSchema);