Skip to main content
Version: SDK-5.9.6

GetMyData

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

Parameters

ValueTypeDescriptionDefault
tableNamestringName of table to look up-
whereWhereThe where clause to search-
limitint(Optional) Number of game information rows to load. Minimum 1, maximum 100.10
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

Your own data 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.

Look up all data without conditions

To search all data without conditions, declare 'where,' which is passed as a parameter value, as new Where().

Example 1

Looks up all of your data without conditions

Synchronous

var bro = Backend.GameData.GetMyData("tableName", new Where(), 10);S
if (bro.IsSuccess() == false)
{
// Request handled as failure
Debug.Log(bro);
return;
}
if (bro.GetReturnValuetoJSON()["rows"].Count <= 0)
{
// Even if the request succeeds, there might not be a piece of data that meets the where condition
// Therefore, you must confirm that the corresponding piece of data exists
// In the case of the new Where() condition example above, the Count may be 0 or less if there is no row in the table.
Debug.Log(bro);
return;
}
// Checks the inDate value of all rows for the searched data
for (int i = 0; i < bro.Rows().Count; ++i)
{
string inDate = bro.FlattenRows()[0]["inDate"].ToString();
Debug.Log(inDate);
}

Asynchronous

Backend.GameData.GetMyData("tableName", new Where(), 10, bro =>
{
if (bro.IsSuccess() == false)
{
// Request handled as failure
Debug.Log(bro);
return;
}
if (bro.GetReturnValuetoJSON()["rows"].Count <= 0)
{
// Even if the request succeeds, there might not be a piece of data that meets the where condition
// Therefore, you must confirm that the corresponding piece of data exists
// In the case of the new Where() condition example above, the Count may be 0 or less if there is no row in the table.
Debug.Log(bro);
return;
}
// Checks the inDate value of all rows for the searched data
for (int i = 0; i < bro.Rows().Count; ++i)
{
string inDate = bro.FlattenRows()[0]["inDate"].ToString();
Debug.Log(inDate);
}
});

SendQueue

SendQueue.Enqueue(Backend.GameData.GetMyData, "tableName", new Where(), 10, bro =>
{
if (bro.IsSuccess() == false)
{
// Request handled as failure
Debug.Log(bro);
return;
}
if (bro.GetReturnValuetoJSON()["rows"].Count <= 0)
{
// Even if the request succeeds, there might not be a piece of data that meets the where condition
// Therefore, you must confirm that the corresponding piece of data exists
// In the case of the new Where() condition example above, the Count may be 0 or less if there is no row in the table.
Debug.Log(bro);
return;
}
// Checks the inDate value of all rows for the searched data
for (int i = 0; i < bro.Rows().Count; ++i)
{
string inDate = bro.FlattenRows()[0]["inDate"].ToString();
Debug.Log(inDate);
}
});

Example 2

Searches for the piece of data that meets certain conditions in your data

Synchronous

// Looks up the piece of data that has 'weapon' as the type column
// and has 'dragon' at the start of the name column
Where where = new Where();
where.Equal("type", "weapon");
where.BeginsWith("name", "dragon");

var bro = Backend.GameData.GetMyData("tableName", where, 10);
if (bro.IsSuccess() == false)
{
// Request handled as failure
Debug.Log(bro);
return;
}
if (bro.GetReturnValuetoJSON()["rows"].Count <= 0)
{
// Even if the request succeeds, there might not be a piece of data that meets the where condition
// Therefore, you must confirm that the corresponding piece of data exists
// In the case of the new Where() condition example above, the Count may be 0 or less if there is no row in the table.
Debug.Log(bro);
return;
}
//1st way to extract data : Print the name column of the first piece of data among the searched data
string name = bro.Rows()[0]["name"]["S"].ToString();
int level = Int32.Parse(bro.Rows()[0]["level"]["N"].ToString());

//2nd way to extract data (unmarshalling): Print the name column of the first piece of data among the searched data
string name = bro.FlattenRows()[0]["name"].ToString();
int level = Int32.Parse(bro.FlattenRows()[0]["level"].ToString());


Debug.Log(name);

Asynchronous

// Looks up the piece of data that has 'weapon' as the type column
// and has 'dragon' at the start of the name column
Where where = new Where();
where.Equal("type", "weapon");
where.BeginsWith("name", "dragon");

Backend.GameData.GetMyData("tableName", where, 10, bro =>
{
if (bro.IsSuccess() == false)
{
// Request handled as failure
Debug.Log(bro);
return;
}
if (bro.GetReturnValuetoJSON()["rows"].Count <= 0)
{
// Even if the request succeeds, there might not be a piece of data that meets the where condition
// Therefore, you must confirm that the corresponding piece of data exists
// In the case of the new Where() condition example above, the Count may be 0 or less if there is no row in the table.
Debug.Log(bro);
return;
}
//1st way to extract data : Print the name column of the first piece of data among the searched data
string name = bro.Rows()[0]["name"]["S"].ToString();
int level = Int32.Parse(bro.Rows()[0]["level"]["N"].ToString());

//2nd way to extract data (unmarshalling): Print the name column of the first piece of data among the searched data
string name = bro.FlattenRows()[0]["name"].ToString();
int level = Int32.Parse(bro.FlattenRows()[0]["level"].ToString());
});

SendQueue

// Looks up the piece of data that has 'weapon' as the type column
// and has 'dragon' at the start of the name column
Where where = new Where();
where.Equal("type", "weapon");
where.BeginsWith("name", "dragon");

SendQueue.Enqueue(Backend.GameData.GetMyData, "tableName", where, 10, bro =>
{
if (bro.IsSuccess() == false)
{
// Request handled as failure
Debug.Log(bro);
return;
}
if (bro.GetReturnValuetoJSON()["rows"].Count <= 0)
{
// Even if the request succeeds, there might not be a piece of data that meets the where condition
// Therefore, you must confirm that the corresponding piece of data exists
// In the case of the new Where() condition example above, the Count may be 0 or less if there is no row in the table.
Debug.Log(bro);
return;
}
//1st way to extract data : Print the name column of the first piece of data among the searched data
string name = bro.Rows()[0]["name"]["S"].ToString();
int level = Int32.Parse(bro.Rows()[0]["level"]["N"].ToString());

//2nd way to extract data (unmarshalling): Print the name column of the first piece of data among the searched data
string name = bro.FlattenRows()[0]["name"].ToString();
int level = Int32.Parse(bro.FlattenRows()[0]["level"].ToString());
});

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 data meeting the relevant 'where' search condition statusCode : 200 message : Success returnValue : {"serverTime":"2021-03-23T07:07:01.235Z","rows":[],"firstKey":null}

Error cases

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

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

GetReturnValueToJSON

{
// Server time when the server processed the request
"serverTime":"2021-03-23T06:39:46.519Z",
// Returned data
"rows":[
{
// 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
},
// and etc...
],

// null when firstKey does not exist
"firstKey":null

// When firstKey exists
// "firstKey" : {"inDate":{"S":"2021-03-23T04:54:45.849Z"}}}
}

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(JsonData json)
{
hp = Int32.Parse(json["hp"].ToString());
mp = Int32.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 GetWhereTest()
{
var bro = Backend.GameData.GetMyData("PlayerInfo", new Where());

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

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