Skip to content

Commit

Permalink
PUT request to add subjects to knowledge group
Browse files Browse the repository at this point in the history
  • Loading branch information
nehal96 committed Jul 23, 2019
1 parent edaee1c commit 872cb94
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const app = express();

mongoose.connect(
keys.mongoURI,
{ useNewUrlParser: true }
{ useNewUrlParser: true, useFindAndModify: false }
);

app.use(bodyParser.json());
Expand Down
25 changes: 25 additions & 0 deletions routes/knowledgeGroupRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,29 @@ module.exports = app => {
}
});
});

// PUT request to add a knowledge map subject into a knowledge group
app.put("/api/knowledge-group/:knowledgeGroupId/add-subject", (req, res) => {
const { knowledgeGroupId } = req.params;
const { knowledgeMapId } = req.body;

KnowledgeGroup.findOneAndUpdate(
knowledgeGroupId,
{
$push: {
subjects: knowledgeMapId
}
},
{
new: true
},
(error, data) => {
if (error) {
res.send(error);
} else {
res.send(data);
}
}
);
});
};

0 comments on commit 872cb94

Please sign in to comment.