Skip to main content
Version: 5.11.8

TransactionWrite

public BackendReturnObject TransactionWrite(PlayerDataTransactionWrite playerDataTransactionWrite);

Parameter

ValueTypeDescriptionDefault
playerDataTransactionWritePlayerDataTransactionWriteClass where transaction tasks are stored-

PlayerDataTransactionWrite

These are classes that add commands so data registration, modification, and deletion can be requested all at once.

Add data
public PlayerDataTransactionWrite AddInsert(string tableName, Param param);

PlayerDataTransactionWrite transactionWrite = new PlayerDataTransactionWrite();

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 PlayerDataTransactionWrite AddUpdateMyLatestData(string tableName, Param param);
public PlayerDataTransactionWrite AddUpdateMyData(string tableName, string inDate, Param param);
public PlayerDataTransactionWrite AddUpdateOtherData(string tableName, string inDate, string owner_inDate, Param param);

PlayerDataTransactionWrite transactionWrite = new PlayerDataTransactionWrite();

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 PlayerDataTransactionWrite AddDeleteMyLatestData(string tableName);
public PlayerDataTransactionWrite AddDeleteMyData(string tableName, string inDate);
public PlayerDataTransactionWrite AddDeleteOtherData(string tableName, string inDate, string owner_inDate);

PlayerDataTransactionWrite transactionWrite = new PlayerDataTransactionWrite();
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

PlayerDataTransactionWrite transactionWrite = new PlayerDataTransactionWrite();

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");

Backend.PlayerData.TransactionWrite(transactionWrite);

Asynchronous

PlayerDataTransactionWrite transactionWrite = new PlayerDataTransactionWrite();

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");

Backend.PlayerData.TransactionWrite(transactionWrite, callback => {
// Subsequent logic
});

SendQueue

PlayerDataTransactionWrite transactionWrite = new PlayerDataTransactionWrite();

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");

SendQueue.Enqueue(Backend.PlayerData.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