fix update item, lowercase filtering
This commit is contained in:
+5
-3
@@ -66,7 +66,6 @@ app.put('/box/:id', async (request, response) => {
|
||||
app.delete('/box/:id', async (request, response) => {
|
||||
await Box.deleteOne({_id: request.params.id});
|
||||
const updatedBoxes = await getAllBoxes();
|
||||
console.log(updatedBoxes);
|
||||
response.send(updatedBoxes);
|
||||
});
|
||||
|
||||
@@ -84,8 +83,11 @@ app.post('/box/:id/item', async (request, response) => {
|
||||
app.put('/box/:boxId/item/:itemId', async (request, response) => {
|
||||
const boxID = request.params.boxId;
|
||||
const itemID = request.params.itemId;
|
||||
await Box.updateOne({ 'item._id': itemID }, {
|
||||
$set: { item: request.body }
|
||||
await Box.updateOne({ '_id': boxID, 'item._id': itemID }, {
|
||||
$set: {
|
||||
'item.$.name': request.body.name,
|
||||
'item.$.description': request.description
|
||||
}
|
||||
})
|
||||
const updatedBox = await getBox(boxID);
|
||||
response.send(updatedBox);
|
||||
|
||||
Reference in New Issue
Block a user