Inventory Infrastructure and Example for Suits #10
@ -13,13 +13,14 @@ const inventoryController: RequestHandler = async (request: Request, response: R
|
||||
|
||||
console.log(accountId);
|
||||
|
||||
const inventory = await Inventory.findOne({ accountOwnerId: accountId }); // has the accountOwnerId field to find a corresponding inventory
|
||||
const inventoryJSON = inventory?.toJSON();
|
||||
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() ?. checks for undefined! ?. checks for undefined!
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() good suggestion! good suggestion!
![]() I understand now what you mean I understand now what you mean
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
|
||||
|
||||
![]() remove log remove log
|
||||
if (!inventoryJSON) {
|
||||
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() ?. checks for undefined! ?. checks for undefined!
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() good suggestion! good suggestion!
![]() I understand now what you mean I understand now what you mean
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
|
||||
if (!inventory) {
|
||||
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() ?. checks for undefined! ?. checks for undefined!
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() good suggestion! good suggestion!
![]() I understand now what you mean I understand now what you mean
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
|
||||
response.status(400).json({ error: "inventory was undefined" });
|
||||
return;
|
||||
}
|
||||
|
||||
const inventoryJSON = inventory.toJSON();
|
||||
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() ?. checks for undefined! ?. checks for undefined!
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() good suggestion! good suggestion!
![]() I understand now what you mean I understand now what you mean
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
|
||||
|
||||
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() ?. checks for undefined! ?. checks for undefined!
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() good suggestion! good suggestion!
![]() I understand now what you mean I understand now what you mean
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
|
||||
const inventoreResponse = toInventoryResponse(inventoryJSON); // remove the accountOwnerId for the response
|
||||
|
||||
response.json(inventoreResponse);
|
||||
|
||||
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() i dont think the comment is necessary
i dont think the comment is necessary
```suggestion
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
```
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() check if inventory is undefined before trying check if inventory is undefined before trying `toJson()`
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() it is important, because it is not present in the original response. it is important, because it is not present in the original response.
![]() ?. checks for undefined! ?. checks for undefined!
![]() ?. checks for undefined! ?. checks for undefined!
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious. this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() that's why you check before so you dont two undefined checks that's why you check before so you dont two undefined checks
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() it explains a lot. I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there. The purpose of the field is explained: it exists to find an account's corresponding inventory. it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
![]() good suggestion! good suggestion!
![]() good suggestion! good suggestion!
![]() I understand now what you mean I understand now what you mean
![]() I understand now what you mean I understand now what you mean
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
![]() should that belong then inside inventoryModel.ts? should that belong then inside inventoryModel.ts?
|
i dont think the comment is necessary
i dont think the comment is necessary
check if inventory is undefined before trying
toJson()
check if inventory is undefined before trying
toJson()
it is important, because it is not present in the original response.
it is important, because it is not present in the original response.
?. checks for undefined!
?. checks for undefined!
this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
this comment doesn't explain nothing, it says its using accountOwnerId to find an inventory which is obvious.
that's why you check before so you dont two undefined checks
that's why you check before so you dont two undefined checks
it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
it explains a lot.
I added the field accountOwnerId and everyone who knows the inventory structure would know the field is not originally there.
The purpose of the field is explained: it exists to find an account's corresponding inventory.
good suggestion!
good suggestion!
I understand now what you mean
I understand now what you mean
should that belong then inside inventoryModel.ts?
should that belong then inside inventoryModel.ts?