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.

46 lines
1.5 KiB

7 years ago
  1. var mongoose = require('mongoose');
  2. var mongooseUniqueValidator = require('mongoose-unique-validator');
  3. var Schema = mongoose.Schema;
  4. var dietSchema = new Schema({
  5. title: {type: String},
  6. description: {type: String},
  7. startingDay: {type: Date},
  8. price: { type: Number },
  9. image: { type: String },
  10. clients: [{
  11. type: mongoose.Schema.Types.ObjectId,
  12. ref: 'userModel'
  13. }],
  14. chef: {
  15. type: mongoose.Schema.Types.ObjectId,
  16. ref: 'userModel'
  17. },
  18. days: [{
  19. date: {type: Date}, //Ha de ser realmente un día que empiezas por ejemplo 12/12/2016 para poder ir completando según la fecha, comer comes cada día
  20. title: {type: String},
  21. description: {type: String},
  22. meals: [{
  23. title: {type: String},
  24. img: {type: String},
  25. submeals: [{
  26. title: {type: String},
  27. description: {type: String},
  28. amount: {
  29. unit: {type: String},
  30. quantity: {type: Number}
  31. },
  32. nutritional: {
  33. kcal: {type: Number},
  34. proteins: {type: Number},
  35. carbohidrates: {type: Number},
  36. fats: {type: Number},
  37. vitamins: {type: Number}
  38. }
  39. }]
  40. }],
  41. done: {type: Boolean, default: false}
  42. }]
  43. });
  44. dietSchema.plugin(mongooseUniqueValidator);
  45. module.exports = mongoose.model('dietModel', dietSchema);