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.

43 lines
1.3 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. favs: [{
  23. user: {
  24. type: mongoose.Schema.Types.ObjectId,
  25. ref: 'userModel'
  26. },
  27. date: {type: Date}
  28. }],
  29. travels: [{
  30. type: mongoose.Schema.Types.ObjectId,
  31. ref: 'travelModel'
  32. }],
  33. notifications: [{
  34. type: mongoose.Schema.Types.ObjectId,
  35. ref: 'notificationModel'
  36. }]
  37. })
  38. userSchema.plugin(mongooseUniqueValidator);
  39. module.exports = mongoose.model('userModel', userSchema);