This method overwrites the data on the server with the key-value pairs sent from the client (the data on the server will be lost).
This method checks for overwrites using a technique known as optimistic locking. If the data on the server has been updated by other clients after you got the KiiObject, your update is rejected with an error.
Here is the sample code:
This is what is happening in the sample code:
Prepare a KiiObject to update. In this sample code, we are creating a KiiObject with its URI (Replace the URI in the code with the real one when you are running the code).
Use the refresh() method to get the latest key-value pairs in the server. This is required to get the latest _version value that indicates the update status of the KiiObject.
Add key-value pairs with the set() method and remove a key-value pair with the remove() method. Only the key-value pairs set here will be in the KiiOject after the updating.
Execute the saveAllFields() method to update the KiiObject. By setting the argument to false, we are enabling the overwrite check; the method returns an error if the KiiObject on the server has been updated by another client.