- added fields: longdescr, hoursworked, hoursplanned

This commit is contained in:
Paolo Arena
2019-03-30 02:58:19 +01:00
parent f4ad69674e
commit cadf2ef86a
3 changed files with 23 additions and 18 deletions

View File

@@ -24,6 +24,18 @@ var ProjectSchema = new mongoose.Schema({
descr: {
type: String,
},
longdescr: {
type: String,
},
hoursplanned: {
type: Number,
},
hoursworked: {
type: Number,
},
id_parent: {
type: String,
},
priority: {
type: Number,
},
@@ -65,7 +77,7 @@ ProjectSchema.methods.toJSON = function () {
// console.log(projObject);
return _.pick(projObject, tools.allfieldTodoWithId());
return _.pick(projObject, tools.allfieldProjectWithId());
};
@@ -78,22 +90,15 @@ ProjectSchema.statics.findByUserIdAndCat = function (userId, category) {
});
};
ProjectSchema.statics.findAllByUserIdAndCat = function (userId, category = '') {
ProjectSchema.statics.findAllByUserId = function (userId) {
var Project = this;
if (category === '') {
return Project.find({
'userId': userId,
}).then(ris => {
return tools.mapSort(ris)
})
return Project.find({
'userId': userId,
}).then(ris => {
return ris
})
} else {
return Project.find({
'userId': userId,
'category': category,
});
}
};
ProjectSchema.statics.getArrCategoryInTable = function (userId) {
@@ -111,7 +116,7 @@ ProjectSchema.statics.getAllProjects = async function (userId) {
let obj = [];
obj.arrproj = await Project.findAllByUserIdAndCat(userId);
obj.arrproj = await Project.findAllByUserId(userId);
return obj;