UpdateSingletonFields
Partially updates the data, of the singleton owned by the user for the specified custom entity type, with the specified fields, on the server.
Service | Operation |
---|---|
customEntity | UPDATE_SINGLETON_FIELDS |
Method Parameters
Parameter | Description |
---|---|
entityType | The type of custom entity singleton being updated. Custom entity type must have option isOwned set to true. |
version | Version of the custom entity singleton being updated. |
fieldsJson | Specific fields, as JSON, to set within singleton entity's custom data. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string entityType = "athletes";
int version = 1;
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.UpdateSingletonFields(entityType, version, fieldsJson, successCallback, failureCallback);
const char *entityType = "athletes";
int version = 1;
const char *fieldsJson = "{\"goals\":3,\"assists\":5}";
_bc->getCustomEntityService()->updateSingletonFields(entityType, version, fieldsJson, this);
NSString *entityType = @"athletes";
int version = 1;
NSString *fieldsJson = "{\"goals\":3,\"assists\":5}";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc customEntityService] updateSingletonFields:entityType
version:version
fieldsJson:fieldsJson
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String entityType = "athletes";
int version = 1;
String fieldsJson = "{\"goals\":3,\"assists\":5}";
this; // implements IServerCallback
_bc.getCustomEntityService().updateSingletonFields(entityType, version, 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 version = 1;
var fieldsJson = {
"goals": 3,
"assists": 5
};
_bc.customEntity.updateSingletonFields(entityType, version, fieldsJson, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var entityType = "athletes";
var version = 1;
var fieldsJson = {
"goals": 3,
"assists": 5
};
ServerResponse result = await _bc.customEntityService.updateSingletonFields(entityType:entityType, version:version, fieldsJson:fieldsJson);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var entityType = "athletes";
var version = 1;
var fieldsJson = {
"goals": 3,
"assists": 5
};
var customEntityProxy = bridge.getCustomEntityServiceProxy();
var postResult = customEntityProxy.updateSingletonFields(entityType, version, fieldsJson);
if (postResult.status == 200) {
// Success!
}
{
"service": "customEntity",
"operation": "UPDATE_SINGLETON_FIELDS",
"data": {
"entityType": "athletes",
"version": 1,
"fieldsJson": {
"goals": 3,
"assists": 5
}
}
}
JSON Response
{
"data": {
"version": 2,
"updatedAt": 1591821018374
},
"status": 200
}