Skip to main content
Version: 5.11.8

GetMyData

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

Parameters

ValueTypeDescriptionDefault
tableNamestringName of table to look up-
limitint(Optional) Number of game information rows to load. Minimum 1, maximum 100.10
inDatestringinDate value of the row to look up-
owner_inDatestringinDate of the user who owns the row-
selectstring[](Optional) Columns to include among existing columns in the rowIncludes all columns
firstKeystring(Optional) Starting point of data lookupData that was inserted last

Description

Among the values saved in the table, all values equal to the number of limits are loaded.

  • The data can be looked up regardless of schema definition status.
  • Both public and private data can be looked up.
  • The throughput of the data is the same regardless of whether the select clause is used.

Example

Synchronous

 BackendReturnObject bro = null;

// Load up to 10 rows added by myself from tableName
bro = Backend.PlayerData.GetMyData(tableName);
// When loading fails
if(bro.IsSuccess() == false)
{
Debug.Log("An issue occurred while reading data : " + bro.ToString());
}
// When loading is successful but data does not exist
if(bro.IsSuccess() && bro.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
// When more than one piece of data is loaded
if(bro.FlattenRows().Count > 0)
{
string inDate = bro.FlattenRows()[0]["inDate"].ToString();
int level = int.Parse(bro.FlattenRows()[0]["level"].ToString());
}
// Load up to one row added by myself from tableName
bro = Backend.PlayerData.GetMyData(tableName, 1);

// After the 'load up to one row added by myself' above is called, check if there are older pieces of data below to load additionally
if(bro.HasFirstKey() == false)
{
Debug.Log("The data to be loaded does not exist");
}

// If there is more data after the 'load up to one row added by myself' above is called, load the subsequent data
// (Data will be loaded from latest to oldest.)
bro = Backend.PlayerData.GetMyData(tableName, 1, bro.FirstKeystring());


// Only show columns included in selectList when loading data.
string[] selectList = new string[] { "intData", "doubleData" };

// Load up to 10 rows added by myself from tableName (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetMyData(tableName, selectList);

// Load up to one row added by myself from tableName (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetMyData(tableName, selectList, 1);

// If there is more data after the 'load up to one row added by myself' above is called, load the subsequent data
// (Data will be loaded from latest to oldest.)
// (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetMyData(tableName, selectList, 1, bro.FirstKeystring());

// From the loaded values called above, load the data with a matching inDate
bro = Backend.PlayerData.GetMyData(tableName, bro.FlattenRows()[0]["inDate"].ToString());

// From the loaded values called above, load the data with a matching inDate (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetMyData(tableName, bro.FlattenRows()[0]["inDate"].ToString(), selectList);

Asynchronous


string[] selectList = new string[] { "intData", "doubleData" };

Backend.PlayerData.GetMyData(tableName, callback =>
{
if(callback.IsSuccess() == false)
{
Debug.Log("An issue occurred while reading data : " + callback.ToString());
}
// When loading is successful but data does not exist
if(callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
// When more than one piece of data is loaded
if(callback.FlattenRows().Count > 0)
{
string inDate = callback.FlattenRows()[0]["inDate"].ToString();
int level = int.Parse(callback.FlattenRows()[0]["level"].ToString());
}
});

Backend.PlayerData.GetMyData(tableName, 1, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
return;
}

if(callback.HasFirstKey() == false)
{
Debug.Log("The data to be read next does not exist");
return;
}
Backend.PlayerData.GetMyData(tableName, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
});


Backend.PlayerData.GetMyData(tableName, selectList, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
});

Backend.PlayerData.GetMyData(tableName, selectList, 1, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
return;
}
if(callback.HasFirstKey() == false)
{
Debug.Log("The data to be read next does not exist");
return;
}

Backend.PlayerData.GetMyData(tableName, selectList, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
});

// From the loaded values called above, load the data with a matching inDate
Backend.PlayerData.GetMyData(tableName, bro.FlattenRows()[0]["inDate"].ToString(), callback =>
{

});
// From the loaded values called above, load the data with a matching inDate (Columns aside from those displayed in selectList will not be displayed.)
Backend.PlayerData.GetMyData(tableName, bro.FlattenRows()[0]["inDate"].ToString(), selectList, callback =>
{

});

SendQueue


string[] selectList = new string[] { "intData", "doubleData" };

SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, callback =>
{
if(callback.IsSuccess() == false)
{
Debug.Log("An issue occurred while reading data : " + callback.ToString());
}
// When loading is successful but data does not exist
if(callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
// When more than one piece of data is loaded
if(callback.FlattenRows().Count > 0)
{
string inDate = callback.FlattenRows()[0]["inDate"].ToString();
int level = int.Parse(callback.FlattenRows()[0]["level"].ToString());
}
});

SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, 1, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
return;
}

if(callback.HasFirstKey() == false)
{
Debug.Log("The data to be read next does not exist");
return;
}
SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
});


SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, selectList, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
});

SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, selectList, 1, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
return;
}
if(callback.HasFirstKey() == false)
{
Debug.Log("The data to be read next does not exist");
return;
}

SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, selectList, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
});

// From the loaded values called above, load the data with a matching inDate
SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, bro.FlattenRows()[0]["inDate"].ToString(), callback =>
{

});
// From the loaded values called above, load the data with a matching inDate (Columns aside from those displayed in selectList will not be displayed.)
SendQueue.Enqueue(Backend.PlayerData.GetMyData, tableName, bro.FlattenRows()[0]["inDate"].ToString(), selectList, callback =>
{

});

ReturnCase

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:07:01.235Z","rows":[],"firstKey":null}

Error cases

When the inDate is string.Empty upon executing GetMyData using inDate
statusCode : 400
errorCode : ClientException

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 (Values within rows all differ depending on the data.)

{
"serverTime": "2023-10-29T13:09:53.832Z",
"rows": [
{
"stringData": {
"S": "57J5EO3CJOGE"
},
"floatData": {
"N": "0.17887"
},
"dateTimeData": {
"S": "2023-10-29 13:09:53.401"
},
"boolData": {
"BOOL": true
},
"doubleData": {
"N": "0.139331"
},
"inDate": {
"S": "2023-10-29T13:09:53.543Z"
},
"updatedAt": {
"S": "2023-10-29T13:09:53.545Z"
},
"dicData": {
"M": {
"key1": {
"S": "JQZB3TY7LUNE"
},
"key2": {
"S": "QZOUGY1PVIR6"
},
"key3": {
"S": "EBCWMSVZKKOM"
}
}
},
"owner_inDate": {
"S": "2022-07-18T07:42:46.490Z"
},
"listData": {
"L": [
{
"S": "WJOLDW7Q1TXW"
},
{
"S": "15XFDY0PSJTF"
},
{
"S": "SWTBY0LTRBGB"
}
]
},
"intData": {
"N": "108684"
}
}
],
// Time to load next after loading has expired
"firstKey": {
"inDate": {
"S": "2023-10-29T13:09:53.543Z"
}
},
"ConsumedCapacity": {
"Read": {
"CapacityUnits": 0.5,
"GlobalSecondaryIndexes": {
"partition-inDate-index": {
"CapacityUnits": 0.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 GetInDate()
{
var bro = Backend.PlayerData.GetMyData("PlayerInfo");

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

LitJson.JsonData gameDataListJson = bro.FlattenRows();

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

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