Skip to main content
Version: SDK-5.11.6

GetMyData

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

Parameters

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

Description

1 row from the data you own is looked up.

  • The data can be looked up regardless of schema definition status.
  • Only your own data(both public and private) can be looked up.
  • The throughput of the data is the same regardless of whether the select clause is used.

Example

Synchronous

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

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

// Looks up rows with the relevant rowIndate in the table
// Returns only the columns in select
bro = Backend.GameData.GetMyData("tableName", "rowIndate", 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"};

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

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

SendQueue

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

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

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

Return cases

Success cases

When the lookup is successful
statusCode : 200
message : Success
returnValue : refer to GetReturnValuetoJSON

When the lookup succeeds but there is no row with the relevant inDate
statusCode : 200
message : Success
returnValue : {"serverTime":"2021-03-23T07:04:50.114Z","row":{}}

Error cases

When Get is attempted on a non-existent table
statusCode : 404
errorCode : NotFoundException
message : table not found, table cannot be found

When an attempt is made to load to an inactive tableName
statusCode : 412
errorCode : PreconditionFailed
message : inactiveTable prerequisites are not met

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.GetMyData("PlayerInfo", "2022-03-15T07:16:44.031Z");

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