-
Notifications
You must be signed in to change notification settings - Fork 279
Add transactions API docs #2459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d4572f2
add transactions API docs
ebenezerdon e6ab7cb
add more languages
ebenezerdon 68dc92e
add more languages
ebenezerdon 4f3c32f
Merge branch 'main' into docs-transaction-api
ebenezerdon c10f7f1
make section clearer
ebenezerdon 50a2dca
update python import
ebenezerdon 700d99e
update file
ebenezerdon 910bf34
add more language examples
ebenezerdon c97fd41
remove duplicate java and kotlin code
ebenezerdon ba82638
add more languages
ebenezerdon 6af1607
add more languages
ebenezerdon a2a3fbe
add more languages
ebenezerdon 6845339
Merge branch 'main' into docs-transaction-api
ebenezerdon 32c1c8f
fixes for feedback
ebenezerdon 945927a
Merge branch 'main' into docs-transaction-api
ebenezerdon f980abe
address comments + correct mistakes
atharvadeosthale f8655dd
add column to increment/decrement
atharvadeosthale 74b8397
remove bulkDelete example
atharvadeosthale 7235405
add section on limts
ebenezerdon 22a59e4
update transaction operations section to include bulk versions of met…
ebenezerdon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,4 +262,131 @@ When deleting rows, you must specify queries to filter which rows to delete. | |
| If no queries are provided, all rows in the table will be deleted. | ||
| [Learn more about queries](/docs/products/databases/queries). | ||
|
|
||
| {% /info %} | ||
| {% /info %} | ||
|
|
||
| # Use transactions {% #use-transactions %} | ||
|
|
||
| All bulk operations accept `transactionId`. When provided, Appwrite stages the bulk request and applies it on commit. See [Transactions](/docs/products/databases/transactions). | ||
|
|
||
| {% multicode %} | ||
| ```server-nodejs | ||
| await tablesDB.createRows('<DATABASE_ID>', '<TABLE_ID>', [ | ||
| { $id: sdk.ID.unique(), data: { name: 'One' } }, | ||
|
||
| { $id: sdk.ID.unique(), data: { name: 'Two' } } | ||
| ], { transactionId: '<TRANSACTION_ID>' }); | ||
abnegate marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| ```server-python | ||
| tablesDB.update_rows( | ||
abnegate marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| database_id = '<DATABASE_ID>', | ||
| table_id = '<TABLE_ID>', | ||
| data = { 'status': 'published' }, | ||
| queries = [ Query.equal('status', 'draft') ], | ||
| transaction_id = '<TRANSACTION_ID>' | ||
| ) | ||
| ``` | ||
| ```server-deno | ||
| await tablesDB.createRows('<DATABASE_ID>', '<TABLE_ID>', [ | ||
| { $id: sdk.ID.unique(), data: { name: 'One' } }, | ||
| { $id: sdk.ID.unique(), data: { name: 'Two' } } | ||
| ], { transactionId: '<TRANSACTION_ID>' }); | ||
abnegate marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| ```server-php | ||
| $tablesDB->createRows( | ||
| databaseId: '<DATABASE_ID>', | ||
| tableId: '<TABLE_ID>', | ||
| rows: [ | ||
| [ '$id' => ID::unique(), 'data' => [ 'name' => 'One' ] ], | ||
| [ '$id' => ID::unique(), 'data' => [ 'name' => 'Two' ] ] | ||
| ], | ||
| transactionId: '<TRANSACTION_ID>' | ||
| ); | ||
| ``` | ||
| ```server-ruby | ||
| tablesDB.create_rows( | ||
| database_id: '<DATABASE_ID>', | ||
| table_id: '<TABLE_ID>', | ||
| rows: [ | ||
| { '$id' => ID.unique(), 'data' => { 'name' => 'One' } }, | ||
| { '$id' => ID.unique(), 'data' => { 'name' => 'Two' } } | ||
| ], | ||
| transaction_id: '<TRANSACTION_ID>' | ||
| ) | ||
| ``` | ||
| ```server-dotnet | ||
| await tablesDB.CreateRows( | ||
| databaseId: "<DATABASE_ID>", | ||
| tableId: "<TABLE_ID>", | ||
| rows: new List<Dictionary<string, object>> | ||
| { | ||
| new Dictionary<string, object> | ||
| { | ||
| ["$id"] = ID.Unique(), | ||
| ["data"] = new Dictionary<string, object> { ["name"] = "One" } | ||
| }, | ||
| new Dictionary<string, object> | ||
| { | ||
| ["$id"] = ID.Unique(), | ||
| ["data"] = new Dictionary<string, object> { ["name"] = "Two" } | ||
| } | ||
| }, | ||
| transactionId: "<TRANSACTION_ID>" | ||
| ); | ||
| ``` | ||
| ```server-dart | ||
| await tablesDB.createRows( | ||
| databaseId: '<DATABASE_ID>', | ||
| tableId: '<TABLE_ID>', | ||
| rows: [ | ||
| { '\$id': ID.unique(), 'data': { 'name': 'One' } }, | ||
| { '\$id': ID.unique(), 'data': { 'name': 'Two' } } | ||
| ], | ||
| transactionId: '<TRANSACTION_ID>' | ||
| ); | ||
| ``` | ||
| ```server-swift | ||
| let _ = try await tablesDB.createRows( | ||
| databaseId: "<DATABASE_ID>", | ||
| tableId: "<TABLE_ID>", | ||
| rows: [ | ||
| ["$id": ID.unique(), "data": ["name": "One"]], | ||
| ["$id": ID.unique(), "data": ["name": "Two"]] | ||
| ], | ||
| transactionId: "<TRANSACTION_ID>" | ||
| ) | ||
| ``` | ||
| ```server-kotlin | ||
| val _ = tablesDB.createRows( | ||
| databaseId = "<DATABASE_ID>", | ||
| tableId = "<TABLE_ID>", | ||
| rows = listOf( | ||
| mapOf("\$id" to ID.unique(), "data" to mapOf("name" to "One")), | ||
| mapOf("\$id" to ID.unique(), "data" to mapOf("name" to "Two")) | ||
| ), | ||
| transactionId = "<TRANSACTION_ID>" | ||
| ) | ||
| ``` | ||
| ```server-java | ||
| Map<String, Object> row1 = new HashMap<>(); | ||
| row1.put("$id", ID.unique()); | ||
| row1.put("data", new HashMap<String, Object>() {{ put("name", "One"); }}); | ||
|
|
||
| Map<String, Object> row2 = new HashMap<>(); | ||
| row2.put("$id", ID.unique()); | ||
| row2.put("data", new HashMap<String, Object>() {{ put("name", "Two"); }}); | ||
|
|
||
| tablesDB.createRows( | ||
| "<DATABASE_ID>", | ||
| "<TABLE_ID>", | ||
| Arrays.asList(row1, row2), | ||
| "<TRANSACTION_ID>", | ||
| new CoroutineCallback<>((result, error) -> { | ||
| if (error != null) { | ||
| error.printStackTrace(); | ||
| return null; | ||
| } | ||
| System.out.println(result); | ||
| return null; | ||
| }) | ||
| ); | ||
abnegate marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| {% /multicode %} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.