Skip to main content
Version: 5.9.6

GetV2

public BackendReturnObject GetV2(string tableName, string inDate, string owner_inDate);
public BackendReturnObject GetV2(string tableName, string inDate, string owner_inDate, string[] select);

Parameters

ValueTypeDescriptionDefault
tableNamestringName of table to look up-
inDatestringinDate value of the row to look up-
owner_inDatestringinDate of the user who owns the row-
selectstring[](Optional) A value to show only a specific column among the rows to look upIncludes all columns

Description

From the values stored in the table, the rows whose values in the inDate column match the user's owner_inDate are searched.

  • The data can be looked up regardless of schema definition status.
  • Both public and private data can be looked up.
  • In the case of a private table, you can look up only your own data.
  • The throughput of the data is the same regardless of whether the select clause is used.
    You can import your owner_inDate via { Backend.UserInDate }.

Example

Synchronous

// When returning through the use of select[], set to print only owner_inDate and score
string[] select = {"owner_inDate", "score"};

//Your owner_inDate
string owner_inDate = Backend.UserInDate;
// Other's owner_inDate
string owner_inDate = "2018-07-06T05:22:41.000Z";

// Looks up rows with the relevant rowIndate in the table
var bro = Backend.GameData.GetV2("tableName", "rowIndate", owner_inDate);
Debug.Log(bro);

// Looks up rows with the relevant rowIndate in the table
// Returns only the columns in select
bro = Backend.GameData.GetV2("tableName", "rowIndate", owner_inDate , select);
Debug.Log(bro);

Asynchronous

// When returning through the use of select[], set to print only owner_inDate and score
string[] select = {"owner_inDate", "score"};

//Your owner_inDate
string owner_inDate = Backend.UserInDate;
// Other's owner_inDate
string owner_inDate = "2018-07-06T05:22:41.000Z";

// Looks up rows with the relevant rowIndate in the table
Backend.GameData.GetV2("tableName", "rowIndate", owner_inDate , (callback) =>
{
Debug.Log(callback);
});

// Looks up rows with the relevant rowIndate in the table
// Returns only the columns in select
Backend.GameData.GetV2("tableName", "rowIndate", owner_inDate , select, (callback) =>
{
Debug.Log(callback);
});

SendQueue

// When returning, set to print only owner_inDate and score
string[] select = {"owner_inDate", "score"};

//Your owner_inDate
string owner_inDate = Backend.UserInDate;
// Other's owner_inDate
string owner_inDate = "2018-07-06T05:22:41.000Z";

// Looks up rows with the relevant rowIndate in the table
SendQueue.Enqueue(Backend.GameData.GetV2,"tableName", "rowIndate", owner_inDate , (callback) =>
{
Debug.Log(callback);
});

// Looks up rows with the relevant rowIndate in the table
// Returns only the columns in select
SendQueue.Enqueue(Backend.GameData.GetV2, "tableName", "rowIndate", owner_inDate , select, (callback) =>
{
Debug.Log(callback);
});

Return cases

Success cases

When the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

When the lookup succeeds but there is no row with the relevant inDate
statusCode : 200

returnValue : {"serverTime":"2021-03-23T07:04:50.114Z","row":{}}

Error cases

When Get is attempted on a non-existent table
statusCode : 404
errorCode : NotFoundException

When an attempt is made to load to an inactive tableName
statusCode : 412
errorCode : PreconditionFailed

GetReturnValuetoJSON

{
// Server time when the server processed the request
"serverTime":"2021-03-23T06:39:46.519Z",
// Returned data
"row": {
// 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"
},
... // Data stored in the client
}
}

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 GetInDate()
{
var bro = Backend.GameData.GetV2("PlayerInfo", "2022-03-15T07:16:44.031Z", Backend.UserInDate);

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

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

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

GameDataItem gameDataItem = new GameDataItem(gameDataListJson);
Debug.Log(gameDataItem.ToString());
}