Skip to main content
Version: 5.7.0

UpdateEntityFields

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 UpdateEntityFieldsSharded() version of this method instead.

Used to update only a specific set of fields with the custom data section of the custom entity object.

The outer "data" portion of the field name is implied, and should not be included.

fieldsJson example:

{
"age": 30,
"homeAddress": {
"street": Breakwater Street",
"number": "11",
"city": "Souris",
"state": "PEI",
"country": "CA",
"phone": "555-555-1234"
},
"workAddress.phone": "555-555-5555"
}

For the above example:

  • the data.age field will be set to 30
  • the data.homeAddress field will be set to the full JSON address provided
  • just the phone sub-field of the data.workAddress object will be set to "555-555-5555"
ServiceOperation
customEntityUPDATE_ENTITY_FIELDS

Method Parameters

ParameterDescription
entityTypeThe type of custom entity being updated.
entityIdThe id of custom entity being updated.
versionVersion of the custom entity being updated.
fieldsJsonSpecific fields, as JSON, to set within entity's custom data.

Usage

http://localhost:3000
string entityType = "athletes";
string entityId = "aaaa-bbbb-cccc-dddd";
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.UpdateEntityFields(entityType, entityId, version, fieldsJson, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": {
"entityId": "1497cc7e-66cb-4682-xxxx-c755523369a8",
"version": 2,
"acl": {
"other": 1
},
"ownerId": null,
"expiresAt": null,
"timeToLive": null,
"createdAt": 1573540122600,
"updatedAt": 1573540445332
}
}