Docs : SDK : putTransaction
putTransaction 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 to the database.
userbase.putTransaction({
databaseName: 'example-database-name',
operations: [
{ command: 'Insert', item: { example: 'Sample Item A' } },
{ command: 'Update', item: { example: 'Sample Item B' }, itemId: '0002' },
{ command: 'Delete', itemId: '0003' }
]
}).then(() => {
// transaction applied
}).catch((e) => console.error(e))
Parameters
-
databaseName [string | Len: 1-100] - The database name to use.
-
operations [Array | Len: 1-10] - The insert, update, or delete operations to execute as an atomic transaction. There is a limit of 10 operations per transaction.
Advanced Parameters
-
shareToken [string | optional] - The token used to access a shared database.
-
databaseId [string | optional] - The database's unique identifier.
Errors
- ParamsMustBeObject
- DatabaseNotOpen
- DatabaseNameMissing
- DatabaseNameMustBeString
- DatabaseNameCannotBeBlank
- DatabaseNameTooLong
- DatabaseNameRestricted
- DatabaseIdMustBeString
- DatabaseIdCannotBeBlank
- DatabaseIdInvalidLength
- DatabaseIdNotAllowed
- DatabaseIsReadOnly
- OperationsMissing
- OperationsMustBeArray
- OperationsConflict
- OperationsExceedLimit
- CommandNotRecognized
- ItemIdMissing
- ItemIdMustBeString
- ItemIdCannotBeBlank
- ItemIdTooLong
- ItemMissing
- ItemInvalid
- ItemTooLarge
- ItemAlreadyExists
- ItemDoesNotExist
- ItemUpdateConflict
- TransactionUnauthorized
- UserNotSignedIn
- UserNotFound
- TooManyRequests
- ServiceUnavailable