fix update item, lowercase filtering

This commit is contained in:
np.w
2020-12-12 17:47:14 -06:00
parent 4350ac87a9
commit f3da826395
5 changed files with 28 additions and 21 deletions
+5 -3
View File
@@ -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);