Skip to content

Commit

Permalink
delete all transit nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
polroti committed Mar 16, 2024
1 parent 608e3f5 commit b360fe6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions components/places/controller/transitNodeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports.createTransiteNode = (req, res, next) => {

exports.checkIfTransitNodeExistsByNameEn = (req, res, next) => {
TransiteNode.findOne({
name_en: req.name_en,
name_en: req.body.name_en,
})
.exec()
.then((foundTrNode) => {
Expand Down Expand Up @@ -59,7 +59,7 @@ exports.generatePlaceId = (req, res, next) => {
// Concatenate the prefix, first three characters, and numeric part
const generatedId = req.body.province + firstThreeChars + randomNumericPart;

req.place_id = generatedId.toUpperCase() + "454545454";
req.place_id = generatedId.toUpperCase();

next();
};
Expand All @@ -71,7 +71,7 @@ exports.checkIfTransitNodeExistsByPlaceId = (req, res, next) => {
.exec()
.then((foundTrNode) => {
if (foundTrNode) {
console.log(req.place_id);
console.log(foundTrNode);
res.status(409).json({
error: "Transit Node already exists",
code: "TRANSIT_NODE_EXISTS",
Expand All @@ -81,3 +81,11 @@ exports.checkIfTransitNodeExistsByPlaceId = (req, res, next) => {
}
});
};

exports.deleteAllTransitNodes = (req, res, next) =>{
TransiteNode.deleteMany().exec().then(()=>{
res.status(200).json({
"msg": "deleted all TR nodes"
})
})
}
4 changes: 4 additions & 0 deletions components/places/routes/transitNodeRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ routes.post('/add',
tNodeController.checkIfTransitNodeExistsByPlaceId,
tNodeController.createTransiteNode);

//warning! only for dev purposes
routes.delete('/delete/all',
tNodeController.deleteAllTransitNodes)

module.exports = routes;

0 comments on commit b360fe6

Please sign in to comment.