Skip to main content
Version: 5.11.6

TransactionRead

public BackendReturnObject TransactionRead(PlayerDataTransactionRead playerDataTransactionRead)

Parameters

ValueTypeDescriptionDefault
playerDataTransactionReadPlayerDataTransactionReadClass where transaction tasks are stored-

PlayerDataTransactionRead

These are classes that add data-loading commands.

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

PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

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

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

PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

// 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 PlayerDataTransactionRead AddGetOtherLatestData(string tableName, string owner_inDate);
public PlayerDataTransactionRead AddGetOtherData(string tableName, string inDate, string owner_inDate);

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

PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

// 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

PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("PUBLIC_DATA");

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

var userBro = Backend.Social.GetUserInfoByNickName("nickName");
string otherOwnerIndate = userBro.GetReturnValuetoJSON()["row"]["inDate"].ToString();

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

Backend.PlayerData.TransactionRead(playerDataTransactionRead);

Asynchronous

PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("PUBLIC_DATA");

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

var userBro = Backend.Social.GetUserInfoByNickName("nickName");
string otherOwnerIndate = userBro.GetReturnValuetoJSON()["row"]["inDate"].ToString();

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

Backend.PlayerData.TransactionRead(playerDataTransactionRead, callback => {

});

SendQueue

PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("PUBLIC_DATA");

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

var userBro = Backend.Social.GetUserInfoByNickName("nickName");
string otherOwnerIndate = userBro.GetReturnValuetoJSON()["row"]["inDate"].ToString();

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

Sendqueue.Enqueue(Backend.PlayerData.TransactionRead, playerDataTransactionRead, callback => {

});

ReturnCase

Success cases

When all requests are successful
statusCode : 200

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

When there are over 10 tasks in transactionList, or when there are no tasks
statusCode : 400
errorCode : TransactionSizeError

When there is a request that failed to find data because the conditions were not met
statusCode : 404
errorCode : NotFoundException

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 = Backend.UserNickName;
public string ownerIndate = Backend.UserInDate;
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(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 PlayerDataTransactionReadTest()
{
PlayerDataTransactionRead playerDataTransactionRead = new PlayerDataTransactionRead();

playerDataTransactionRead.AddGetAllLatestData("USER_DATA");

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

var bro = Backend.PlayerData.TransactionRead(playerDataTransactionRead);

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

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());
}
}