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.

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