Partial Update without the Overwrite Check

This method merges the data on the server with the key-value pairs sent from the client. You will send only key-value pairs you want to update from the client to the server. Note that you cannot delete the keys on the server with this method.

The data will be overwritten unconditionally regardless of if the data on the server is updated by other clients.

Here is the sample code:

  • // Instantiate a KiiObject.
    var object2 = KiiObject.objectWithURI(object.objectURI());
    
    // Update key-value pairs.
    object2.set("myid", 1);
    object2.set("name", "John Doe Jr");
    object2.set("email", "john_jr@example.com");
    
    // Save and partially update the KiiObject.
    // This method appends the key-value pairs generated locally
    // to the KiiObject on the server.
    object2.save().then(
      function(theObject) {
        // Do something.
      }
    ).catch(
      function(error) {
        var theObject = error.target;
        var errorString = error.message;
        // Handle the error.
      }
    );
  • // Instantiate a KiiObject.
    var object2 = KiiObject.objectWithURI(object.objectURI());
    
    // Update key-value pairs.
    object2.set("myid", 1);
    object2.set("name", "John Doe Jr");
    object2.set("email", "john_jr@example.com");
    
    // Save and partially update the KiiObject.
    // This method appends the key-value pairs generated locally
    // to the KiiObject on the server.
    object2.save({
      success: function(theObject) {
        // Do something.
      },
      failure: function(theObject, errorString) {
        // Handle the error.
      }
    });

This is what is happening in the sample code:

  1. 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).
  2. Set the key-value pairs to update.
  3. Execute the save() method to update the KiiObject. We are not using the overwrite check, so the update will be made unconditionally.

You do not need to execute the refresh() method when updating a KiiObject partially. If you execute the refresh() method, all key-value pairs on the server will be downloaded to the client. So, the update will be virtually the full update.

When you partially update a KiiObject, you cannot remove key-value pairs with the remove() method. This is because the local key-value pairs are merged with those on the server. Fully update the KiiObject to remove key-value pairs.