Transactions is now available as part of our Early Access Program (EAP). To start testing this feature, sign up using this form.
Transactions is an experimental feature offered for testing and feedback purposes. This feature is unsupported and subject to change without notice. Do not use transactions in apps that handle sensitive information, including personal data and customer data.
For more details, see Forge EAP, Preview, and GA.
Transactions allow you to perform multiple operations in a single transaction, ensuring that all operations are either committed or rolled back together. This works with data stored through the Key-Value Store's basic methods:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import { kvs } from '@forge/kvs'; await kvs.transact() // set first key with value .set('key1', 'value1') // delete second key .delete('key2') //set third key with value .set('key3', 'value3') //commit the transaction .execute();
This page covers transaction usage for Key-Value Store. For transactions with the Custom Entity Store, see here.
Data stored through transactions must still follow limits defined in Forge hosted storage key and object size limits.
Adds an operation to the transaction to set a JSON value with a specified key.
1 2transact.set(key: string, value: array | boolean | number | object | string): TransactionBuilder;
1 2// array kvs.transact().set('example-key', [ 'Hello', 'World' ]) // boolean kvs.transact().set('example-key', true); // number kvs.transact().set('example-key', 123); // object kvs.transact().set('example-key', { hello: 'world' }); // string kvs.transact().set('example-key', 'Hello world');
Deletes a value by key, this succeeds whether the key exists or not.
1 2transact.delete(key: string): TransactionBuilder;
1 2kvs.transact().delete('example-key');
Rate this page: