TransactionWrite
public BackndReturnObject TransactionWrite(PlayerTableTransactionWrite playerDataTransactionWrite);
Parameter
Value | Type | Description | Default |
---|---|---|---|
playerDataTransactionWrite | PlayerTableTransactionWrite | Class where transaction tasks are stored | - |
PlayerTableTransactionWrite
These are classes that add commands so data registration, modification, and deletion can be requested all at once.
Add data
public PlayerTableTransactionWrite AddInsert(string tableName, Param param);
PlayerTableTransactionWrite transactionWrite = new PlayerTableTransactionWrite();
Param param = new Param();
param.Add("level", 10);
param.Add("hp",20);
// Insert one piece of data
transactionWrite.AddInsert("USER_DATA", param);
Param param2 = new Param();
param2.Add("score", 100000);
transactionWrite.AddInsert("SCORE", param2);
Modify data
public PlayerTableTransactionWrite AddUpdateMyLatestData(string tableName, Param param);
public PlayerTableTransactionWrite AddUpdateMyData(string tableName, string inDate, Param param);
public PlayerTableTransactionWrite AddUpdateOtherData(string tableName, string inDate, string owner_inDate, Param param);
PlayerTableTransactionWrite transactionWrite = new PlayerTableTransactionWrite();
Param param = new Param();
param.Add("level", 10);
param.Add("hp",20);
transactionWrite.AddUpdateMyLatestData("USER_DATA", param);
Param param2 = new Param();
param2.Add("score", 10);
// 2023-10-30T08:34:49.925Z is the row value of the data added by yourself in the SCORE table.
transactionWrite.AddUpdateMyData("SCORE", "2023-10-30T08:34:49.925Z", param2);
Param param3 = new Param();
param3.Add("level", 10);
param3.Add("hp",20);
// 2023-10-30T08:34:49.925Z is the row value of the data registered by a user with identical "2022-09-10T04:54:12.314Z" and owner_inDate in the SCORE table.
// 2022-09-10T04:54:12.314Z is the user's unique ID.
transactionWrite.AddUpdateOtherData("SCORE", "2023-10-30T08:34:49.925Z", "2022-09-10T04:54:12.314Z", param3);
Delete data
public PlayerTableTransactionWrite AddDeleteMyLatestData(string tableName);
public PlayerTableTransactionWrite AddDeleteMyData(string tableName, string inDate);
public PlayerTableTransactionWrite AddDeleteOtherData(string tableName, string inDate, string owner_inDate);
PlayerTableTransactionWrite transactionWrite = new PlayerTableTransactionWrite();
transactionWrite.AddDeleteMyLatestData("USER_DATA");
// 2023-10-30T08:34:49.925Z is the row value of the data added by yourself in the SCORE table.
transactionWrite.AddDeleteMyData("SCORE", "2023-10-30T08:34:49.925Z");
// 2023-10-30T08:34:49.925Z is the row value of the data registered by a user with identical "2022-09-10T04:54:12.314Z" and owner_inDate in the SCORE table.
// 2022-09-10T04:54:12.314Z is the user's unique ID.
transactionWrite.AddDeleteOtherData("SCORE", "2023-10-30T08:34:49.925Z", "2022-09-10T04:54:12.314Z");
Description
Transaction commands existing in playerDataTransactionWrite are requested to the server.
- If there are commands in playerDataTransactionWrite for modifying or deleting the same row data, an error occurs.
- Up to 10 tasks can be grouped into 1 unit.
- When at least one request in the task list has an error, all requests will fail.
- For all requests to be handled as success, all requests must succeed.
Example
Synchronous
PlayerTableTransactionWrite transactionWrite = new PlayerTableTransactionWrite();
Param param = new Param();
param.Add("level", 10);
param.Add("hp",20);
// Insert one piece of data
transactionWrite.AddInsert("USER_DATA", param);
Param param2 = new Param();
param2.Add("score", 10);
// Modify one piece of data
transactionWrite.AddUpdateMyLatestData("SCORE", param2);
// Delete one piece of data
transactionWrite.AddDeleteMyLatestData("TEMP_DATA");
Backnd.PlayerTable.TransactionWrite(transactionWrite);
Asynchronous
PlayerTableTransactionWrite transactionWrite = new PlayerTableTransactionWrite();
Param param = new Param();
param.Add("level", 10);
param.Add("hp",20);
// Insert one piece of data
transactionWrite.AddInsert("USER_DATA", param);
Param param2 = new Param();
param2.Add("score", 10);
// Modify one piece of data
transactionWrite.AddUpdateMyLatestData("SCORE", param2);
// Delete one piece of data
transactionWrite.AddDeleteMyLatestData("TEMP_DATA");
Backnd.PlayerTable.TransactionWrite(transactionWrite, callback => {
// Subsequent logic
});
ReturnCase
Success cases
When 'Insert' is included in the request and all requests are successful
statusCode : 200
returnValue :
{"putItem":[{"table":"Table name of first AddInserted","inDate":"inDate value of created data"},{"table":"Table name of second AddInserted","inDate":"2023-10-30T09:00:52.209Z"},...],"ConsumedCapacity":[{"Write":{"CapacityUnits":18},"Read":{"CapacityUnits":0}}]}
When all requests are successful
statusCode : 200
returnValue :
{"putItem":[],"ConsumedCapacity":[{"Write":{"CapacityUnits":6},"Read":{"CapacityUnits":1}}]}
Error cases
When an error occurs in at least 1 task while performing a transaction task
An error corresponding to the error situation will be returned.
For the errors that occur during Insert/Update/Delete, refer to the developer documentation relevant to each error.
When 2 or more tasks are performed to the same row
statusCode : 400
errorCode : ValidationException
When there are over 10 tasks in transactionList, or when there are no tasks
statusCode : 400
errorCode : TransactionSizeError
When there is a task other than the Get command in transactionList
statusCode : 400
errorCode : TransactionDataError
When there is a modify/delete task in transactionList that uses inDate without the use of V2
statusCode : 400
errorCode : TransactionDataError
When the size of the data to be modified is over 4 MB/When the total number of columns to be modified is over 290
statusCode : 400
errorCode : ValidationException