DalvinCodes / tenant-management

Create and Manage Tenants of WATTBA
0 stars 0 forks source link

[FIX] Tenant Management API - Fix the Update Function in Tenant Management API to Preserve Existing Field Values During MongoDB $set Operation #110

Open DalvinCodes opened 1 year ago

DalvinCodes commented 1 year ago

Description: As a developer, I want to fix the Update function in the Tenant Management API to address the issue where sending a struct to the function results in setting the document field values as nil, empty, or default during the MongoDB $set operation. This behavior leads to unintended updates where existing field values are overwritten.

To resolve this issue, modifications need to be made to the Update function. When updating a tenant with a struct, the function should ensure that value fields are preserved during the $set operation. This means that if a field in the struct is not provided or has a nil, empty, or default value, the existing value in the MongoDB document should be preserved instead of being updated to the nil, empty, or default value.

It is important to handle partial updates properly, ensuring that only the specified fields are updated while preserving the existing values for other fields. This will prevent unintended data loss or undesired changes in the tenant records.

Thorough testing should be conducted to validate the functionality and reliability of the fixed Update function. The tests should cover various scenarios, including full updates and partial updates, to ensure that the preservation of existing field values during the $set operation is working as expected.

Finally, the documentation should be updated to include the details of the fixed Update function and provide guidance on how to properly update tenant fields while preserving existing values. This will assist other developers in understanding the updated behavior and using the Update function effectively in the Tenant Management API.

DalvinCodes commented 1 year ago

Acceptance Criteria: