Skip to main content
Version: SDK-6.0.0

TransactionRead

public BackndReturnObject TransactionRead(PlayerTableTransactionRead playerDataTransactionRead)

Parameters

ValueTypeDescriptionDefault
playerDataTransactionReadPlayerTableTransactionReadClass where transaction tasks are stored-

PlayerTableTransactionRead

These are classes that add data-loading commands.

Load one piece of latest data from all data
public PlayerTableTransactionRead AddGetAllLatestData(string tableName);

PlayerTableTransactionRead playerDataTransactionRead = new PlayerTableTransactionRead();

// Data most recently inserted into the table
playerDataTransactionRead.AddGetAllLatestData("SCORE");

Load my data
public PlayerTableTransactionRead AddGetMyLatestData(string tableName);
public PlayerTableTransactionRead AddGetMyData(string tableName, string inDate);

PlayerTableTransactionRead playerDataTransactionRead = new PlayerTableTransactionRead();

// Data most recently inserted into the table by myself
playerDataTransactionRead.AddGetMyLatestData("SCORE");

// Load data with inDate value of "2023-09-14T12:43:54.451Z" from the data I registered
playerDataTransactionRead.AddGetMyData("USER_DATA", "2023-09-14T12:43:54.451Z");

Load another person's data
public PlayerTableTransactionRead AddGetOtherLatestData(string tableName, string owner_inDate);
public PlayerTableTransactionRead AddGetOtherData(string tableName, string inDate, string owner_inDate);

// Obtain the user's owner_inDate by searching the user name
var userBro = Backnd.Player.GetPlayerInfoByDisplayName("nickName");
string otherOwnerIndate = userBro.GetReturnValuetoJSON()["row"]["inDate"].ToString();

PlayerTableTransactionRead playerDataTransactionRead = new PlayerTableTransactionRead();

// Load the most recent data registered by the user with a matching owner_inDate in the table
playerDataTransactionRead.AddGetOtherLatestData("SCORE", otherOwnerIndate);

// Load data with inDate value of "2023-09-14T12:43:54.451Z" from the data registered by the user with a matching owner_inDate in the table
playerDataTransactionRead.AddGetOtherData("USER_DATA", "2023-09-14T12:43:54.451Z", otherOwnerIndate);

Description

The transaction read commands in transactionList are requested to the server.

  • If there is no data that matches the given conditions, an error occurs instead of rows[].
  • If the same row is loaded by a command in playerDataTransactionRead, 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

PlayerTableTransactionRead playerDataTransactionRead = new PlayerTableTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("PUBLIC_DATA");

playerDataTransactionRead.AddGetMyLatestData("ACHIVE_DATA");
playerDataTransactionRead.AddGetMyData("USER_DATA", "2023-09-17T14:16:32.341Z");

var userBro = Backnd.Player.GetPlayerInfoByDisplayName("nickName");
string otherOwnerIndate = userBro.GetReturnValuetoJSON()["row"]["inDate"].ToString();

playerDataTransactionRead.AddGetOtherLatestData("SCORE", otherOwnerIndate);
playerDataTransactionRead.AddGetOtherData("USER_DATA", "2023-09-19T16:21:12.542Z", otherOwnerIndate);

Backnd.PlayerTable.TransactionRead(playerDataTransactionRead);

Asynchronous

PlayerTableTransactionRead playerDataTransactionRead = new PlayerTableTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("PUBLIC_DATA");

playerDataTransactionRead.AddGetMyLatestData("ACHIVE_DATA");
playerDataTransactionRead.AddGetMyData("USER_DATA", "2023-09-17T14:16:32.341Z");

var userBro = Backnd.Player.GetPlayerInfoByDisplayName("nickName");
string otherOwnerIndate = userBro.GetReturnValuetoJSON()["row"]["inDate"].ToString();

playerDataTransactionRead.AddGetOtherLatestData("SCORE", otherOwnerIndate);
playerDataTransactionRead.AddGetOtherData("USER_DATA", "2023-09-19T16:21:12.542Z", otherOwnerIndate);

Backnd.PlayerTable.TransactionRead(playerDataTransactionRead, callback => {

});

ReturnCase

Success cases

When all requests are successful
statusCode : 200
message : Success
returnValue : refer to GetReturnValuetoJSON

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 error that occurs during 'Get,' refer to the relevant developer documentation.

