title: REST API a request to add/subtract from a field
body: <p>What's considered best for an hydration resource that saves each day, in which the user may add/subtract the amount he drank during that specific day. each resource row in the database looks like:</p>
  <p>userid, date, amount</p>
  <p>1, 2021-05-23 1000</p>
  <p>a. A single PUT method that:</p>
  <ol>
  <li>Creates the resource (with the given amount) if it doesn't exist yet for the particular date.</li>
  <li>Updates the resource whole amount</li>
  <li>Deletes the resource for that date if the amount is below 0.</li>
  </ol>
  <p>b. A POST request to create the resource with the given amount, and a PATCH request to update the whole amount and delete if the amount is below 0</p>
  <p>c. A POST request to create the resource with the given amount and a PATCH request to update the amount like:</p>
  <pre><code>{
     &quot;operation&quot;: &quot;add&quot;/&quot;subtract&quot;,
     &quot;amount&quot;: 200
  }
  </code></pre>
  <p>And again if the amount falls below 0 then delete the resource</p>
  <p>d. Other possible solution?</p>
  <p>I don't see how DELETE is related here because the user doesn't type the amount he drank, he can add/remove a given amount so I'm trying to figure out what works best for this scenario.</p>
  <p><strong>EDIT:</strong></p>
  <p>The api will function as a backend for an android app. The user will see a few built-in buttons. 100 ml, 300 ml, 500 ml &amp; custom amount.</p>
  <p>As he clicks one of these the amount should increase. on the database it will be saved as a single row BUT the user will see a one entry for each click.</p>
  <p>My question is what's the best way for doing such thing. is a PATCH or PUT that does a DELETE if the amount is below 0 considered normal? what's better, POST and then PATCH or PUT?</p>
  <p>another possible solution that is similar to opt. C, Is to just remove the operation field and allow the amount to be either positive or negative, and that should simplify things a little but is it ok?</p>