UpdateWithCalculationV2
public BackendReturnObject UpdateWithCalculationV2(string tableName, string inDate, string owner_inDate, Param param);
Parameters
Value | Type | Description |
---|---|---|
tableName | string | Table name to be updated |
inDate | string | inDate value of the row to be updated |
owner_inDate | string | inDate of the user who owns the row |
param | Param | Information to be updated (inserts data using AddCalculation) |
Description
From the values stored in the table, the rows whose values in the inDate column match the user's owner_inDate are searched and calculated using the four fundamental arithmetic operations.
- The data can be modified regardless of schema definition status.
- You can only modify your own public/private data.
- You can modify the public data of others.
- You cannot modify the private data of others.
You can import your owner_inDate via { Backend.UserInDate }.
The number type data stored in the table are modified via the four fundamental arithmetic operations.
You can add, subtract, multiply, or divide the base value by the number you enter.
- When using this method, the parameter's param must only use AddCalculation(). (Typing Add() will cause an error.)
- Modification of game information can be performed for only one row.
- When multiple rows are found with the 'where' query, the most recently inserted row will be modified.
- You cannot modify the private table of others. (Available for public tables)
- Update() only requires the data to be modified; however, in the case of UpdateWithCalculation(), you may experience a heavier usage of DB compared to Update because the process checks and modifies the numbers of the data.
Reserved column
When saving, eight fields, including partition, gamer_id, inDate, updatedAt, sender, receiver, reservationDate, owner_inDate, client_date, are used by the server.
When these columns are included in the param, an error occurs.
Value | Description | Whether the value is displayed in BACKND Console |
---|---|---|
partition | Value used by the server to classify a table | X |
gamer_id | Gamer ID of the row owner | O |
inDate | inDate of the row (key value) | O |
updatedAt | Time the table was last modified | O |
sender | Value used internally for BACKND function (e.g., mail) | X |
receiver | Value used internally for BACKND function (e.g., mail) | X |
reservationDate | Value used internally for BACKND function (e.g., mail) | X |
owner_inDate | User inDate of the row owner | O |
client_date | The time when the client first requested data creation | O |
In the case of old version tables' rows without the owner_inDate, an owner_inDate column is added when the rows are updated by using the corresponding method.
Example
Synchronous
Param updateParam = new Param();
updateParam.AddCalculation("atk", GameInfoOperator.addition, 10); // Add 10 to atk of the existing data
updateParam.AddCalculation("def", GameInfoOperator.subtraction, 20); // Subtract 20 from the def of the existing data
// Perform four fundamental arithmetic operations on your inDate row
Backend.GameData.UpdateWithCalculationV2("tableName", inDate, Backend.UserInDate, updateParam);
//Perform four fundamental arithmetic operations on other's inDate row
Backend.GameData.UpdateWithCalculationV2("tableName", inDate, "owner_inDate", updateParam);
Asynchronous
Param updateParam = new Param();
updateParam.AddCalculation("atk", GameInfoOperator.addition, 10); // Add 10 to atk of the existing data
updateParam.AddCalculation("def", GameInfoOperator.subtraction, 20); // Subtract 20 from the def of the existing data
//Perform four fundamental arithmetic operations on your inDate row
Backend.GameData.UpdateWithCalculationV2("tableName", inDate, Backend.UserInDate, updateParam, callback =>
{
// Post-process
});
//Perform four fundamental arithmetic operations on other's inDate row
Backend.GameData.UpdateWithCalculationV2("tableName", inDate, "owner_inDate", updateParam ,callback =>
{
// Post-process
});
SendQueue
Param updateParam = new Param();
updateParam.AddCalculation("atk", GameInfoOperator.addition, 10); // Add 10 to atk of the existing data
updateParam.AddCalculation("def", GameInfoOperator.subtraction, 20); // Subtract 20 from the def of the existing data
//Perform four fundamental arithmetic operations on your inDate row
SendQueue.Enqueue(Backend.GameData.UpdateWithCalculationV2, "tableName", inDate, Backend.UserInDate, updateParam ,callback =>
{
// Post-process
});
//Perform four fundamental arithmetic operations on other's inDate row
SendQueue.Enqueue(Backend.GameData.UpdateWithCalculationV2, "tableName", inDate, "owner_inDate", updateParam ,callback =>
{
// Post-process
});
ReturnCase
Success cases
When the modification is successful
statusCode : 204
message : Success
Error cases
When the data in Param is not modified as AddCalculation type
statusCode : 400
errorCode : BadParameterException
message : bad operator have to been, Invalid operator
When there is an attempt to modify data that is not a number type
statusCode : 400
errorCode : ValidationException
message : An operand in the update expression has an incorrect data type
When the user tries to modify a non-existent column
statusCode : 400
errorCode : ValidationException
message : An operand in the update expression has an incorrect data type
(Schema) When there is an attempt to modify a null or non-existent column
statusCode : 404
errorCode : NotFoundException
message : column not found, column cannot be found.
When the tableName does not exist
statusCode : 404
errorCode : NotFoundException
message : table not found, table cannot be found
When the inDate does not exist
statusCode : 404
errorCode : NotFoundException
message : gameInfo not found, gameInfo cannot be found
When the eight fields (partition, gamer_id, inDate, updatedAt, sender, receiver, reservationDate, and owner_inDate) are included in param
statusCode : 405
errorCode : MethodNotAllowedParameterException
message : MethodNotAllowed {param value}, Unavailable {param value}
When an attempt is made to modify an inactive table
statusCode : 412
errorCode : PreconditionFailed
message : inactiveTable prerequisites are not met.
When one row (group of columns) exceeds 400 KB
statusCode : 413
errorCode : ServerErrorException
message : request entity too large