Skip to main content
Version: 5.7.0

IncrementData

tip

This method is not sharding safe - and thus is not recommended for custom entities that you may want to shard for greater performance and scalability in the future. Consider using IncrementDataSharded() version of this method instead.

Increments the specified fields by the specified amount within custom entity data on the server, enforcing ownership/ACL permissions.

ServiceOperation
customEntityINCREMENT_DATA

Method Parameters

ParameterDescription
entityTypeThe type of custom entity being updated.
entityIdThe id of custom entity being updated.
fieldsJsonSpecific fields, as JSON, within entity's custom data, with respective increment amount.

Usage

http://localhost:3000
string entityType = "athletes";
string entityId = "aaaa-bbbb-cccc-dddd";
string fieldsJson = "{ \"goals\": 3, \"assists\": 5 }";
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};

_bc.CustomEntityService.IncrementData(entityType, entityId, fieldsJson, successCallback, failureCallback);
JSON Response
{
"data": {
"entityId": "aaaa-bbbb-cccc-dddd",
"version": 2,
"acl": {
"other": 2
},
"ownerId": null,
"expiresAt": null,
"timeToLive": null,
"createdAt": 1586047449214,
"updatedAt": 1591290232477,
"data": {
"goals": 3,
"assists": 5
},
"entityType": "athletes"
},
"status": 200
}