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.

22 lines
686 B

7 years ago
  1. var mongoose = require('mongoose');
  2. var mongooseUniqueValidator = require('mongoose-unique-validator');
  3. var Schema = mongoose.Schema;
  4. var publicationSchema = new Schema({
  5. title: {type: String, required: true},
  6. content: {type: String, required: true},
  7. user: {
  8. type: mongoose.Schema.Types.ObjectId,
  9. ref: 'userModel'
  10. },
  11. photo: {type: String},//link a la imatge, en plan, l'user corrent pel carrer tot feliç
  12. date: {type: Date},
  13. likes: [{
  14. type:mongoose.Schema.Types.ObjectId,
  15. ref: 'userModel'
  16. }]
  17. });
  18. publicationSchema.plugin(mongooseUniqueValidator);
  19. module.exports = mongoose.model('publicationModel', publicationSchema);