GetAllData
public BackendReturnObject GetAllData(string tableName);
public BackendReturnObject GetAllData(string tableName, int limit);
public BackendReturnObject GetAllData(string tableName, int limit, string firstKey);
public BackendReturnObject GetAllData(string tableName, int limit, string firstKey, TableSortOrder tableSortOrder);
public BackendReturnObject GetAllData(string tableName, string[] select);
public BackendReturnObject GetAllData(string tableName, string[] select, int limit);
public BackendReturnObject GetAllData(string tableName, string[] select, int limit, string firstKey);
public BackendReturnObject GetAllData(string tableName, string[] select, int limit, string firstKey, TableSortOrder tableSortOrder);
Parameters
Value | Type | Description | Default |
---|---|---|---|
tableName | string | Name of table to look up | - |
limit | int | (Optional) Number of game information rows to load. Minimum 1, maximum 100. | 10 |
select | string[] | (Optional) Columns to include among existing columns in the row | Includes all columns |
firstKey | string | (Optional) Starting point of data lookup | Data that was inserted last |
sortOrder | TableSortOrder | (Optional) TableSortOrder.DESC(descending order) or TableSortOrder.ASC(ascending order) | TableSortOrder.DESC(descending order) |
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.
- 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.
Example
Synchronous
BackendReturnObject bro = null;
// Load up to 10 rows from tableName
bro = Backend.PlayerData.GetAllData(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 from tableName
bro = Backend.PlayerData.GetAllData(tableName, 1);
// After the 'load up to one row' 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' above is called, load the subsequent data
// (Data will be loaded from latest to oldest.)
bro = Backend.PlayerData.GetAllData(tableName, 1, bro.FirstKeystring());
// If there is more data after the 'load up to one row' above is called, load the subsequent data in descending order
// (Data will be loaded from latest to oldest.)
bro = Backend.PlayerData.GetAllData(tableName, 1, bro.FirstKeystring(), TableSortOrder.DESC);
// Only show columns included in selectList when loading data.
string[] selectList = new string[] { "intData", "doubleData" };
// Load up to 10 rows from tableName (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetAllData(tableName, selectList);
// Load one row from tableName (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetAllData(tableName, selectList, 1);
// If there is more data after the 'load up to one row' 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.GetAllData(tableName, selectList, 1, bro.FirstKeystring());
// If there is more data after the 'load up to one row' above is called, load the subsequent data in descending order
// (Data will be loaded from latest to oldest.)
// (Columns aside from those displayed in selectList will not be displayed.)
bro = Backend.PlayerData.GetAllData(tableName, selectList, 1, bro.FirstKeystring(), TableSortOrder.DESC);
Asynchronous
string[] selectList = new string[] { "intData", "doubleData" };
Backend.PlayerData.GetAllData(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.GetAllData(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.GetAllData(tableName, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
Backend.PlayerData.GetAllData(tableName, 1, callback.FirstKeystring(), TableSortOrder.DESC, callback2 =>
{
// Handled with callback2
});
});
Backend.PlayerData.GetAllData(tableName, selectList, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
});
Backend.PlayerData.GetAllData(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.GetAllData(tableName, selectList, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
Backend.PlayerData.GetAllData(tableName, selectList, 1, callback.FirstKeystring(), TableSortOrder.DESC, callback2 =>
{
// Handled with callback2
});
});
SendQueue
string[] selectList = new string[] { "intData", "doubleData" };
SendQueue.Enqueue(Backend.PlayerData.GetAllData, 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.GetAllData, 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.GetAllData, tableName, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
SendQueue.Enqueue(Backend.PlayerData.GetAllData, tableName, 1, callback.FirstKeystring(), TableSortOrder.DESC, callback2 =>
{
// Handled with callback2
});
});
SendQueue.Enqueue(Backend.PlayerData.GetAllData, tableName, selectList, callback =>
{
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
{
Debug.Log("The data does not exist");
}
});
SendQueue.Enqueue(Backend.PlayerData.GetAllData, 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.GetAllData, tableName, selectList, 1, callback.FirstKeystring(), callback2 =>
{
// Handled with callback2
});
SendQueue.Enqueue(Backend.PlayerData.GetAllData, tableName, selectList, 1, callback.FirstKeystring(), TableSortOrder.DESC, callback2 =>
{
// Handled with callback2
});
});
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":"2023-10-29T13:46:51.305Z","rows":[],"ConsumedCapacity":{"Read":{"CapacityUnits":0.5}}}
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 (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.GetAllData("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());
}