From 19e4f5bc6961df291b68e50d997e4e8f7ef386c1 Mon Sep 17 00:00:00 2001 From: Daniel Vassallo Date: Sat, 2 Nov 2019 10:54:25 -0700 Subject: [PATCH] Update transaction docs --- src/pages/docs_sdk_transaction.html | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pages/docs_sdk_transaction.html b/src/pages/docs_sdk_transaction.html index 147c6aa..50dd145 100644 --- a/src/pages/docs_sdk_transaction.html +++ b/src/pages/docs_sdk_transaction.html @@ -1,12 +1,22 @@

SDK : Transaction

-
-    userbase.transaction(databaseName, operations)
-  .then(() => {
+  

Transaction 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.

- }) - .catch((e) => console.error(e))
+
+    
+    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))
+    
   

Parameters

@@ -16,7 +26,7 @@ databaseName [string | Len: 1-50] - The database name to use.
  • - operations [Array] - The Insert, Update, or Delete operations to execute in an atomic transaction. + operations [Array] - The Insert, Update, or Delete operations to execute as an atomic transaction.