Skip to main content
Version: 5.9.6

TransactionReadV2

public BackendReturnObject TransactionReadV2(TransactionValue[] transactionList);
public BackendReturnObject TransactionReadV2(List<TransactionValue> transactionList);

Parameters

ValueTypeDescription
transactionListTransactionValue[] (Selection) Arrays transaction tasks
transactionListList<TransactionValue>(Selection) List where transaction tasks are stored

Description

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

  • Up to 10 tasks can be grouped into 1 unit.
  • Upon searching data using inDate, you may only use the tasks of SetGetV2 instead of SetGet.
  • 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.
  • When multiple pieces of data are searched with the where condition, only 1 piece of data that has been inserted most recently will be returned.
  • An error may occur if the pieces of data to be searched are identical even under different where conditions.

Example

List< TransactionValue >

List<TransactionValue> transactionList = new List<TransactionValue>();

//When the data belongs to you
transactionList.Add(TransactionValue.SetGetV2("tableName", "row_indate", Backend.UserInDate));

//When the data belongs to another person
transactionList.Add(TransactionValue.SetGetV2("tableName", "row_indate", "owner_inDate"));

Where where = new Where();
where.Equal("nickname","BACKND Boy");
transactionList.Add(TransactionValue.SetGet("tableName", where));

Where where2 = new Where();
where2.Less("level",10);
where2.Contains("guildName","BACKND Adventure Guild");
transactionList.Add(TransactionValue.SetGet("tableName", where2));

Synchronous

Backend.GameData.TransactionReadV2(transactionList);  

Asynchronous

Backend.GameData.TransactionReadV2(transactionList, (callback) => 
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.GameData.TransactionReadV2, transactionList, (callback) => 
{
// Post-process
});

Return cases

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 task other than the Get command in transactionList
statusCode : 400
errorCode : TransactionDataError

If there is a SetGet task using the inDate in the transactionList(must use SetGetV2.)
statusCode : 400
errorCode : TransactionDataError

GetReturnValuetoJSON

{
// Returned data
"Responses":[
// Data that underwent transactionList.Add first
{
// inDate of the user who owns the row
"owner_inDate":{
"S":"2019-07-31T06:15:35.691Z"
},
// Time when the row was inserted
"client_date":{
"S":"2021-03-23T04:54:45.709Z"
},
// inDate of the row
"inDate":{
"S":"2021-03-23T04:54:45.849Z"
},
// Time when the row was last updated
"updatedAt":{
"S":"2021-03-23T04:54:45.849Z"
},
"score":{
"N":"1234"
},
"item1":{
"S":"Longsword"
},
... // Data stored in the client
},
// Data that underwent transactionList.Add second
{
// inDate of the user who owns the row
"owner_inDate":{
"S":"2019-03-21T01:15:35.621Z"
},
// Time when the row was inserted
"client_date":{
"S":"2021-03-13T02:54:45.709Z"
},
// inDate of the row
"inDate":{
"S":"2021-03-13T04:54:45.849Z"
},
// Time when the row was last updated
"updatedAt":{
"S":"2021-03-23T04:54:45.849Z"
},
"item1":{
"S":"BACKND Boys Sword"
},
... // Data stored in the client
},
// and etc...
}
]
}

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 TransactionReadV2()
{
List<TransactionValue> transactionList = new List<TransactionValue>();

transactionList.Add(TransactionValue.SetGetV2("PlayerInfo", "2022-03-15T07:16:44.131Z", "2021-11-16T06:57:55.552Z"));

transactionList.Add(TransactionValue.SetGet("PlayerInfo", new Where()));

var bro = Backend.GameData.TransactionReadV2(transactionList);

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