Update transaction docs
This commit is contained in:
@@ -1,12 +1,22 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<h2><a href="/docs/#sdk">SDK</a> : Transaction</h2>
|
<h2><a href="/docs/#sdk">SDK</a> : Transaction</h2>
|
||||||
|
|
||||||
<pre>
|
<p><span class="font-semibold">Transaction</span> lets you submit multiple database operations as a single atomic batch. Either all operations succeed, or the entire batch fails. You will never see partial updates. This API will return a promise that gets resolved once the transaction has been fully applied and durably persisted in the database.</p>
|
||||||
<code class="language-javascript">userbase.transaction(databaseName, operations)
|
|
||||||
.then(() => {
|
|
||||||
|
|
||||||
})
|
<pre>
|
||||||
.catch((e) => console.error(e))</code>
|
<code class="language-javascript">
|
||||||
|
const operations = [
|
||||||
|
{ command: 'Update', item: { todo: 'Item A' }, id: '0001' },
|
||||||
|
{ command: 'Insert', item: { todo: 'Item B' }, id: '0002' },
|
||||||
|
{ command: 'Delete', item: { todo: 'Item C' }, id: '0003' }
|
||||||
|
]
|
||||||
|
|
||||||
|
userbase.transaction(databaseName, operations)
|
||||||
|
.then(() => {
|
||||||
|
// transaction applied
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e))
|
||||||
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3 id="params">Parameters</h3>
|
<h3 id="params">Parameters</h3>
|
||||||
@@ -16,7 +26,7 @@
|
|||||||
<span class="field">databaseName</span> [string | Len: 1-50] - The database name to use.
|
<span class="field">databaseName</span> [string | Len: 1-50] - The database name to use.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="field">operations</span> [Array] - The Insert, Update, or Delete operations to execute in an atomic transaction.
|
<span class="field">operations</span> [Array] - The Insert, Update, or Delete operations to execute as an atomic transaction.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user