clean more pt 2

This commit is contained in:
np.w
2021-02-19 20:01:02 -06:00
parent 5bab7525b8
commit 52b22ebcae
+1 -4
View File
@@ -116,7 +116,6 @@ app.delete('/box/:boxId/item/:itemId', async (request, response) => {
app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => { app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => {
const itemID = request.params.itemId; const itemID = request.params.itemId;
const targetBoxID = request.params.boxIdTarget; const targetBoxID = request.params.boxIdTarget;
const query = { _id: targetBoxID };
//the way I am doing this cannot be the best way...fix me later //the way I am doing this cannot be the best way...fix me later
try { try {
@@ -127,7 +126,7 @@ app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => {
//remove item from source box //remove item from source box
await Box.updateOne({ _id: box[0]._id }, { $pull: { item: { _id: itemID } } }); await Box.updateOne({ _id: box[0]._id }, { $pull: { item: { _id: itemID } } });
//add item to target box //add item to target box
await Box.updateOne(query, { $push: { item: item[0].item[0] } }); await Box.updateOne({ _id: targetBoxID }, { $push: { item: item[0].item[0] } });
const boxes = await getAllBoxes(); const boxes = await getAllBoxes();
response.send(boxes); response.send(boxes);
@@ -135,8 +134,6 @@ app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => {
catch (error) { catch (error) {
response.json(error); response.json(error);
} }
/*...*/
}) })
/*------------/CONTROLLER------------*/ /*------------/CONTROLLER------------*/