- Projects: Shared / Personal
This commit is contained in:
@@ -221,19 +221,45 @@ ProjectSchema.statics.getIdParentByIdProj = function (idProj) {
|
||||
|
||||
};
|
||||
|
||||
ProjectSchema.statics.creaProjMain = async function () {
|
||||
|
||||
const projmain = {
|
||||
descr: process.env.PROJECT_DESCR_MAIN,
|
||||
longdescr: process.env.PROJECT_DESCR_MAIN,
|
||||
typeproj: 1,
|
||||
id_main_project: null,
|
||||
id_parent: null,
|
||||
privacyread: server_constants.Privacy.all
|
||||
};
|
||||
|
||||
return await new Project(projmain).save()
|
||||
.then(ris => {
|
||||
console.log('ris', ris);
|
||||
if (!!ris)
|
||||
return ris._doc;
|
||||
else
|
||||
return null;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
ProjectSchema.statics.getAllProjects = async function (userId) {
|
||||
var Project = this;
|
||||
// console.log('getAllProjects');
|
||||
|
||||
let obj = [];
|
||||
|
||||
const projbase = await Project.findById(process.env.PROJECT_ID_MAIN)
|
||||
const projbase = await Project.findOne( { descr: process.env.PROJECT_DESCR_MAIN })
|
||||
.then(ris => {
|
||||
// console.log('ris', ris);
|
||||
if (!!ris._doc)
|
||||
return ris._doc;
|
||||
else
|
||||
return null;
|
||||
if (!!ris) {
|
||||
// console.log('ris', ris);
|
||||
if (!!ris._doc)
|
||||
return ris._doc;
|
||||
else
|
||||
return null;
|
||||
}else {
|
||||
return Project.creaProjMain();
|
||||
}
|
||||
});
|
||||
|
||||
obj.arrproj = await Project.findAllProjByUserId(userId);
|
||||
|
||||
Reference in New Issue
Block a user