Skip to content

Commit

Permalink
update for rotating locations
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinovpankaj committed Apr 7, 2024
1 parent d637006 commit cf49ee4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion model/projectDAO.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ module.exports = {
}
});
},

addUpdateChildInSingleLevelProject: async (projectId, childId,childData) => {
return await mongo.Projects.updateOne({ _id: new ObjectId(projectId),"sections._id":ObjectId(childId) }, {
$set: {
"sections.$": childData
}
},{upsert:true}
);
},
addUpdateProjectChild : async (projectId, childId, childData)=>{
return await mongo.Projects.findOneAndUpdate({_id:ObjectId(projectId),"children._id":ObjectId(childId)},
{
Expand Down
2 changes: 1 addition & 1 deletion service/sectionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const editSetion = async (sectionId, section) => {
// sectionId,
// sectionFromDB
// );
await updateParentHelper.addUpdateSectionMetadataFromParent(
await updateParentHelper.addUpdateSectionMetadataInParent(
sectionId,
sectionFromDB
);
Expand Down
2 changes: 1 addition & 1 deletion service/subProjectService.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const editSubProject = async (subProjectId,subproject) => {
//await updateParentHelper.removeSubprojectMetaDataInProject(subProjectId,subProjectFromDB);
//await updateParentHelper.addSubprojectMetaDataInProject(subProjectId,subProjectFromDB);

await updateParentHelper.addRemoveSubProjectMetadataInProject(subProjectId,subProjectFromDB);
await updateParentHelper.addUpdateSubProjectMetadataInProject(subProjectId,subProjectFromDB);
return {
success: true,
};
Expand Down
10 changes: 5 additions & 5 deletions service/updateParentHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const removeSectionMetadataFromParent = async (sectionId, section) => {
);
}
};
const addUpdateSectionMetadataFromParent = async (sectionId,section)=>{
const addUpdateSectionMetadataInParent = async (sectionId,section)=>{
const sectionDataInParent = {
_id:sectionId,
name: section.name,
Expand All @@ -154,7 +154,7 @@ const addUpdateSectionMetadataFromParent = async (sectionId,section)=>{
};

if (section.parenttype == "project") {
await ProjectDAO.addChildInSingleLevelProject(
await ProjectDAO.addUpdateChildInSingleLevelProject (
section.parentid,
sectionId,
sectionDataInParent
Expand Down Expand Up @@ -218,7 +218,7 @@ const removeSubprojectMetaDataInProject = async (subProjectId, subProject) => {
);
};

const addRemoveSubProjectMetadataInProject = async (subProjectId, subProject) => {
const addUpdateSubProjectMetadataInProject = async (subProjectId, subProject) => {
const subProjectDataInParent = {
_id: subProject._id,
name: subProject.name,
Expand All @@ -242,8 +242,8 @@ module.exports = {
removeSectionMetadataFromParent,
addSubprojectMetaDataInProject,
removeSubprojectMetaDataInProject,
addRemoveSubProjectMetadataInProject,
addUpdateSubProjectMetadataInProject,
addUpdateLocationMetadataInParent,
addUpdateSectionMetadataFromParent,
addUpdateSectionMetadataInParent,
addUpdateSubprojectMetaDataInProject
};

0 comments on commit cf49ee4

Please sign in to comment.