Skip to main content
Version: 5.7.0

UpdateSingleton

Method updates a singleton entity on the server. This operation results in the entity data being completely replaced by the passed in JSON string. If the entity doesn't exist it is created.

Singletons are defined by their entity type, so no two singletons of the same type can exist at once.

This method is affected by versioning. See the versioning documentation for more information.

ServiceOperation
entityUPDATE_SINGLETON

Method Parameters

ParameterDescription
entityTypeThe entity type as defined by the user
dataThe entity's data object
aclThe entity's Access Control List as object. A null ACL implies default permissions which make the entity readable/writeable by only the user.
versionThe version of the entity to update. Use -1 to indicate the newest version

Usage

http://localhost:3000
string entityType = "settings";
string jsonEntityData = "{\"difficulty\":\"normal\"}";
string jsonEntityAcl = "{\"other\":0}";
int version = -1;
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.EntityService.UpdateSingleton(entityType, jsonEntityData, jsonEntityAcl, version, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": {
"entityType": "test",
"version": 1 // Note - `version` will only be returned if not null or -1 in the update call
}
}