Skip to content

Commit 68df378

Browse files
committed
Update API.html
1 parent e0dc3b0 commit 68df378

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

public/API.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,19 @@ <h3 id="overwrite">Overwrite</h3>
809809

810810
<p>
811811
RERUM allows the Generator of a record to overwrite that record. An error will be returned if the agent encoded in the request "Authorization" access token does not match the <code __rerum.generatedBy></code> agent of the existing record. </span>
812-
813812
Replace a record using a reference to its internal RERUM id and receive the <code class="language-plaintext highlighter-rouge">Location</code> URI for the resulting record as a response header and the complete record as the response body.
814-
815813
This will have the effects of update, set, and unset actions. New keys will be created and keys not present in the request will not be present in the resulting record.
816-
817814
The record is replaced in place, or overwritten, and so the <code class="language-plaintext highlighter-rouge">@id</code> will not change and the history connected with this record will not be altered. The <code>__rerum.isOverwritten</code> property will be set to the date and time of the overwrite.
818815
</p>
816+
<p>
817+
This endpoint supports optimistic locking, if requested. Including the "If-Overwritten-Version" header with the
818+
value of the <code class="language-plaintext highlighter-rouge">__rerum.isOverwritten</code> property of the
819+
record will cause the request to fail if the record has been overwritten since that time.
820+
This is useful for preventing overwriting a record that has been changed by another agent, colliding within an
821+
application that rapidly requests overwrites of the same object, or if an object is held in memory or cache for a
822+
long time prior to the overwrite. Omitting the "If-Overwritten-Version" header or <code class="language-plaintext highlighter-rouge">__rerum.isOverwritten</code>
823+
property will cause the request to succeed regardless.
824+
</p>
819825

820826
<table>
821827
<thead>
@@ -865,6 +871,12 @@ <h3 id="overwrite">Overwrite</h3>
865871
</code></pre>
866872
</p>
867873

874+
<p class="alert">
875+
In the case of an optimistic locking failure, the response will be a 409 Conflict with a
876+
body containing the current version of the document, in case you would like to automate a
877+
retry of the overwrite request.
878+
</p>
879+
868880
<p>
869881
<div class="exHeading">Here is what the response <code>resp</code> looks like:</div>
870882
<pre><code class="respExample">
@@ -878,12 +890,11 @@ <h3 id="overwrite">Overwrite</h3>
878890
<span>}</span>
879891
</code></pre>
880892
<p class="alert">
881-
Note that resp.headers.get("location") will return "https://devstore.rerum.io/v1/id/abcdef1234567890"
893+
Note: resp.headers.get("location") will return "https://devstore.rerum.io/v1/id/abcdef1234567890"
882894
</p>
883895
<p class="alert">
884-
Note that the <code>@id</code> and <code>__rerum.history</code> properties of the original record "https://devstore.rerum.io/v1/id/abcdef1234567890" have not changed. This is the difference between /update and /overwrite. Be careful.
896+
Note: the <code>@id</code> and <code>__rerum.history</code> properties of the original record "https://devstore.rerum.io/v1/id/abcdef1234567890" have not changed. This is the difference between /update and /overwrite. Be careful.
885897
</p>
886-
887898
</p>
888899

889900
<!--

0 commit comments

Comments
 (0)