Skip to main content
Version: 5.11.8

UpdateWithCalculationV2

public BackendReturnObject UpdateWithCalculationV2(string tableName, string inDate, string owner_inDate, Param param);

Parameters

ValueTypeDescription
tableNamestringTable name to be updated
inDatestringinDate value of the row to look up
owner_inDatestringinDate of the user who owns the row
paramParamInformation 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 the 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, and owner_inDate, are used by the server.
When these columns are included in the param, an error occurs.

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

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); // Adds 10 to atk of the existing data
updateParam.AddCalculation("def", GameInfoOperator.subtraction, 20); // Subtracts 20 from the def of the existing data
updateParam.AddCalculation("exp", GameInfoOperator.division, 2); // Decreases the exp of the existing data by 1/2
updateParam.AddCalculation("money", GameInfoOperator.multiplication, 1.25); // Increases the money of the existing data by 1.25 times

// Performs four fundamental arithmetic operations on your inDate row
Backend.GameData.UpdateWithCalculationV2("tableName", inDate, Backend.UserInDate, updateParam);

//Performs 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); // Adds 10 to atk of the existing data
updateParam.AddCalculation("def", GameInfoOperator.subtraction, 20); // Subtracts 20 from the def of the existing data
updateParam.AddCalculation("exp", GameInfoOperator.division, 2); // Decreases the exp of the existing data by 1/2
updateParam.AddCalculation("money", GameInfoOperator.multiplication, 1.25); // Increases the money of the existing data by 1.25 times

//Performs four fundamental arithmetic operations on your inDate row
Backend.GameData.UpdateWithCalculationV2("tableName", inDate, Backend.UserInDate, updateParam, callback =>
{
// Post-process
});

//Performs 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); // Adds 10 to atk of the existing data
updateParam.AddCalculation("def", GameInfoOperator.subtraction, 20); // Subtracts 20 from the def of the existing data
updateParam.AddCalculation("exp", GameInfoOperator.division, 2); // Decreases the exp of the existing data by 1/2
updateParam.AddCalculation("money", GameInfoOperator.multiplication, 1.25); // Increases the money of the existing data by 1.25 times

//Performs four fundamental arithmetic operations on your inDate row
SendQueue.Enqueue(Backend.GameData.UpdateWithCalculationV2, "tableName", inDate, Backend.UserInDate, updateParam ,callback =>
{
// Post-process
});

//Performs four fundamental arithmetic operations on other's inDate row
SendQueue.Enqueue(Backend.GameData.UpdateWithCalculationV2, "tableName", inDate, "owner_inDate", updateParam ,callback =>
{
// Post-process
});

Return cases

Success cases

When the modification is successful
statusCode : 204

Error cases

When the data in Param is not modified as AddCalculation type
statusCode : 400
errorCode : BadParameterException

When there is an attempt to modify data that is not a number type
statusCode : 400
errorCode : ValidationException

When the user tries to modify a non-existent column
statusCode : 400
errorCode : ValidationException

When the tableName does not exist
statusCode : 404
errorCode : NotFoundException

When the inDate does not exist
statusCode : 404
errorCode : NotFoundException

(Schema) When there is an attempt to modify a null or non-existent column
statusCode : 404
errorCode : NotFoundException

When the eight fields(partition, gamer_id, inDate, updatedAt, sender, receiver, reservationDate, and owner_inDate) are included in param
statusCode : 405
errorCode : MethodNotAllowedParameterException

When an attempt is made to modify an inactive table
statusCode : 412
errorCode : PreconditionFailed

When one row(group of columns) exceeds 400 KB
statusCode : 413
errorCode : ServerErrorException