When 2 or more tasks are performed to the same row
statusCode : 400
errorCode : ValidationException
message : Transaction request cannot include multiple operations on one item

When there are over 10 tasks in transactionList, or when there are no tasks
statusCode : 400
errorCode : TransactionSizeError
message : Not Support Transaction Size: {number of tasks in transactionList}

When there is a request that failed to find data because the conditions were not met
statusCode : 404
errorCode : NotFoundException
message : gameInfo not found, gameInfo cannot be found

GetReturnValuetoJSON

{
"Responses": [
{
"stringData": {
"S": "DWW96NRXHI2F"
},
"floatData": {
"N": "0.22267"
},
"dateTimeData": {
"S": "2023-10-30 16:01:11.250"
},
"boolData": {
"BOOL": true
},
"doubleData": {
"N": "0.541407"
},
"inDate": {
"S": "2023-10-30T16:01:11.624Z"
},
"updatedAt": {
"S": "2023-10-30T16:01:11.624Z"
},
"dicData": {
"M": {
"key1": {
"S": "RO3G4CSUSSYP"
},
"key2": {
"S": "XZ48X72RW26H"
},
"key3": {
"S": "7HWQXXSQW9FT"
}
}
},
"owner_inDate": {
"S": "2022-07-18T07:42:46.490Z"
},
"listData": {
"L": [
{
"S": "7OICP9Z8GSGI"
},
{
"S": "1HMC1VSIIX02"
}
]
},
"intData": {
"N": "856602"
}
}
],
"ConsumedCapacity": [
{
"Read": {
"CapacityUnits": 2.5
}
}
]
}

Sample Code

public class GameDataItem
{
public string nickName = Backnd.UserNickName;
public string ownerIndate = Backnd.PlayerInDate;
public string inDate;
public int hp;
public int mp;
public float atk;
public long money;
public Dictionary<string, string> equip = new Dictionary<string, string>();
public List<string> items = new List<string>();
public DateTime lastUpdate;

public GameDataItem()
{
}

public GameDataItem(BACKND.LitJson.JsonData json)
{
hp = int.Parse(json["hp"].ToString());
mp = int.Parse(json["mp"].ToString());
atk = float.Parse(json["atk"].ToString());
money = long.Parse(json["money"].ToString());

foreach(var column in json["equip"].Keys)
{
equip.Add(column, json["equip"][column].ToString());
}

for(int i = 0; i < json["items"].Count; i++)
{
items.Add(json["items"][i].ToString());
}
inDate = json["inDate"].ToString();
lastUpdate = DateTime.Parse(json["lastUpdate"].ToString());
}

public Param ToParam()
{
Param param = new Param();

param.Add("nickName", nickName);
param.Add("hp", hp);
param.Add("mp", mp);
param.Add("atk", atk);
param.Add("money", money);
param.Add("equip", equip);
param.Add("items", items);
param.Add("lastUpdate", DateTime.UtcNow);

return param;
}
public override string ToString()
{
string equipString = "equip\n";
foreach(var dic in equip)
{
equipString += $"-{dic.Key} : {dic.Value}\n";
}

string itemString = "items : ";
for(int i = 0; i < items.Count; i++)
{
itemString += $"{items[i]}, ";
}

return $"hp : {hp}\n" +
$"mp : {mp}\n" +
$"atk : {atk}\n" +
$"money : {money}\n" +
$"lastUpdate : {lastUpdate}\n" +
equipString + "\n" + itemString + "\n";
}
}
public void PlayerTableTransactionReadTest()
{
PlayerTableTransactionRead playerDataTransactionRead = new PlayerTableTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("USER_DATA");

playerDataTransactionRead.AddGetMyData("USER_DATA", "2023-09-17T14:16:32.341Z");

var bro = Backnd.PlayerTable.TransactionRead(playerDataTransactionRead);

if(!bro.IsSuccess())
{
Debug.LogError(bro.ToString());
return;
}

BACKND.LitJson.JsonData gameDataListJson = bro.GetFlattenJSON()["Responses"];

if(gameDataListJson.Count <= 0)
{
Debug.Log("The data does not exist");
return;
}

for(int i = 0; i < gameDataListJson.Count; i++)
{
GameDataItem gameDataItem = new GameDataItem(gameDataListJson[i]);
Debug.Log(gameDataItem.ToString());
}
}