UpdateDataWithCalculation
public BackndReturnObject UpdateMyLatestDataByOperation(string tableName, Param param);
public BackndReturnObject UpdateMyDataByOperation(string tableName, string inDate, Param param);
public BackndReturnObject UpdateOtherDataByOperation(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 look up |
owner_inDate | string | inDate of the user who owns the row |
param | Param | Information to be updated(inserts data using AddCalculation) |
Description
UpdateMyLatestDataByOperation method modifies a piece of my data that has been registered most recently in the table via addition or subtraction.
UpdateMyDataByOperation method modifies a piece of my data in the table identical to inDate via addition or subtraction.
UpdateOtherDataByOperation method modifies a piece of my data in the table identical to inDate and owner_inDate via addition or subtraction. (If public, the data of others can also be modified.)
- 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.
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.
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 |
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 param = new Param();
param.AddCalculation("gold", Calculating.addition, 10);
// Modify my data that has been registered most recently in the table
Backnd.PlayerTable.UpdateMyLatestDataByOperation("tableName", param);
// Modify my data in the table that is identical to inDate
Backnd.PlayerTable.UpdateMyDataByOperation("tableName", "2023-10-25:11:34:24.124Z", param);
// Modify data in the table identical to inDate and owner_inDate (data of others can also be modified)
Backnd.PlayerTable.UpdateOtherDataByOperation("tableName", "2023-10-25:11:34:24.124Z", "2023-10-22:09:14:35.616Z", param);
Asynchronous
Param param = new Param();
param.Add("gold", 100);
param.Add("level", 2);
// Modify my data that has been registered most recently in the table
Backnd.PlayerTable.UpdateMyLatestDataByOperation("tableName", param, (callback) =>
{
// Post-process
});
// Modify data in the table that is identical to inDate
Backnd.PlayerTable.UpdateMyDataByOperation("tableName", "2023-10-25:11:34:24.124Z", param, (callback) =>
{
// Post-process
});
// Modify data in the table identical to inDate and owner_inDate (data of others can also be modified)
Backnd.PlayerTable.UpdateOtherDataByOperation("tableName", "2023-10-25:11:34:24.124Z", "2023-10-22:09:14:35.616Z", param, (callback) =>
{
// Post-process
});
ReturnCase
Success cases
When the modification is successful
statusCode : 200
returnValue : {"ConsumedCapacity":{"Read":{"CapacityUnits":1},"Write":{"CapacityUnits":4}}}
Error cases
When GameInfoOperator.multiplication (multiplication) and GameInfoOperator.division (division) have been passed into Param.AddCalculation()
statusCode : 400
errorCode : ValidationException
(Schema) When a column whose schema is not defined is included in param
statusCode : 400
errorCode : BadParameterException
(Schema) When the data type of the column declared upon defining the schema is different from that of the column to be updated
statusCode : 400
errorCode : BadParameterException
(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
(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
When the total number of columns to be calculated is over 290
statusCode : 400
errorCode : ValidationException
When the total number of columns to be modified is over 290
statusCode : 400
errorCode : ValidationException
When the user tries to modify other people's information in a private table
statusCode : 403
errorCode : ForbiddenException
When the tableName does not exist
statusCode : 404
errorCode : NotFoundException
When the inDate does not exist
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 there is an attempt to modify an inactive table
statusCode : 412
errorCode : PreconditionFailed
When the size of data to be updated exceeds 400 KB
statusCode : 413
errorCode : ServerErrorException