RE-DOING and new Structure of project. Updating functionalities, and models

This commit is contained in:
arnaucode
2017-01-26 00:06:19 +01:00
parent 4961f8ca43
commit da188b9b39
9 changed files with 252 additions and 341 deletions

View File

@@ -1,14 +0,0 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var carSchema = new Schema({
title: { type: String },
description: { type: String },
owner: { type: String },
zone: { type: String },
available: { type: Boolean },
generateddate: { type: Date },
seats: { type: Number }
})
module.exports = mongoose.model('carModel', carSchema);

View File

@@ -3,11 +3,10 @@ var mongoose = require('mongoose'),
var commentSchema = new Schema({
travelId: { type: String },
commentUserId: { type: String },
commentUsername: { type: String },
comment: { type: String },
commentAvatar: { type: String }
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'userModel'
}
});
module.exports = mongoose.model('commentModel', commentSchema);

View File

@@ -1,13 +0,0 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var joinSchema = new Schema({
travelId: { type: String },
joinedUserId: { type: String },
joinedUsername: { type: String },
acceptedUserId: { type: String },
joinedAvatar: { type: String }
});
module.exports = mongoose.model('joinModel', joinSchema);

View File

@@ -1,15 +0,0 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var needtravelSchema = new Schema({
title: { type: String },
description: { type: String },
owner: { type: String },
from: { type: String },
to: { type: String },
date: { type: Date },
generateddate: { type: Date },
seats: { type: Number }
})
module.exports = mongoose.model('needtravelModel', needtravelSchema);

View File

@@ -3,32 +3,28 @@ var mongoose = require('mongoose'),
var travelSchema = new Schema({
title: { type: String },
title: { type: String, required: true },
description: { type: String },
owner: { type: String },
from: { type: String },
to: { type: String },
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'userModel'
},
from: { type: String, required: true },
to: { type: String, required: true },
date: { type: Date },
periodic: { type: Boolean },
generateddate: { type: Date },
seats: { type: Number },
seats: { type: Number, required: true },
package: { type: Boolean },
icon: { type: String },
phone: { type: Number },
telegram: { type: String },
collectivized: { type: Boolean },
modality: { type: String }, //if is an offering travel or asking for travel
type: { type: String }, //if is an offering travel or asking for travel
joins: [{
joinedUserId: { type: String },
joinedUsername: { type: String },
acceptedUserId: { type: String },
joinedAvatar: { type: String }
type: mongoose.Schema.Types.ObjectId,
ref: 'userModel'
}],
comments: [{
commentUserId: { type: String },
commentUsername: { type: String },
comment: { type: String },
commentAvatar: { type: String }
type: mongoose.Schema.Types.ObjectId,
ref: 'commentModel'
}]
})
module.exports = mongoose.model('travelModel', travelSchema);

View File

@@ -5,30 +5,40 @@ var mongooseUniqueValidator = require('mongoose-unique-validator');
var userSchema = new Schema({
username: { type: String, unique: true },
password: { type: String },
token: { type: String },
username: { type: String, required: true, unique: true },
password: { type: String, required: true, selected: false },
token: { type: String, selected: false },
description: { type: String },
avatar: { type: String },
mail: { type: String },
email: { type: String, required: true },
phone: { type: String },
telegram: { type: String },
valorations: [{
username: { type: String },
value: { type: Number },
comment: { type: String }
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'userModel'
},
value: { type: Number },
comment: { type: String }
}],
favs: [{
username: { type: String },
userId: { type: String },
avatar: { type: String }
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'userModel'
},
date: {type: Date}
}],
travels: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'travelModel'
}],
notifications: [{
type: { type: String },//fav, comment, join
otherusername: { type: String },
description: { type: String },
date: { type: Date },
link: { type: String }
state: {type: String},//viewed, pendent
message: {type: String},
link: {type: String},//aquí oju, a la app i a la web calen links diferents, però ho podem fer posant sempre a la app i a la web el prefix del link (#!/app) o (#/app/), i després afegint-hi la pàgina on volem enviar el routing, per exemple (dashboard)
icon: {type: String},
date: {type: Date},
dateviewed: {type: Date}
}]
})