joins system done inside the travel model (with join and unjoin implemented

This commit is contained in:
idoctnef
2016-10-06 15:12:08 +02:00
parent 747b52cdcf
commit a51b917484
7 changed files with 58 additions and 19 deletions

View File

@@ -17,7 +17,19 @@ var travelSchema = new Schema({
phone: { type: Number },
telegram: { type: String },
collectivized: { type: Boolean },
modality: { type: String } //if is an offering travel or asking for travel
modality: { type: String }, //if is an offering travel or asking for travel
joins: [{
joinedUserId: { type: String },
joinedUsername: { type: String },
acceptedUserId: { type: String },
joinedAvatar: { type: String }
}],
comments: [{
commentUserId: { type: String },
commentUsername: { type: String },
comment: { type: String },
commentAvatar: { type: String }
}]
})
module.exports = mongoose.model('travelModel', travelSchema);

View File

@@ -1,9 +1,11 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var mongooseUniqueValidator = require('mongoose-unique-validator');
var userSchema = new Schema({
username: { type: String },
username: { type: String, unique: true },
password: { type: String },
description: { type: String },
avatar: { type: String },
@@ -16,4 +18,6 @@ var userSchema = new Schema({
comment: { type: String }
}]
})
userSchema.plugin(mongooseUniqueValidator);
module.exports = mongoose.model('userModel', userSchema);