IncrementSingletonData
Increments the specified fields, of the singleton owned by the user, by the specified amount within the custom entity data on the server.
Service | Operation |
---|---|
customEntity | INCREMENT_SINGLETON_DATA |
Method Parameters
Parameter | Description |
---|---|
entityType | The type of custom entity being updated. |
fieldsJson | Specific fields, as JSON, within entity's custom data, with respective increment amount. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string entityType = "athletes";
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.IncrementSingletonData(entityType, fieldsJson, successCallback, failureCallback);
const char *entityType = "athletes";
const char *fieldsJson = "{ \"goals\": 3, \"assists\": 5 }";
_bc->getCustomEntityService()->incrementSingletonData(entityType, fieldsJson, this);
NSString *entityType = @"athletes";
NSString *fieldsJson = "{ \"goals\": 3, \"assists\": 5 }";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc customEntityService] incrementSingletonData:entityType
fieldsJson:fieldsJson
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String entityType = "athletes";
String fieldsJson = "{ \"goals\": 3, \"assists\": 5 }";
this; // implements IServerCallback
_bc.getCustomEntityService().incrementSingletonData(entityType, fieldsJson, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var entityType = "athletes";
var fieldsJson = {
"goals": 3,
"assists": 5
};
_bc.customEntity.incrementSingletonData(entityType, fieldsJson, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var entityType = "athletes";
var fieldsJson = {
"goals": 3,
"assists": 5
};
ServerResponse result = await _bc.customEntityService.incrementSingletonData(entityType:entityType, fieldsJson:fieldsJson);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var entityType = "athletes";
var fieldsJson = {
"goals": 3,
"assists": 5
};
var customEntityProxy = bridge.getCustomEntityServiceProxy();
var postResult = customEntityProxy.incrementSingletonData(entityType, fieldsJson);
if (postResult.status == 200) {
// Success!
}
{
"service": "customEntity",
"operation": "INCREMENT_SINGLETON_DATA",
"data":
{
"entityType": "athletes",
"fieldsJson": {
"goals": 3,
"assists": 5
}
}
}
JSON Response
{
"data": {
"timeToLive": null,
"createdAt": 1663079696618,
"data": {
"goals": 5,
"assists": 9
},
"entityType": "athletes",
"entityId": "aab8cc93-0f7b-4f42-9072-2437fc12737f",
"acl": {
"other": 1
},
"ownerId": "f5a6f67b-efa8-494f-b17e-d0f7f4b1e71e",
"version": 2,
"expiresAt": null,
"updatedAt": 1663079731601
},
"status": 200
}