Continue Refactoring and Testing the API and add a new Entity

I started this week by implementing the category API as part of my ongoing refactoring of the item API. The ability to query the category list, category by id, and other list has been implemented. In addition, I’ve introduced the ability to generate random items from the HTTP POST request using the item API. This API will generate random things with the item name “item” and a randomly generated GUID value when the user uses it. Furthermore, it will also generate more details for the item. It will also generate new brands and new categories when the user first uses the HTTP POST request. When the user uses this HTTP POST request to generate random items for the second time, it will not generate new brands and categories.

Mr. Peter suggested that I restructure the detail query once I had completed implementing the API for categories and the command for creating random items. He stated that there are several drawbacks when querying an item by its MongoDB ObjectID, which is why this query will take a long time. He advised me to use the barcode as a basis for my query to obtain the item detail since it is a unique value. In addition, he recommended that I combine the two query item lists: which is the primary query item list using the search name and the secondary query item list based on details into one. This is due to the fact that these two queries’ codes are quite similar.

I tested the item API using the Postman tool after I had made the necessary changes to it in accordance with sir’s advice. However, there is an error since I do not add the MongoDB connection variable to the docker. As a result, the server is unable to connect to the actual server. I therefore inserted the variable with the proper format, “mongodb://username:password@host:port,” to the docker file. After entering the variable for MongoDB, I rebuild the docker-compose and use the Postman to test the API again.

Adding the new entity to the retail system is my final task for this week. The name, id, code, and foreign key id will be its four properties. The link between the new entity and the store will be one to many, meaning that each store may have multiple entities. But every entity will only be associated with one store. The entity will have the feature of creating, updating, and deleting commands as well as the feature of querying list, and detail by id. Since I haven’t completed implementing this entity, I will continue to do this task next week.

Leave a Reply