Skip to main content
Version: SDK-5.11.4

Insert

public BackendReturnObject Insert(string tableName);
public BackendReturnObject Insert(string tableName, Param param);

Parameters

ValueTypeDescription
tableNamestringName of table where the game information will be stored
paramParamContent to be stored in the game information

Description

A row is added to the table.

  • The row is bound to the user who inserted that row.
  • The data can be inserted regardless of the schema definition status.
  • Both public and private data can be inserted.
  • When inserting schema, null or the default value is entered if the value is empty.
  • For numerical data, you can safely input numbers up to 9,007,199,254,740,991(approximately 9 quadrillion).
    When your input data exceeds the limit above, place values in units and tens are rounded down to 0.
    As the number increases and place values expand, small numbers are rounded down, and large numbers are maintained up to 16 - 18 digits, based on the left.
    For long, the data is saved as shown below:
    12345678912345678 -> 12345678912345678(within the limit of 9 quadrillion, the input number is maintained)
    123456789123456789 -> 123456789123456780(exceeds the limit of 9 quadrillion, the last digit is rounded down)
    1234567891234567891 -> 1234567891234568000
    9223372036854775807 -> 9223372036854776000(the maximum value for 'long')
    When saving an integer with double to save a larger piece of data, the number is displayed as shown below:
    12345678912345678912 -> 12345678912345678000(the 'double' larger than the maximum value of 'long')
    123456789123456789123.0 -> 123456789123456800000
    1234567891234567891234.0 -> 123456789123456800000000
    1.23456789123457E+29 -> 123456789123457000000000000000
    In the case of receiving the number from the client(C#), it may be changed to an exponent format.
    12345678912345678000 -> 1.23456789123457E+19

Reserved column

When saving, eight fields, including partition, gamer_id, inDate, updatedAt, sender, receiver, reservationDate, and owner_inDate, are used by the server.
If this column is included in the param, the value in the param is ignored and the value used by the server is stored.

ValueDescriptionWhether the value is displayed in BACKND Console
partitionValue used by the server to classify a table.X
gamer_idGamer ID of the row owner.O
inDateinDate of the row.(Key value.)O
updatedAtTime the table was last modified.O
senderValue used internally for BACKND function(e.g., mail)X
receiverValue used internally for BACKND function(e.g., mail)X
reservationDateValue used internally for BACKND function(e.g., mail)X
owner_inDateUser inDate of the row owner.O

Example

param

Param lunch = new Param();
lunch.Add("how much", 332);
lunch.Add("when", "yesterday");
lunch.Add("what", "eat chocolate");

Dictionary<string, int> dic = new Dictionary<string, int>
{
{ "dic1", 1 },
{ "dic4", 2 },
{ "dic2", 4 }
};

Dictionary<string, string> dic2 = new Dictionary<string, string>
{
{ "mm", "j" },
{ "nn", "n" },
{ "dd", "2" }
};

String[] list = { "a", "b" };
int[] list2 = { 400, 500, 600 };

Param param = new Param();
param.Add("name", "cheolsu");
param.Add("score", 99);
param.Add("lunch", lunch);
param.Add("dic_num", dic);
param.Add("dic_string", dic2);
param.Add("list_string", list);
param.Add("list_num", list2);

Synchronous

Backend.GameData.Insert("tableName", param);

Asynchronous

Backend.GameData.Insert("tableName", param, (callback) => 
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.GameData.Insert, "tableName", param, (callback) => 
{
// Post-process
});

Return cases

Success cases

When the table is inserted successfully
statusCode : 200
message : Success
returnValue : {"inDate":"inDate of the inserted table"}
e.g.) returnValue : {"inDate":"2020-06-10T09 : 26 : 21.738Z"}

Error cases

(Schema) When the data type of the column declared upon defining the schema is different from that of the column to be inserted and updated
statusCode : 400
errorCode : BadParameterException
message : bad {column name} dataType, Invalid {column name} dataType

(Schema) When there is an attempt to insert a column whose schema is not defined
statusCode : 400
errorCode : BadParameterException
message : bad column does not exist., The column does not exist

(Schema) When the size of the list selected upon declaring the list column in the schema is different from the size of the list entered in param
statusCode : 400
errorCode : BadParameterException
message : bad list data length, Invalid list data length

(Schema) When the size of the map selected upon declaring the map column in the schema is different from the size of the map entered in param
statusCode : 400
errorCode : BadParameterException
message : bad map data length, Invalid map data length

When the total number of columns to be inserted exceeds 290
statusCode : 400
errorCode : ValidationException
message : Invalid UpdateExpression: Expression size has exceeded the maximum allowed size;

When an attempt is made to insert into a non-existent table
statusCode : 404
errorCode : NotFoundException
message : table not found, table cannot be found

When there is an attempt to insert into a deactivated tableName
statusCode : 412
errorCode : PreconditionFailed
message : inactiveTable prerequisites are not met.

When the size of the data to be inserted exceeds 400 KB
statusCode : 413
errorCode : ServerErrorException
message : request entity too large

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 InsertTest()
{
GameDataItem gameData = new GameDataItem();

gameData.hp = 1000;
gameData.mp = 0;
gameData.atk = 231.23f;
gameData.money = 100000000000;
gameData.equip = new Dictionary<string, string>() { { "head", "itemID231" }, { "arms", "itemID192" }, { "legs", "itemID001" }, { "body", "itemID337" } };
gameData.items = new List<string>() { "itemID231", "itemID341", "itemID12", "itemID124", "itemID331", "itemID228", "itemID775", "itemID479" };

Param param = gameData.ToParam();

var bro = Backend.GameData.Insert("PlayerInfo", param);

if(bro.IsSuccess())
{
string playerInfoIndate = bro.GetInDate();
Debug.Log("My playerInfo's indate : " + playerInfoIndate);
}
else
{
Debug.LogError("Failed to insert game information : " + bro.ToString());
}
}