C
C#2y ago
_vegabyte_

❔ Need some advise regarding HTTP Request

Hello, I have a few operations here and would appreciate some guidance on how to carry them out. I therefore have a payer table. It has a column for the remaining balance. Additionally, I have a contribution table where the funds from payers go. I must update the Payer's remaining Balance if the payer adds a contribution (HTTP POST). Should I have to make two APIs? 1. Making a Contribution 2. Updating the balance that remains Or a single API that updates the remaining balance and create contributions?
16 Replies
Henkypenky
Henkypenky2y ago
you should separate this because one is chained to the other it's a conditional case 1 yes -> case 2 yes case 1 no -> case 2 no also update sounds more like a patch not a post you probably have to affect more tables so yes post + patch
_vegabyte_
_vegabyte_OP2y ago
Oh yes! I understand now!
Henkypenky
Henkypenky2y ago
for transaction history + balances
_vegabyte_
_vegabyte_OP2y ago
Patch kinda new to me. I will make some research on this one
Henkypenky
Henkypenky2y ago
is your balance calculated every time or do you store it?
_vegabyte_
_vegabyte_OP2y ago
stored
Henkypenky
Henkypenky2y ago
then patch
_vegabyte_
_vegabyte_OP2y ago
what is the difference between put?
Henkypenky
Henkypenky2y ago
patch = partial put = total Name: John Doe Age: 21 Address: No Number 22 Patch: Name = Jane Doe Put: Name = Jane Doe Age = 21 Address: No Number 22 if u do put wrong you mess everything up if you do Put: Name: Jane Doe then do get you will only get Name: Jane Doe depends on the system you might get everything else null, don't know the outcomes but it's bad put modifies the entire entity, patch only modifies it partially post creates entities
_vegabyte_
_vegabyte_OP2y ago
so if i only modify the Balance its recommended to use patch
Henkypenky
Henkypenky2y ago
if you are not modifying the entire entity always patch
_vegabyte_
_vegabyte_OP2y ago
Yes, thankyou very much. It is a big help to me! Didn't knoe there is a way like this!
Henkypenky
Henkypenky2y ago
the exact definition of put is modify the entire entity or create it so it's kinda like a post with steroids very dangerous
_vegabyte_
_vegabyte_OP2y ago
I will take note on this. Thank you very much!
Henkypenky
Henkypenky2y ago
Ok
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server